Commit graph

227 commits

Author SHA1 Message Date
Philip Kaufmann c73323eec9 allow listening on -bind=address for blocked networks
- this allows the client to listen on via -bind specified addresses
  (e.g. 127.0.0.1), even when a network (IPv4 in that case) was blocked
  via e.g -onlynet="Tor"
- introduce enum BindFlags to avoid passing multiple bools to Bind()
- make -bind help text clear we ALWAYS listen on the specified address
- remove an unused variable
- remove 2 unneeded IsLimited() checks before calling Bind(), which does
  these checks anyway

- usage case: specify -bind=127.0.0.1 -onlynet="Tor" to allow incoming
  connections to a Tor hidden service, but still don't allow other IPv4
  nodes to connect / get connected
2012-11-10 00:29:12 +01:00
Pieter Wuille 485cf044ba Merge pull request #1943 from sipa/reindex2
Add -reindex, to perform in-place reindexing of block chain files
2012-11-09 14:50:30 -08:00
Pieter Wuille b41de54a2c Merge pull request #1978 from sipa/nodetach
Remove -detachdb and stop's detach argument.
2012-11-09 14:10:50 -08:00
Pieter Wuille 7fea484674 Add -reindex, to perform in-place reindexing of block chain files
Flushes the blktree/ and coins/ databases, and reindexes the
block chain files, as if their contents was loaded via -loadblock.

Based on earlier work by Jeff Garzik.
2012-11-09 01:06:32 +01:00
Pieter Wuille 7a5b7535bf Move ThreadImport to init.cpp 2012-11-09 01:06:32 +01:00
Pieter Wuille 16d9d61f99 Merge pull request #1981 from sipa/caches
Cache size optimizations
2012-11-08 14:17:37 -08:00
Pieter Wuille 1c83b0a377 Cache size optimizations 2012-11-04 18:06:25 +01:00
Pieter Wuille 92467073ad Remove -detachdb and stop's detach argument.
As the only BDB database left is the wallet, and it is always
detached.

Also remove IsChainFile() predicate and related chainfile-specific
logic.
2012-11-04 12:59:06 +01:00
Philip Kaufmann 6b3783a9c9 fix some double-spaces in strings
- remove some unneeded stuff in sendcoinsentry.ui
- harmonize some "Error:"-messages
2012-10-25 22:25:50 +02:00
Pieter Wuille bb790aa24d First flush block tree, then coin set
As the coinset data refers to the best block, stored in the block
tree. Flushing the coin set first can cause inconsistencies if
the process gets killed in between.
2012-10-25 20:47:17 +02:00
tucenaber 3026baaa7c Added checks for null pointers in Shutdown
Estetics
2012-10-25 20:45:38 +02:00
Philip Kaufmann 729b180686 change blockchain -> block chain (spelling)
- Wiki says "block chain" is correct ;)
- remove some unneeded spaces I found in the source, while fixing the spelling
2012-10-21 21:32:25 +02:00
Pieter Wuille e1bfbab802 Add LevelDB MemEnv support
Support LevelDB memory-backed environments, and use them in unit tests.
2012-10-20 23:08:57 +02:00
Pieter Wuille 2d8a48292b LevelDB block and coin databases
Split off CBlockTreeDB and CCoinsViewDB into txdb-*.{cpp,h} files,
implemented by either LevelDB or BDB.

Based on code from earlier commits by Mike Hearn in his leveldb
branch.
2012-10-20 23:08:57 +02:00
Pieter Wuille d979e6e36a Use singleton block tree database instance 2012-10-20 23:08:57 +02:00
Pieter Wuille 857c61df0b Prepare database format for multi-stage block processing
This commit adds a status field and a transaction counter to the block
indexes.
2012-10-20 23:08:57 +02:00
Pieter Wuille 4fea06db25 Automatically reorganize at startup to best known block
Given that the block tree database (chain.dat) and the active chain
database (coins.dat) are entirely separate now, it becomes legal to
swap one with another instance without affecting the other.

