Commit graph

317 commits

Author SHA1 Message Date
Matt Corallo c2efd981aa (finally) Remove IRC Seed support now that lfnet is down. 2013-03-24 19:38:19 -04:00
Philip Kaufmann 967125ca4a blockchain -> block chain (used everywhere else) 2013-03-21 08:23:23 +01:00
Gavin Andresen e5f163a041 -alertnotify=<cmd>
Runs a shell command when an AppliesToMe() alert is received.
%s in the <cmd> string is replaced with the alert.strStatusBar
message.
2013-03-19 15:16:30 -04:00
Gregory Maxwell 124f823714 Deleting everything except the wallet will not help recover from BDB errors.
Now that the wallet is the only thing in BDB any DB open errors must be
from the wallet itself-- so deleting everything else will not likely help.
2013-03-19 10:11:43 -07:00
Philip Kaufmann e1ca89df1f harmonize 2 init messages and remove one
- harmonize the database related init messages
- as we have a thread for importing blocks, that init message is obsolete
2013-03-13 09:17:59 +01:00
Wladimir J. van der Laan 0bd573d666 Merge pull request #2186 from Diapolo/misc_stuff
small changes in init, main, checkpoints.h and bitcoin-qt.pro
2013-02-23 23:52:27 -08:00
Gavin Andresen 49e332f6fc Merge pull request #1974 from kjj2/walletnotify
Add -walletnotify to call an external script on wallet transactions
2013-02-22 08:47:04 -08:00
Mike Hearn 0556bb22e1 Shorten a startup message. It was getting truncated and looks ugly. 2013-02-20 16:35:30 +01:00
Philip Kaufmann 69e0774714 small changes in init, main, checkpoints.h and bitcoin-qt.pro
- remove an unneeded MODAL flag, as MSG_ERROR sets MODAL
- re-order an if-clause in main to have bool checks before a function call
- fix some log messages that used wrong function names
- make a log message use a correct ellipsis
- remove some unneded spaces, brackets and line-breaks
- fix style for adding files in the Qt project
2013-02-20 08:46:38 +01:00
Pieter Wuille f7f3a96b74 Improve block database load error reporting 2013-02-17 23:25:42 +01:00
Pieter Wuille 386037615a Make sure the genesis block is present after reindex 2013-02-01 23:29:59 +01:00
Pieter Wuille 421218d304 Deal with LevelDB errors 2013-01-30 04:30:02 +01:00
Pieter Wuille ef3988ca36 CValidationState framework 2013-01-30 03:56:44 +01:00
Pieter Wuille 56869fc07c Check only 288 blocks at startup by default 2013-01-26 18:57:07 +01:00
Gavin Andresen 63cc7661a5 Merge pull request #2168 from sipa/txindex
Add optional transaction index to databases
2013-01-25 12:55:52 -08:00
Wladimir J. van der Laan 0c16cc73ef Merge pull request #2171 from Diapolo/init
add InitMessage() to noui and use debug.log for GUI
2013-01-19 06:29:34 -08:00
Pieter Wuille 2d1fa42e85 Add optional transaction index to databases
By specifying -txindex when initializing the database, a txid-to-diskpos
index is maintained in the blktree database. This database is used to
help answering getrawtransaction() RPC queries, when enabled.

Changing the -txindex value requires a -reindex; the client will abort
at startup if the database and the specified -txindex mismatch.
2013-01-18 14:39:11 +01:00
Gavin Andresen 0e31ae9818 Merge pull request #2060 from sipa/parallel
Parallel script verification
2013-01-17 16:58:58 -08:00
Gavin Andresen c83c3cbe97 Merge pull request #2172 from Diapolo/init_messages
make database init messages more valuable
2013-01-14 12:49:42 -08:00
Gavin Andresen dd46c88f2f Merge pull request #2099 from gavinandresen/blkfile_upgrade
Upgrading to 0.8: re-use blkNNNN.dat files.
2013-01-14 11:37:12 -08:00
Philip Kaufmann 06494cabb4 make database init messages more valuable
- it was bad, that quite some messages were just talking about a database,
  I think a user should know, if we are talking about wallet db or
  block/coin db
- also adds a new init message for "Verifying block database integrity..."
2013-01-13 21:22:40 +01:00
Philip Kaufmann bb41a87d57 add InitMessage() to noui and use debug.log for GUI
- this pull adds an InitMessage() function to noui.cpp, which outputs init
  messages to debug.log (this allows to remove some printf() calls from
  init.cpp)
- change InitMessage() in bitcoin.cpp to also write init messages to
  debug.log to ensure nothting is missing in the log because of the
  removal of printf() calls in init.cpp
2013-01-11 22:57:22 +01:00
Pieter Wuille f9cae832e6 Parallelize script verification
* During block verification (when parallelism is requested), script
  check actions are stored instead of being executed immediately.
* After every processed transactions, its signature actions are
  pushed to a CScriptCheckQueue, which maintains a queue and some
  synchronization mechanism.
* Two or more threads (if enabled) start processing elements from
  this queue,
* When the block connection code is finished processing transactions,
  it joins the worker pool until the queue is empty.

As cs_main is held the entire time, and all verification must be
finished before the block continues processing, this does not reach
the best possible performance. It is a less drastic change than
some more advanced mechanisms (like doing verification out-of-band
entirely, and rolling back blocks when a failure is detected).

The -par=N flag controls the number of threads (1-16). 0 means auto,
and is the default.
2013-01-08 02:00:59 +01:00
Pieter Wuille 1f355b66cd New database check routine
-checklevel gets a new meaning:
0: verify blocks can be read from disk (like before)
1: verify (contextless) block validity (like before)
2: verify undo files can be read and have good checksums
3: verify coin database is consistent with the last few blocks
   (close to level 6 before)
4: verify all validity rules of the last few blocks

Level 3 is the new default, as it's reasonably fast. As level 3 and
4 are implemented using an in-memory rollback of the database, they
are limited to as many blocks as possible without exceeding the
limits set by -dbcache. The default of -dbcache=25 allows for some
150-200 blocks to be rolled back.

In case an error is found, the application quits with a message
instructing the user to restart with -reindex. Better instructions,
and automatic recovery (when possible) or automatic reindexing are
left as future work.
2013-01-04 14:58:47 +01:00
Jeff Garzik 3f964b3c50 Remove 'T' from remaining date/time format strings. 2013-01-01 15:28:28 -05:00
Philip Kaufmann b8397fbfcd update 2 command-line parameter help messages
- -checkpoints is now much more understandable and should be way easier
  to translate
- -loadblock uses the same format (blk000??.dat) as -reindex
2012-12-28 14:55:38 +01:00
Gavin Andresen f4445f9982 Upgrading to 0.8: re-use blkNNNN.dat files. 2012-12-16 12:23:59 -05:00
Pieter Wuille 33766c9557 Merge pull request #2096 from 94m3k1n9/fix-time-formats
Change timestamps to use ISO8601 formatting
2012-12-13 14:39:57 -08:00
Gavin Andresen a9e055a1ca Merge pull request #2048 from jgarzik/no-checkpoints
Add "checkpoints" option, to permit disabling of checkpoint logic.
2012-12-12 09:18:00 -08:00
Gavin Andresen 043a8fb98d Merge pull request #2059 from sipa/benchmark
Add -benchmark for reporting block processing times
2012-12-12 09:14:52 -08:00
Gavin Andresen dbd5bb8039 Merge pull request #2062 from sipa/nocoins
Reconstruct coins/ database when missing
2012-12-12 09:11:36 -08:00
Richard Schwab 303b0009dc Change timestamps to use ISO8601 formatting 2012-12-12 16:32:22 +01:00
Pieter Wuille 3fb9b99cca Allow lengthy block reconnections to be interrupted
When the coin database is out of date with the block database, the
best block in it is automatically switched to. This reconnection
process can take time, so allow it to be interrupted.

This also stops block connection as soon as shutdown is requested,
leading to a faster shutdown.
2012-12-06 22:04:59 +01:00
Pieter Wuille 89b7019be8 Reconstruct coins/ from scratch when missing. 2012-12-06 17:00:12 +01:00
Pieter Wuille 8a28bb6dee Add -benchmark for reporting block processing times 2012-12-05 23:06:01 +01:00
Philip Kaufmann a8a4b9673e add 2 constructors in CDiskBlockPos to simplify class usage
- add a default-constructor, which simply calls SetNull() and a
  constructor to directly pass nFile and nPos