This commit introduces a check in the startup code that detects the
presence of a better chain in chain.dat that has not been activated
yet, and does so efficiently (in batch, while reusing the blk???.dat
files).
2012-10-20 23:08:57 +02:00
Pieter Wuille ae8bfd12da Batch block connection during IBD
During the initial block download (or -loadblock), delay connection
of new blocks a bit, and perform them in a single action. This reduces
the load on the database engine, as subsequent blocks often update an
earlier block's transaction already.
2012-10-20 23:08:57 +02:00
Pieter Wuille 450cbb0944 Ultraprune
This switches bitcoin's transaction/block verification logic to use a
"coin database", which contains all unredeemed transaction output scripts,
amounts and heights.

The name ultraprune comes from the fact that instead of a full transaction
index, we only (need to) keep an index with unspent outputs. For now, the
blocks themselves are kept as usual, although they are only necessary for
serving, rescanning and reorganizing.

The basic datastructures are CCoins (representing the coins of a single
transaction), and CCoinsView (representing a state of the coins database).
There are several implementations for CCoinsView. A dummy, one backed by
the coins database (coins.dat), one backed by the memory pool, and one
that adds a cache on top of it. FetchInputs, ConnectInputs, ConnectBlock,
DisconnectBlock, ... now operate on a generic CCoinsView.

The block switching logic now builds a single cached CCoinsView with
changes to be committed to the database before any changes are made.
This means no uncommitted changes are ever read from the database, and
should ease the transition to another database layer which does not
support transactions (but does support atomic writes), like LevelDB.

For the getrawtransaction() RPC call, access to a txid-to-disk index
would be preferable. As this index is not necessary or even useful
for any other part of the implementation, it is not provided. Instead,
getrawtransaction() uses the coin database to find the block height,
and then scans that block to find the requested transaction. This is
slow, but should suffice for debug purposes.
2012-10-20 23:08:57 +02:00
Pieter Wuille 66b02c93e6 Move external block import to separate thread 2012-10-20 01:54:10 +02:00
Wladimir J. van der Laan 22bb049011 Fix a use-after-free problem in initialization (#1920)
Don't store the result of c_str().

Luckily, this only affects logging, though it could crash or leak
sensitive data to the log in rare cases.
2012-10-12 03:09:05 +02:00
Gavin Andresen de038acd96 Fix bad merge, pszDataDir duplication 2012-10-09 12:28:00 -04:00
Gavin Andresen 673021410f Merge branch 'wallet_exceptions' of github.com:gavinandresen/bitcoin-git 2012-10-09 12:14:26 -04:00
Jeff Garzik b855abb8db Revert "Send 'mempool' P2P command at the start of each P2P session"
Fat-fingered on github, and merged this too early.

This reverts commit 22f9b06903.
2012-10-08 18:14:15 -04:00
Jeff Garzik 56caa38a67 Merge pull request #1833 from jgarzik/mempool-query
Send 'mempool' P2P command at the start of each P2P session
2012-10-08 15:12:25 -07:00
Gavin Andresen d0b3e77a08 Don't try to verify a non-existent wallet.dat 2012-10-08 17:46:46 -04:00
Gavin Andresen eed1785f70 Handle corrupt wallets gracefully.
Corrupt wallets used to cause a DB_RUNRECOVERY uncaught exception and a
crash. This commit does three things:

1) Runs a BDB verify early in the startup process, and if there is a
low-level problem with the database:
  + Moves the bad wallet.dat to wallet.timestamp.bak
  + Runs a 'salvage' operation to get key/value pairs, and
    writes them to a new wallet.dat
  + Continues with startup.

2) Much more tolerant of serialization errors. All errors in deserialization
are reported by tolerated EXCEPT for errors related to reading keypairs
or master key records-- those are reported and then shut down, so the user
can get help (or recover from a backup).

3) Adds a new -salvagewallet option, which:
 + Moves the wallet.dat to wallet.timestamp.bak
 + extracts ONLY keypairs and master keys into a new wallet.dat
 + soft-sets -rescan, to recreate transaction history