- change code to use that new constructors
2012-12-03 10:19:17 +01:00
Jeff Garzik 857b3ad923 Add "checkpoints" option, to permit disabling of checkpoint logic. 2012-11-28 12:07:42 -05:00
Philip Kaufmann 5350ea4171 update CClientUIInterface and remove orphan Wx stuff
- fix ThreadSafeMessageBox always displays error icon
- allow to specify MSG_ERROR / MSG_WARNING or MSG_INFORMATION without a
  custom caption / title
- allow to specify CClientUIInterface::ICON_ERROR / ICON_WARNING and
  ICON_INFORMATION (which is default) as message box icon
- remove CClientUIInterface::OK from ThreadSafeMessageBox-calls, as
  the OK button will be set as default, if none is specified
- prepend "Bitcoin - " to used captions
- rename BitcoinGUI::error() -> BitcoinGUI::message() and add function
  documentation
- change all style parameters and enum flags to unsigned
- update code to use that new API

- update Client- and WalletModel to use new BitcoinGUI::message() and
  rename the classes error() method into message()
- include the possibility to supply the wanted icon for messages from
  Client- and WalletModel via "style" parameter
2012-11-26 13:32:31 +01:00
Philip Kaufmann 29e214aaf5 make enum and parameter used in Bind() unsigned
- it's good practise to use unsigned int for enum flags, so change this
  one, as I introduced this for Bind()
2012-11-14 16:13:18 +01:00
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
kjj2 cae686d31e Add -walletnotify to call an external script on wallet transactions 2012-11-03 10:07:57 -05: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
Luke Dashjr 814efd6f1f Bugfix: Fix a variety of misspellings 2012-08-01 17:49:51 +00:00
Philip Kaufmann e6bc9c35f3 Update Warning-strings to use a standard-format
- ensure warnings always start with "Warning:" and that the first
  character after ":" is written uppercase
- ensure the first sentence in warnings ends with an "!"
- remove unneeded spaces from Warning-strings
- add missing Warning-string translation
- remove a "\n" and replace with untranslatable "<br><br>"
2012-08-01 19:33:32 +02:00
Jeff Garzik 06e0e1c853 Merge pull request #1465 from Diapolo/NOUI_showSSLVersion
write used OpenSSL library version to debug.log
2012-08-01 10:08:45 -07:00
Jeff Garzik b5029b87c8 Merge pull request #1396 from rebroad/NoShrinkOption
Make truncating the debug.log file an option.
2012-08-01 09:41:50 -07:00
Philip Kaufmann 6986c779f0 update HelpMessage()
- place "-?" option at first
- re-work description and "\n" usage for Gavins new block creation options
  to better match current description syntax
- ensure no "\n" is in translated strings, which is better for Transifex
2012-07-27 14:03:37 +02:00
Gavin Andresen c555400ca1 When creating new blocks, sort 'paid' area by fee-per-kb
Modify CreateNewBlock so that instead of processing all transactions
in priority order, process the first 27K of transactions in
priority order and then process the rest in fee-per-kilobyte
order.

This is the first, minimal step towards better a better fee-handling
system for both miners and end-users; this patch should be easy
to backport to the old versions of Bitcoin, and accomplishes the
most important goal-- allow users to "buy their way in" to blocks
using transaction fees.
2012-07-26 14:24:19 -04:00
Giel van Schijndel 96931d6f78 Give threads a recognisable name to aid in debugging
NOTE: These thread names are visible in gdb when using 'info threads'.
      Additionally both 'top' and 'ps' show these names *unless* told to
      display the command-line instead of task name.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-07-17 01:50:35 +02:00
Philip Kaufmann 31b581bcac write used OpenSSL library version to debug.log 2012-07-04 08:18:03 +02:00
Matt Corallo 6d6c2afb2b Change default send buffer to 1Mb. 2012-07-01 04:17:26 +02:00
Matt Corallo 18c4beb05b Revert "*Always* send a shutdown signal to enable custom shutdown actions"
This reverts commit 896899e0d6.
2012-06-28 15:52:45 +02:00