This was tested by randomly corrupting testnet wallets using a little
python script I wrote (https://gist.github.com/3812689)
2012-10-08 17:46:45 -04:00
Gavin Andresen 8d5f461cb6 Handle incompatible BDB environments
Before, opening a -datadir that was created with a new
version of Berkeley DB would result in an un-caught DB_RUNRECOVERY
exception.

After these changes, the error is caught and the user is told
that there is a problem and is told how to try to recover from
it.
2012-10-08 17:25:17 -04:00
Gavin Andresen c2bb42168b Merge branch 'BDB_DOWNGRADE' 2012-10-08 17:18:17 -04:00
Gavin Andresen e4954b1297 Handle incompatible BDB environments
Before, opening a -datadir that was created with a new
version of Berkeley DB would result in an un-caught DB_RUNRECOVERY
exception.

After these changes, the error is caught and the user is told
that there is a problem and is told how to try to recover from
it.
2012-10-08 15:51:59 -04:00
Wladimir J. van der Laan bb353618f1 Send --help message to stdout i.s.o stderr
This allows fun stuff such as `bitcoin --help | less`, and more
easy piping to files.

Looking at other tools such as bash, gcc, they all send their help
text to stdout.
2012-10-04 07:56:57 +02:00
Philip Kaufmann d210f4f5b8 fix -Wformat warnings all over the source 2012-10-01 19:45:42 +02:00
Pieter Wuille 842a31ad1b Merge pull request #1862 from kjj2/testports
Fix: when testnet=1 specified, change default RPC port to 18332
2012-09-28 08:03:45 -07:00
kjj2 b202d43076 Fix: when testnet=1 specified, change default ports to 18332 and 18333 2012-09-24 15:26:04 -05:00
Jeff Garzik 22f9b06903 Send 'mempool' P2P command at the start of each P2P session
to query remote node mempool contents.
2012-09-24 13:53:44 -04:00
Jeff Garzik 52c90a2b2b Import $DataDir/bootstrap.dat automatically, if it exists.
As discussed on IRC. Intended to make using an external blockchain download
solution just a bit easier.
2012-09-24 13:37:03 -04:00
Gavin Andresen 1913b6e2fc Fix double-paren typo 2012-09-06 16:29:59 -04:00
Philip Kaufmann 274b7ab123 remove double logging of startup time, when !fLogTimestamps 2012-09-05 08:36:50 +02:00
Jeff Garzik dcb14198bb init.cpp: fix build error, and possibly-uninit'd warning 2012-09-04 12:24:08 -04:00
Jeff Garzik 38e8f282d2 Merge pull request #1427 from rebroad/StartTimeFix
No need to log start time if it's already being done on every line.
2012-09-04 09:10:47 -07:00
Jeff Garzik 8c7b6c05db Merge pull request #1738 from laanwj/2012_08_boostthread
implement CreateThread with boost::thread
2012-09-04 08:53:05 -07:00
R E Broadley 016178132e No need to log start time if it's already being done on every line. 2012-09-01 14:24:33 +01:00
Philip Kaufmann d93e5986d7 add default value in -timeout description 2012-08-30 23:28:19 +02:00
Wladimir J. van der Laan 4d1d94c56c Rename CreateThread to NewThread
Prevent clash with win32 API symbol
2012-08-29 20:25:37 +02:00
Luke Dashjr 9655d73f49 Allow building with IPv6 support, but it disabled by default 2012-08-23 21:01:01 +00:00
Pieter Wuille f161a2c211 Fix infinite loops in connection logic 2012-08-22 13:35:33 +02:00
Philip Kaufmann 2d914f89fe add splashscreen message when importing blocks via -loadblock 2012-08-17 14:21:17 +02:00
Philip Kaufmann 3d88c9b4d3 Bitcoin-Qt (Windows only): enable DEP for bitcoin-qt.exe
- this enables DEP on all Windows version which support the
  SetProcessDEPPolicy() call in Kernel32.dll
- use a dynamic approach via GetProcAddress() to not rely on headers or
  compiler libs
- this is the same way the Tor-project does it
2012-08-03 14:51:51 +02:00
Jeff Garzik f81e6f779b Merge pull request #1632 from luke-jr/spelling
Fix spelling and grammar errors
2012-08-01 10:56:47 -07:00
Luke Dashjr b49f1398a1 Bugfix: Correct English grammar regarding "'s" 2012-08-01 17:50:00 +00:00