Commit graph

891 commits

Author SHA1 Message Date
Wladimir J. van der Laan 19a5676280 Use mutex pointer instead of name for AssertLockHeld
This makes it useable for non-global locks such as the wallet and
keystore locks.
2013-12-19 09:46:11 +01:00
Wladimir J. van der Laan cd7fa8bb43 Move nTransactionFee from main.cpp to wallet.cpp
Transaction fee is only used by the wallet.
No need for it to be in main.cpp.
2013-12-13 16:34:57 +01:00
Pieter Wuille b2864d2fb3 Add main-specific node state 2013-12-08 14:51:37 +01:00
Gregory Maxwell 9b59e3bda8 Sanitize assert usage and refuse to compile with NDEBUG.
There were quite a few places where assert() was used with side effects,
 making operation with NDEBUG non-functional.  This commit fixes all the
 cases I know about, but also adds an  #error on NDEBUG because the code
 is untested without assertions and may still have vulnerabilities if
 used without assert.
2013-12-02 11:33:44 -08:00
Gavin Andresen a65edb104d Merge pull request #3329 from gavinandresen/syncdebug
mutex debugging routines: LocksHeld() and AssertLockHeld()
2013-12-01 17:43:37 -08:00
Gavin Andresen 4d707d5120 Add verbose boolean to getrawmempool
Also changes mempool to store CTxMemPoolEntries
to keep track of when they enter/exit the pool.
2013-11-30 15:42:10 +10:00
Gavin Andresen 0733c1bde6 Refactor: move GetValueIn(tx) to tx.GetValueIn()
GetValueIn makes more sense as a CTransaction member.
2013-11-30 15:42:10 +10:00
Gavin Andresen 98c7c8fd1d Remove dead transaction replacement code
This dead code can be resurrected from git history if
transaction replacement is ever implemented. Keeping
dead code in the source is a bad idea, because it implies
it was tested and worked at some point, which is not true.
2013-11-30 15:42:10 +10:00
Gavin Andresen c649637b6c mutex debugging routines: LocksHeld() and AssertLockHeld() 2013-11-29 17:46:19 +10:00
Mike Hearn a946aa8d3e Store and use a sanitized subVer 2013-11-26 13:26:00 +01:00
Mike Hearn ba6a4ea344 Add some additional logging to give extra network insight. 2013-11-26 13:26:00 +01:00
Mike Hearn 6a4c196dd6 Drop fees by 10x due to the persistently higher exchange rate.
The last fee drop was by 5x (from 50k satoshis to 10k satoshis)
in the 0.8.2 release which was about 6 months ago.

The current fee is (assuming a $500 exchange rate) about 5 dollar
cents. The new fee after this patch is 0.5 cents.

Miners who prefer the higher fees are obviously still able to
use the command line flags to override this setting. Miners who
choose to create smaller blocks will select the highest-fee paying
transactions anyway.

This would hopefully be the last manual adjustment ever required
before floating fees become normal.
2013-11-26 15:56:28 +04:00
Julian Langschaedel 848fe68acd cleanup error message consistency
relicts from the CTransaction refactor.
2013-11-22 02:19:18 +01:00
Wladimir J. van der Laan d980f9b7d6
Merge pull request #3257
379778b core: remove includes in .cpp, if header is already in .h (Philip Kaufmann)
2013-11-20 16:18:33 +01:00
Philip Kaufmann 379778bde6 core: remove includes in .cpp, if header is already in .h
- example: if util.h includes stdint.h, remove it from util.cpp, as
  util.h is the first header included in util.cpp
2013-11-15 12:20:16 +01:00
Cozz Lovan 8dfd8c62dc pass nBytes as parameter to GetMinFee(..) 2013-11-14 14:25:04 +01:00
Philip Kaufmann cd696e64df misc small changes to polish after include cleanup 2013-11-11 16:20:39 +01:00
Gavin Andresen 7d7df381f8 Merge pull request #3199 from sipa/mempoolmove
Cleanup refactoring of coins/mempool
2013-11-10 18:09:58 -08:00
Gavin Andresen 358ce2664d New reject p2p message 2013-11-11 10:31:08 +10:00
Pieter Wuille a0fa20a12b Move CCoins-related logic to coins.{cpp.h} 2013-11-10 19:37:56 +01:00
Pieter Wuille 84674082b0 Make CCoinsView use block hashes instead of indices 2013-11-10 19:22:53 +01:00
Brandon Dahler 51ed9ec971 Cleanup code using forward declarations.
Use misc methods of avoiding unnecesary header includes.
Replace int typedefs with int##_t from stdint.h.
Replace PRI64[xdu] with PRI[xdu]64 from inttypes.h.
Normalize QT_VERSION ifs where possible.
Resolve some indirect dependencies as direct ones.
Remove extern declarations from .cpp files.
2013-11-10 09:36:28 -06:00
Wladimir J. van der Laan 9a165e5714 Merge pull request #3155 from wtogami/split_proto_var
Split MIN_PROTO_VERSION into INIT_PROTO_VERSION and MIN_PEER_PROTO_VERSION
2013-11-08 01:03:11 -08:00
Wladimir J. van der Laan e30bd78f81 No more fHaveGUI
No more specific handling of GUI in bitcoin core.
Replace the last usage of fHaveGUI with a fForceServer
parameter on AppInit2.
2013-11-04 14:36:49 +01:00
Patrick Strateman 75ef87dd93 process received messages one at a time without sleeping between messages 2013-11-03 20:25:50 -08:00
Gavin Andresen 319b11607f Refactor: CTxMempool class to its own txmempool.{cpp,h} 2013-11-04 11:27:02 +10:00
Pieter Wuille 694c7c8161
Merge pull request #3087
caca6aa Make some globals in main non-public. (Pieter Wuille)
85eb2ce Do not use the redundant BestInvalidWork record in the block database. (Pieter Wuille)
2013-11-02 15:12:07 +01:00
Pieter Wuille 1dffbf0060
Merge pull request #3114
a616206 Give peer time-adjustment data an own lock (Pieter Wuille)
2013-11-01 01:07:49 +01:00
Pieter Wuille caca6aa4eb Make some globals in main non-public.
This means they are declared static, and their extern definition in
main.h is removed. Also moved CBlockIndexWorkComparator to the .cpp
file.
2013-11-01 00:54:28 +01:00
Pieter Wuille 85eb2cef33 Do not use the redundant BestInvalidWork record in the block database.
As block index entries have a flag for marking invalid blocks, the
'best invalid work' information can be derived from there. In addition,
remove the global from main.h
2013-11-01 00:54:28 +01:00
Philip Kaufmann 3b570559f8 re-work -debug switch handling
- re-work -debug help message text
- make -debug log every debugging information again (even all categories)
- remove unneeded fDebug checks in front of LogPrint()/qDebug(), as that
  check is done in LogPrintf() when category is != NULL (true for all
  LogPrint() calls
- remove fDebug ONLY in code which is NOT performance-critical
- harmonize addrman category name
- deprecate -debugnet usage, should be used via -debug=net and remove the
  corresponding global
2013-10-30 16:02:09 +01:00
Gavin Andresen e13934c94e Merge pull request #3115 from sipa/walletmain
Interaction cleanups between main and wallet
2013-10-29 18:01:57 -07:00
Pieter Wuille 170e02deaf Generalize the remove-outputs check for fully-prunable transactions.
Instead of explicitly testing for the presence of any output, and
dealing with this case specially, just interpret it as an empty
CCoins.

The case previously caught using the HaveCoins check, is now handled
by the generic outs != outsBlock test.
2013-10-28 15:00:43 +01:00
Matt Corallo b33b9a6fef Fix comparison tool by asking for blocks more aggressively 2013-10-27 02:23:36 -04:00
Pieter Wuille 722fa283d0 Break dependency of init on wallet.
This required some code movement (what was CWalletTx::AcceptToMemoryPool
doing in main?), and adding a few explicit includes that used to be
implicit through init.h.
2013-10-26 14:51:47 +02:00
Pieter Wuille 00588c3fac Use boost signals for callbacks from main to wallet 2013-10-26 14:51:46 +02:00
Pieter Wuille e010af7089 Remove broken PrintWallet functionality 2013-10-26 14:49:47 +02:00
Pieter Wuille fe52346450 Do not treat fFromMe transaction differently when broadcasting 2013-10-26 14:49:47 +02:00
Pieter Wuille a616206865 Give peer time-adjustment data an own lock
Instead of relying on cs_main (defined in a different module) to
prevent concurrent access to it.
2013-10-26 14:43:26 +02:00
Warren Togami 1ce418929a Split MIN_PROTO_VERSION into INIT_PROTO_VERSION and MIN_PEER_PROTO_VERSION
INIT_PROTO_VERSION is the initial version, after a succesful version/verack it is increased to a negotiated version.
MIN_PEER_PROTO_VERSION could be a different value to disconnect from peers older than a specified version.
2013-10-25 23:46:37 -10:00
Gavin Andresen 1f3d3647ff Send multiple inv messages if mempool.size > MAX_INV_SZ
Changes the response to the 'mempool' command so that if
the memory pool has more than MAX_INV_SZ transactions (50,000)
it will respond with multiple 'inv' messages.
2013-10-26 14:14:31 +10:00
Gavin Andresen be484db274 Merge pull request #2738 from jgarzik/op_return
Relay OP_RETURN data TxOut as standard transaction type.
2013-10-21 22:47:24 -07:00
Gavin Andresen 749230d05c Merge pull request #2840 from sipa/nosendlock
Allow SendMessages to run partially without cs_main
2013-10-20 19:06:53 -07:00
Pieter Wuille 9b1200c23b
Merge pull request #3119
db0e8cc Bump Year Number to 2013 (super3)
2013-10-20 22:25:44 +02:00
super3 db0e8ccd90 Bump Year Number to 2013 2013-10-20 15:25:06 -04:00
Gavin Andresen f90b690a0d Merge pull request #2884 from gavinandresen/canonicalsizes2
Reject non-canonically-encoded CompactSize
2013-10-19 23:03:04 -07:00
Gavin Andresen d3b0fa1d82 Merge pull request #3008 from gavinandresen/CENTrule
Two small free transaction policy changes
2013-10-19 23:01:47 -07:00
Gavin Andresen 9e70bff67a Merge pull request #3083 from sipa/chainlocator
CBlockLocator improvements & move to core
2013-10-15 16:31:46 -07:00
Pieter Wuille 7d38af3c49 Push down cs_main locking in ProcessMessage 2013-10-15 22:34:25 +02:00
Pieter Wuille 6055b9101b Allow SendMessages to run partially without cs_main
SendMessages() tries to acquire a cs_main lock now, but this isn't nessecary
for much of its functionality. Move those parts out of the locked section,
so they can always be performed, and we hold cs_main for a shorter time.
2013-10-15 22:34:20 +02:00
Philip Kaufmann 7dea6345e1 replace %zu with %"PRIszu" macro to prevent compiler warnings 2013-10-15 14:50:58 +02:00
Pieter Wuille e4daecda0b Reimplement CBlockLocator's chain-related logic in CChain.
This removes a few unused CBlockLocator methods, and moves the
construction and fork-finding logic to CChain (which can do these
more efficiently, as it has a height-indexable chain available).
It also makes CBlockLocator independent from the validation code.
2013-10-15 11:09:29 +02:00
Gavin Andresen b9beea6e9d Merge pull request #3077 from sipa/chain
Refactor/encapsulate chain globals into a CChain class
2013-10-14 20:39:00 -07:00
Pieter Wuille 9269d0e96e
Merge pull request #2937
971bb3e Added ping time measurement. New RPC "ping" command to request ping. Implemented "pong" message handler. New "pingtime" field in getpeerinfo, to provide results to user. New "pingwait" field, to show pings still in flight, to better see newly lagging peers. (Josh Lehan)
2013-10-13 17:41:28 +02:00
Pieter Wuille 4c6d41b8b6 Refactor/encapsulate chain globals into a CChain class 2013-10-11 23:25:50 +02:00
Philip Kaufmann 5ea66c54fb style-police: fixed badly readable code in ProcessMessage()
- I introduced the problem and fixed it with better readable code
2013-10-07 08:55:04 +02:00
Gavin Andresen 16b3ff66e0 Lower maximum size for free transaction creation
Changes the maximum size of a free transaction that will be created
from 10,000 bytes to 1,000 bytes.

The idea behind this change is to make the free transaction area
available to a greater number of people; with the default 27K-per-block,
just three very-large very-high-priority transactions could fill the space.
2013-10-04 22:05:06 +10:00
Gavin Andresen ea1cd5b47f Remove CENT-output free transaction rule when relaying
Remove the (relay/mempool) rule that all outputs of free transactions
must be greater than 0.01 XBT. Dust spam is now taken care of by making
dusty outputs non-standard.
2013-10-04 22:05:06 +10:00
Josh Lehan 971bb3e901 Added ping time measurement.
New RPC "ping" command to request ping.
Implemented "pong" message handler.
New "pingtime" field in getpeerinfo, to provide results to user.
New "pingwait" field, to show pings still in flight, to better see newly lagging peers.
2013-10-04 01:30:12 -07:00
Philip Kaufmann fbed9c9d63 special case DoS value == 0 in ProcessMessage()
- prevents unneeded log messages, which could make users think something
  bad was happening
2013-10-04 10:12:55 +02:00
Gavin Andresen acb3ebc455 Merge pull request #2947 from gmaxwell/theyre_maturing_faster_these_days
[wallet] Consider generated coins mature at COINBASE_MATURITY+1
2013-10-03 22:52:38 -07:00
Jeff Garzik a79342479f Relay OP_RETURN data TxOut as standard transaction type 2013-10-02 11:49:43 -04:00
Philip Kaufmann 8d750f1d21 internal miner: move 2 globals from main to miner
- moves 2 global variables from main.cpp/h to miner.cpp/h
- also removes 2 unneded includes in miner.cpp, that come from miner.h
  already
2013-09-25 15:48:11 +02:00
Pieter Wuille 99740bab9c Skip unspendable outputs in consistency check 2013-09-24 14:11:20 +02:00
Gavin Andresen ff4e3e63e7 Merge pull request #2949 from gmaxwell/fewer_fee_footguns
[raw] reject insanely high fees by default in sendrawtransaction
2013-09-22 16:44:35 -07:00
Gavin Andresen 881a85a22d Replace printf with LogPrintf / LogPrint 2013-09-18 20:39:25 +10:00
Gregory Maxwell 85311c1ef8 Merge pull request #2982 from gmaxwell/20130908_ccoins_corrupt
Longer term workaround for chainstate corruption from negative versions.
2013-09-10 16:07:34 -07:00
Philip Kaufmann d78900cc1b fix some cosmetic glitches in the codebase
- rename URL into URI in paymentserver where correct
- add some missing Qt-coding-stuff in paymentserver
- change QSpinBox to QLineEdit as base for BitcoinAmountField in .ui files
  (as this is the result when converting the BAF back into base)
- remove some c_str() and replace with QString::fromStdString()
- remove several new-lines
- remove unneeded spaces
- indentation fixes
2013-09-09 12:36:04 +02:00
Gregory Maxwell f8b7aa8625 Longer term workaround for chainstate corruption from negative versions.
This also makes negative transaction versions non-standard.

This avoids an issue triggered in block 256818 where transactions with
negative version numbers were incorrectly serialized into the UTXO set.

On restart nodes detect the inconsistency and refuse to start so long as
a block with these transactions is inside the self-consistency check
window, logging "coin database inconsistencies found". The software
recommends reindexing, but reindexing does not correct the problem.

This should be fixed by changing the chainstate serialization, but
working around it seems harmless for now because the version is not
used by any network rule currently.

A patch free workaround is to start with -checklevel=2 which skips
the consistency checks, but the IsStandard change is important for
miners in order to protect unpatched nodes.
2013-09-09 02:11:11 -07:00
Matt Corallo 55ed3f1475 Don't warn about forks while fIsInitialDownload 2013-09-03 22:22:13 -04:00
Gregory Maxwell 9d14e689c8 [raw] reject insanely high fees by default in sendrawtransaction
There have been several incidents where mainnet experimentation with
 raw transactions  resulted in insane fees.  This is hard to prevent
 in the raw transaction api because the inputs may not be known.
 Since sending doesn't work if the inputs aren't known, we can catch
 it there.

This rejects fees > than 10000 * nMinRelayTxFee or 1 BTC with the
 defaults and can be overridden with a bool at the rpc.
2013-08-28 15:49:51 -07:00
Gregory Maxwell bf3a20a6e8 [wallet] Consider generated coins mature at COINBASE_MATURITY+1
We're not seeing large reorgs that would justify waiting a large
 amount past the rule required maturity, and the extra three
 hours is just a nuisance. Take one more block to at least give
 the 100th block time to propagate.
2013-08-28 10:16:50 -07:00
Pieter Wuille 24e5d7d5ae Fix out-of-bounds check 2013-08-24 23:22:27 +02:00
Gregory Maxwell a7f533a972 Update the bloom state on the real object, not the temporary one.
This resulted in just passing all transactions to filtered wallets
which worked surprisingly well, except where it didn't.
2013-08-20 17:46:07 -07:00
Gregory Maxwell 37c6389c5a Performance optimization for bloom filters.
This reduces a peer's ability to attack network resources by
 using a full bloom filter, but without reducing the usability
 of bloom filters.  It sets a default match everything filter
 for peers and it generalizes a prior optimization to
 cover more cases.
2013-08-20 02:27:26 -07:00
Pieter Wuille 2461aba1ac Mempool consistency check 2013-08-15 23:55:35 +02:00
Pieter Wuille f0784ac470 Fix non-standard disconnected transactions causing mempool orphans 2013-08-15 23:53:55 +02:00
Gavin Andresen 8fa9b5cc45 Merge pull request #2658 from TheBlueMatt/forkalert
Detect any sufficiently long fork and alert the user just like any other alert
2013-08-12 23:33:40 -07:00
Cozz Lovan c7fa1a3586 do not call BuildMerkleTree() unnecessarily twice 2013-08-10 15:27:25 +02:00
Gavin Andresen 8dc206a1e2 Reject non-canonically-encoded sizes
The length of vectors, maps, sets, etc are serialized using
Write/ReadCompactSize -- which, unfortunately, do not use a
unique encoding.

So deserializing and then re-serializing a transaction (for example)
can give you different bits than you started with. That doesn't
cause any problems that we are aware of, but it is exactly the type
of subtle mismatch that can lead to exploits.

With this pull, reading a non-canonical CompactSize throws an
exception, which means nodes will ignore 'tx' or 'block' or
other messages that are not properly encoded.

Please check my logic... but this change is safe with respect to
causing a network split. Old clients that receive
non-canonically-encoded transactions or blocks deserialize
them into CTransaction/CBlock structures in memory, and then
re-serialize them before relaying them to peers.

And please check my logic with respect to causing a blockchain
split: there are no CompactSize fields in the block header, so
the block hash is always canonical. The merkle root in the block
header is computed on a vector<CTransaction>, so
any non-canonical encoding of the transactions in 'tx' or 'block'
messages is erased as they are read into memory by old clients,
and does not affect the block hash. And, as noted above, old
clients re-serialize (with canonical encoding) 'tx' and 'block'
messages before relaying to peers.
2013-08-09 10:01:35 +10:00
Gavin Andresen ddd0e2f616 Merge pull request #2871 from gavinandresen/simplify_maporphan
Simplify storage of orphan transactions, fix CVE-2013-4627
2013-08-06 17:11:48 -07:00
Gavin Andresen 15047f5af0 Merge pull request #2851 from TheBlueMatt/master
Prepare for mempool testing in pull-tester and fix multi-block transaction resurrection
2013-08-05 01:53:17 -07:00
Gavin Andresen 159bc48193 Simplify storage of orphan transactions
Orphan transactions were stored as a CDataStream pointer;
this changes the mapOrphanTransactions data structures to
store orphans as a CTransaction.

This also fixes CVE-2013-4627 by always re-serializing
transactions before relaying them.
2013-08-02 16:10:25 +10:00
Gavin Andresen 8f6f92c72b Revert "Truncate oversize 'tx' messages before relaying/storing."
This reverts commit c40a5aaaf4.
2013-08-02 15:50:04 +10:00
Jeff Garzik d247a5d130 Move internal miner/block creation to separate miner.cpp module.
Public functions referenced elsewhere are added to miner.h.
2013-07-31 09:43:35 -04:00
Jeff Garzik 18946846d5 Minor miner fixes (hey hey it's fun to say)
* Fix UpdateCoins() definition in main.h
* Remove pwalletMain reference from BitcoinMiner(), as it is passed
  a wallet argument.
2013-07-31 08:45:49 -04:00
Gavin Andresen 050d2e953f Remove #define loop from util.h
Replace the loop macro with while (true). The #define caused
problems for Qt.
2013-07-31 14:06:44 +10:00
Matt Corallo 9bf2a4aba2 Fix multi-block reorg transaction resurrection 2013-07-23 18:02:27 +02:00
Matt Corallo d9ace8abe8 Don't use checkpoints and accept nonstd txn on -regtest 2013-07-23 18:02:26 +02:00
Matt Corallo f65e7092a2 Better warning/"alert" messages for large-work forks. 2013-07-22 12:12:45 +02:00
Matt Corallo f89faa2584 Call the -alertnotify script when we see a long or invalid fork. 2013-07-22 12:11:46 +02:00
Matt Corallo b8585384da Detect any sufficiently long fork and add a warning.
Such a fork is defined as being at least 7 blocks long and
having a tip which is within 72 blocks of our best block.
2013-07-22 12:10:57 +02:00
Jeff Garzik d598872726 Merge pull request #2743 from jgarzik/reject-reason
Log reason for non-standard transaction rejection
2013-07-10 08:50:49 -07:00
Pieter Wuille 4ad73c6b08 Merge pull request #2209 from CodeShark/WalletRegistrationLocks
Wallet registration locks in main.cpp + UnregisterAllWallet() function
2013-06-25 16:33:16 -07:00
Jeff Garzik 481d899794 Merge pull request #2792 from sipa/coreimpl
Move core implementations to core.cpp
2013-06-25 11:52:18 -07:00
Peter Todd c40a5aaaf4 Truncate oversize 'tx' messages before relaying/storing.
Fixes a memory exhaustion attack on low-memory peers.
2013-06-25 10:37:50 -04:00
Pieter Wuille f121db58e4 Move core implementations to core.cpp 2013-06-25 10:33:29 +02:00
Eric Lombrozo e5cefb9be1 Added locks on the setpwalletRegistered functions in main.cpp and added an UnregisterAllWallets function. 2013-06-24 09:25:23 -07:00
Eric Lombrozo 2a4d3464fd Pulled AcceptBlock out of CBlock. 2013-06-23 19:59:35 -07:00
Eric Lombrozo 38991ffa8a Pulled CheckBlock out of CBlock. 2013-06-23 19:59:35 -07:00
Eric Lombrozo 1959997afb Pulled AddToBlockIndex out of CBlock. 2013-06-23 19:59:35 -07:00
Eric Lombrozo f3ae51dcce Pulled ConnectBlock out of CBlock. 2013-06-23 19:59:35 -07:00
Eric Lombrozo 5c363ed622 Pulled DisconnectBlock out of CBlock. 2013-06-23 19:59:34 -07:00
Eric Lombrozo 8031399494 Moved ReadBlockFromDisk implementation to main.cpp 2013-06-23 19:59:34 -07:00
Eric Lombrozo 7db120d531 Moved CBlock::ReadFromDisk out of CBlock to functions ReadBlockFromDisk in main.h 2013-06-23 19:59:34 -07:00
Eric Lombrozo 226f821942 Moved WriteBlockToDisk implementation from main.h to main.cpp 2013-06-23 19:59:32 -07:00
Eric Lombrozo a6dba0fdb2 Moved CBlock::WriteToDisk out of CBlock to inline function WriteBlockToDisk in main.h 2013-06-23 19:58:23 -07:00
Jeff Garzik 4be2aba302 Merge pull request #2778 from jgarzik/rpc-verifydb
RPC: add 'verifychain' to verify chain database at runtime
2013-06-22 23:08:13 -07:00
Jeff Garzik 980bfe6ef8 Log reason for non-standard transaction rejection 2013-06-23 02:05:25 -04:00
Pieter Wuille b4a8a326c0 Merge pull request #2660 from TheBlueMatt/gmfrefactor
Refactor fee rules to make them actually readable.
2013-06-22 10:08:57 -07:00
Jeff Garzik f590653377 RPC: add 'verifychain', to verify chain database at runtime 2013-06-19 11:53:02 -04:00
Jeff Garzik 168ba99392 Pass check level, check depth to VerifyDB() 2013-06-19 11:32:49 -04:00
Mike Hearn 0e4b317555 Introduce a CChainParameters singleton class and regtest mode.
The new class is accessed via the Params() method and holds
most things that vary between main, test and regtest networks.
The regtest mode has two purposes, one is to run the
bitcoind/bitcoinj comparison tool which compares two separate
implementations of the Bitcoin protocol looking for divergence.

The other is that when run, you get a local node which can mine
a single block instantly, which is highly convenient for testing
apps during development as there's no need to wait 10 minutes for
a block on the testnet.
2013-06-19 16:28:52 +02:00
Mike Hearn 70e7fba06d Move implementation of some CBlockLocator methods
Move out of main.h to improve compile times and add documentation
for what the methods do.
2013-06-19 15:39:45 +02:00
Matt Corallo 87cce04c17 Refactor fee rules to make them actually readable.
This (nearly) doesn't change fee rules at all:
 * To make it into the fee transaction area, the dPriority comparison
   changed from < to <=
 * We now just ignore transactions > MAX_BLOCK_SIZE/4 instead of
   doing some calculations to require increasingly large fees as
   size increases.
2013-06-14 13:37:43 +02:00
Matt Corallo b1f15b218b Remove broken option to skip input checking for wallet txn. 2013-06-13 22:28:03 +02:00
Eric Lombrozo 501da2503a Using boost::signals2 to message main from net.cpp. 2013-06-05 23:15:20 -07:00
Eric Lombrozo aabdf9e899 Moved UpdateTime out of CBlockHeader and moved CBlockHeader into core. 2013-06-05 23:15:20 -07:00
Eric Lombrozo 05df3fc68d Removed AcceptToMemoryPool method from CTransaction. This method belongs to the mempool instance.
Removed AreInputsStandard from CTransaction, made it a regular function in main.
Moved CTransaction::GetOutputFor to CCoinsViewCache.

Moved GetLegacySigOpCount and GetP2SHSigOpCount out of CTransaction into regular functions in main.

Moved GetValueIn and HaveInputs from CTransaction into CCoinsViewCache.

Moved AllowFree, ClientCheckInputs, CheckInputs, UpdateCoins, and CheckTransaction out of CTransaction and into main.

Moved IsStandard and IsFinal out of CTransaction and put them in main as IsStandardTx and IsFinalTx. Moved GetValueOut out of CTransaction into main. Moved CTxIn, CTxOut, and CTransaction into core.

Added minimum fee parameter to CTxOut::IsDust() temporarily until CTransaction is moved to core.h so that CTxOut needn't know about CTransaction.
2013-06-05 23:15:20 -07:00
Eric Lombrozo 788536f175 Moved CInPoint to core. Removed GetMinFee from CTransaction and made it a regular function in main. 2013-06-05 23:15:19 -07:00
Eric Lombrozo 8926263dde Moved PushGetBlocks to main.cpp to eliminate dependence of net.cpp on CBlockLocator. 2013-06-05 20:36:10 -07:00
Cory Fields 13c84b3bd5 build: add global var for whether or not the gui is enabled 2013-06-04 03:54:14 -04:00
Philip Kaufmann 3260b4c090 remove GetBoolArg() fDefault parameter defaulting to false
- explicitly set the default of all GetBoolArg() calls
- rework getarg_test.cpp and util_tests.cpp to cover this change
- some indentation fixes
- move macdockiconhandler.h include in bitcoin.cpp to the "our headers"
  section
2013-06-01 12:53:57 +02:00
Jeff Garzik d397715661 Merge pull request #2644 from sipa/constfindblock
Make FindBlockByHeight constant-time
2013-05-30 08:06:44 -07:00
Jeff Garzik af93273799 Merge pull request #2657 from gmaxwell/its_after_may15_forever
It's after 2013-05-15 forever now, so remove the code for the May 15 fork
2013-05-30 07:35:44 -07:00
Pieter Wuille 95c7db3dbf More bestblock records in wallets
Write bestblock records in wallets:
* Every 20160 blocks synced, no matter what (before: none during IBD)
* Every 144 blocks after IBD (before: for every block, slow)
* When creating a new wallet
* At shutdown

This should result in far fewer spurious rescans.
2013-05-22 20:59:36 +02:00
Pieter Wuille 2ec349bc42 CreateNewBlock performance improvements 2013-05-21 03:53:32 +02:00
Gregory Maxwell a824121eb8 It's after 2013-05-15 forever now, so remove the code for the May 15 fork. 2013-05-16 13:34:01 -07:00
Pieter Wuille 0fe8010a10 Make FindBlockByHeight constant-time.
Remove the pnext pointer in CBlockIndex, and replace it with a
vBlockIndexByHeight vector (no effect on memory usage). pnext can
now be replaced by vBlockIndexByHeight[nHeight+1], but
FindBlockByHeight becomes constant-time.

This also means the entire mapBlockIndex structure and the block
index entries in it become purely blocktree-related data, and
independent from the currently active chain, potentially allowing
them to be protected by separate mutexes in the future.
2013-05-12 19:52:16 +02:00
Gavin Andresen 33edd0a477 Merge pull request #2577 from gavinandresen/fee_bandaid
Treat dust outputs as non-standard, un-hardcode TX_FEE constants
2013-05-04 10:15:39 -07:00
Gavin Andresen 000dc55181 Un-hardcode TX_FEE constants
Allow setting of MIN_TX_FEE / MIN_RELAY_TX_FEE with
-mintxfee / -mintxrelayfee

Default values are the same (0.0001 BTC).
2013-05-03 10:54:31 -04:00
Gavin Andresen 8de9bb53af Define dust transaction outputs, and make them non-standard 2013-05-03 10:52:09 -04:00
Pieter Wuille 360cfe142c Allow the default key to be unavailable
This solves the issue where no default key can be added after -salvagewallet.
2013-04-25 19:36:10 +02:00
Pieter Wuille 97e7901a3a Do not invoke DoS for non-canonical sigs 2013-04-18 22:49:23 +02:00
Pieter Wuille 20d0810f30 Require strictly-standard encodings in mempool 2013-04-14 00:17:49 +02:00
Pieter Wuille 1657c4bc49 Use a uint256 for bnChainWork
Every block index entry currently requires a separately-allocated
CBigNum. By replacing them with uint256, it's just 32 bytes extra
in CBlockIndex itself.

This should save us a few megabytes in RAM, and less allocation
overhead.
2013-04-12 12:17:28 +02:00
Gavin Andresen f158e363a4 Merge pull request #2478 from sipa/fullhash
Always print full hashes (tx, block, inv)
2013-04-09 10:57:16 -07:00
Pieter Wuille 6ed71b5e4f Make sure we always have a node to do IBD from
This introduces the concept of the 'sync node', which is the one we
asked for missing blocks. In case the sync node goes away, a new one
will be selected.

For now, the heuristic is very simple, but it can easily be extended
later to add better policies.
2013-04-07 19:19:13 +02:00
Pieter Wuille 1c06aa98c6 Always print full hashes (tx, block, inv) 2013-04-07 03:43:55 +02:00
Philip Kaufmann b001c87126 small indentation, space, formatting fixes (no code changes) 2013-04-06 02:29:33 +02:00
Gavin Andresen aaf47eac3a Merge pull request #2423 from TheBlueMatt/limitedmapalreadyaskedfor
Limited mapAlreadyAskedFor
2013-04-03 18:31:35 -07:00
Gavin Andresen a0a437c86a Merge pull request #2357 from gavinandresen/shutdowncleanup
Thread / shutdown cleanup
2013-04-03 18:25:00 -07:00
Gavin Andresen 1c4f02139c Merge pull request #2453 from sipa/txstats
Update transaction statistics
2013-04-03 18:23:50 -07:00
Pieter Wuille 92a129980f Update transaction statistics
As these were not updated when 'backporting' the 225430 checkpoint
into head.

Additionally, also report verification progress in debug.log, and
tweak the sigcheck-verification-speed-factor a bit.
2013-04-04 02:39:44 +02:00
Gavin Andresen b31499ec72 Clean up shutdown process 2013-04-03 19:57:53 -04:00
Gavin Andresen 21eb5adadb Port Thread* methods to boost::thread_group 2013-04-03 19:57:13 -04:00
Gavin Andresen 1b43bf0d3a Rename util.h Sleep --> MilliSleep
Two reasons for this change:
1. Need to always use boost::thread's sleep, even on Windows, so the
sleeps can be interrupted (prior code used Windows' built-in Sleep).

2. I always forgot what units the old Sleep took.
2013-04-03 14:04:21 -04:00
Gavin Andresen c8c2fbe07f Shutdown cleanup prep-work
Create a boost::thread_group object at the qt/bitcoind main-loop level
that will hold pointers to all the main-loop threads.

This will replace the vnThreadsRunning[] array.

For testing, ported the BitcoinMiner threads to use its
own boost::thread_group.
2013-04-03 14:04:21 -04:00
Gavin Andresen d8aae1ce1d Merge pull request #2420 from sipa/globclean
Global cleanups
2013-04-02 10:00:31 -07:00
Matt Corallo eb59c4ca8e Revert "Actually use mapAlreadyAskedFor."
This reverts commit 643160f6e7.

Turns out this commit was useless after a more careful reading of
CNode::AskFor
2013-04-01 11:56:22 -04:00
Pieter Wuille c7f039b674 Process getdata invs separately until send buffer overflows
There exists a per-message-processed send buffer overflow protection,
where processing is halted when the send buffer is larger than the
allowed maximum.

This protection does not apply to individual items, however, and
getdata has the potential for causing large amounts of data to be
sent. In case several hundreds of blocks are requested in one getdata,
the send buffer can easily grow 50 megabytes above the send buffer
limit.

This commit breaks up the processing of getdata requests, remembering
them inside a CNode when too many are requested at once.
2013-03-30 18:14:54 +01:00
Pieter Wuille 41b052ad87 Use per-message send buffer, rather than per connection 2013-03-29 23:56:26 +01:00
Pieter Wuille 967f24590b Some fixes to CNetMessage processing
* Change CNode::vRecvMsg to be a deque instead of a vector (less copying)
* Make sure to acquire cs_vRecvMsg in CNode::CloseSocketDisconnect (as it
  may be called without that lock).
2013-03-29 23:56:26 +01:00
Jeff Garzik 607dbfdeaf P2P: parse network datastream into header/data components in socket thread
Replaces CNode::vRecv buffer with a vector of CNetMessage's.  This simplifies
ProcessMessages() and eliminates several redundant data copies.

Overview:

* socket thread now parses incoming message datastream into
  header/data components, as encapsulated by CNetMessage
* socket thread adds each CNetMessage to a vector inside CNode
* message thread (ProcessMessages) iterates through CNode's CNetMessage vector

Message parsing is made more strict:

* Socket is disconnected, if message larger than MAX_SIZE
  or if CMessageHeader deserialization fails (latter is impossible?).
  Previously, code would simply eat garbage data all day long.
* Socket is disconnected, if we fail to find pchMessageStart.
  We do not search through garbage, to find pchMessageStart.  Each
  message must begin precisely after the last message ends.

ProcessMessages() always processes a complete message, and is more efficient:

* buffer is always precisely sized, using CDataStream::resize(),
  rather than progressively sized in 64k chunks.  More efficient
  for large messages like "block".
* whole-buffer memory copy eliminated (vRecv -> vMsg)
* other buffer-shifting memory copies eliminated (vRecv.insert, vRecv.erase)
2013-03-29 23:56:25 +01:00
Pieter Wuille 3427517d50 Clean up global datastructures at shutdown.
This should make detecting leaks much easier.
2013-03-29 02:24:18 +01:00
Gavin Andresen 402f19b645 Before 15 May, limit created block size to 500K 2013-03-17 21:53:01 -04:00
Gavin Andresen 8c222dca4f CheckBlock rule until 15-May for 10,000 BDB lock compatibility 2013-03-17 21:52:47 -04: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 cc67f1e2b4 Merge pull request #2221 from sipa/perfo
Various performance tweaks to CCoinsView
2013-02-22 09:01:30 -08:00
Gavin Andresen b8f4e42e1b Merge pull request #2229 from sipa/prealloc
Native versions for AllocateFileRange()
2013-02-22 09:00:13 -08: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
Gavin Andresen 8f66aedfaa Merge pull request #2279 from sipa/cvrbip30
Bugfix CValidationResult for BIP30 + add DoS
2013-02-06 12:58:52 -08:00
Pieter Wuille 7cdc37c0a4 Bugfix CValidationResult for BIP30 + add DoS 2013-02-06 16:33:51 +01:00
Rubén Darío Ponticelli e90b831e83 Do not call ResendWalletTransactions when reindexing, importing or on IBD
Calling ResendWalletTransactions when reindexing, importing or on IBD spams
other nodes with our old transactions, because they become unconfirmed.
2013-02-05 18:29:41 -03:00
Gavin Andresen 79892883d7 Merge branch 'reindexgen' of git://github.com/sipa/bitcoin 2013-02-05 10:15:06 -05:00
Gavin Andresen 1d0851eca8 Merge pull request #2273 from gavinandresen/txsize
Make transactions larger than 100K non-standard
2013-02-05 07:12:27 -08:00
Gavin Andresen 41e1a0d766 Make transactions larger than 100K non-standard
Extremely large transactions with lots of inputs can cost the network
almost as much to process as they cost the sender in fees.

We would never create transactions larger than 100K big; this change
makes transactions larger than 100K non-standard, so they are not
relayed/mined by default. This is most important for miners that might
create blocks larger than 250K big, who could be vulnerable to a
make-your-blocks-so-expensive-to-verify-they-get-orphaned attack.
2013-02-05 10:08:35 -05:00
Pieter Wuille 386037615a Make sure the genesis block is present after reindex 2013-02-01 23:29:59 +01:00
Luke Dashjr 8c4e43130b Bugfix: Enable ConnectBestBlock to properly report back validation problems, and ensure orphan processing (when their parents are found) cannot be used to counter-DDoS the node providing the parent
Also fix a minor typo
2013-01-31 03:53:21 +00:00
Pieter Wuille 1eb578796c Drop padding in blk* when finalizing file 2013-01-30 04:55:38 +01:00
Gavin Andresen db3b4ade7b Merge pull request #2224 from sipa/valstate
Improve error handling during validation
2013-01-29 19:37:44 -08:00
Pieter Wuille 421218d304 Deal with LevelDB errors 2013-01-30 04:30:02 +01:00
Gavin Andresen 15ebd4865a Fix two clang3.3 warnings 2013-01-29 22:03:49 -05:00
Pieter Wuille 7851033dd6 Improve dealing with abort conditions 2013-01-30 03:56:45 +01:00
Pieter Wuille 18379c8087 Add disk space checks before flushing CCoins cache 2013-01-30 03:56:45 +01:00
Pieter Wuille 86c82bf9d0 Treat coinbase value violation as DoS 2013-01-30 03:56:44 +01:00
Pieter Wuille ef3988ca36 CValidationState framework 2013-01-30 03:56:44 +01:00
Gavin Andresen f73abdc82d Merge pull request #2223 from gavinandresen/nonfinalnonstandard
Treat non-final transactions as non-standard
2013-01-28 07:56:58 -08:00
Gavin Andresen 6f8730752c Treat non-final transactions as non-standard
At least one service that accepted zero-confirmation transactions
was vulnerable because an attacker could send a transaction
with a lock time far in the future, and then have plenty of time in
which to get a double-spend mined (perhaps from a miner who wasn't
on the network when the first transaction was broadcast).

That is a variation on the "Finney attack". We still don't
recommend anybody accept 0-confirmation transactions as final
payment for anything. This change keeps non-final transactions
from appearing in the wallet, and, assuming most of the network
accepts this change, will prevent them from being relayed until
they are final.
2013-01-26 14:38:40 -05:00
Gavin Andresen 434fa60d75 Merge pull request #2182 from gavinandresen/addressoracle
Remove IsFromMe() check in CTxMemPool::accept()
2013-01-26 11:27:48 -08:00
Pieter Wuille 56869fc07c Check only 288 blocks at startup by default 2013-01-26 18:57:07 +01:00
Pieter Wuille f369d02c51 Various performance tweaks to CCoinsView
* Pass txid's to CCoinsView functions by reference instead of by value
* Add a method to swap CCoins, and use it in some places to avoid a
  allocating copy + destruct.
* Optimize CCoinsViewCache::FetchCoins to do only a single search
  through the backing map.
2013-01-26 18:46:12 +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
Gavin Andresen 9c9f5c1303 Let limitfreerelay=0 reject ALL free transactions 2013-01-23 20:24:10 -05:00
Gavin Andresen 09c69c03f7 Merge pull request #2187 from CodeShark/SyncWithWalletsFix
Bugfix - Moved SyncWithWallets out of ProcessMessage and into CTxMemPool::accept()
2013-01-23 09:29:01 -08:00
Gavin Andresen a337505bd7 Merge pull request #2192 from mikehearn/notfoundmsg
Add a notfound message to getdata.
2013-01-23 06:48:57 -08:00
Gavin Andresen 1a2e45d8d5 Merge pull request #2188 from TheBlueMatt/bloom
Send transactions after a CMerkleBlock when asked for it in an inv.
2013-01-23 06:48:17 -08:00
Mike Hearn 903d146030 Add a notfound message to getdata that is sent if any transactions that aren't in the relayable set are requested. 2013-01-19 18:48:26 +01:00
Pieter Wuille 8301ff5077 Bugfix + simplify special case for genesis 2013-01-19 00:35:17 +01:00
Matt Corallo 192cc910ec Replace 520 constant with MAX_SCRIPT_ELEMENT_SIZE 2013-01-18 13:55:18 -05:00
Matt Corallo 28b80e6065 Send transactions after a CMerkleBlock when asked for it in an inv.
This actually simplifies some SPV code, as they can keep track of
a filtered block and its txn before accepting both in one step.
The previous argument was that SPV nodes should handle the txn the
same as any other free txn and then mark them as connected to a
block when they get the filtered block itself.  However, it now
appears that SPV nodes will need to put in more effort to verify
loose txn than they would to verify txn in blocks, thus making it
more approriate to send the txn after the filtered block.
2013-01-18 12:16:39 -05:00
Eric Lombrozo 35c12d176e Moved SyncWithWallets out of ProcessMessage and into CTxMemPool::accept() so that when adding multiple wallets they will be aware of each other's transactions. 2013-01-18 07:01:05 -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
Matt Corallo c51694eb9b Filter mempool command 2013-01-16 14:34:06 -05:00
Matt Corallo 21aaf255ff Use CPartialMerkleTree for CMerkleBlock transactions. 2013-01-16 14:34:06 -05:00
Pieter Wuille 4bedfa9223 Add CPartialMerkleTree
This adds a compact representation for a subset of a merkle tree's
nodes.
2013-01-16 14:34:06 -05:00
Matt Corallo 4c8fc1a588 Let a node opt out of tx invs before we get a their bloom filter
Note that the default value for fRelayTxes is false, meaning we
now no longer relay tx inv messages before receiving the remote
peer's version message.
2013-01-16 12:48:02 -05:00
Matt Corallo b02ddbedcb Relay CMerkleBlocks when asked for MSG_FILTERED_BLOCK 2013-01-16 12:48:02 -05:00
Matt Corallo 9fb106e757 Add a CMerkleBlock to store merkle branches of filtered txes. 2013-01-16 12:48:02 -05:00
Matt Corallo 269d9c6492 Replace RelayMessage with RelayTransaction. 2013-01-16 12:48:02 -05:00
Matt Corallo 422d122537 Add a filter field in CNode, add filterload+filteradd+filterclear 2013-01-16 12:48:02 -05:00
Gavin Andresen ce99358f4a Remove IsFromMe() check in CTxMemPool::accept()
Fixes issue #2178 : attacker could penny-flood with invalid-signature
transactions to deduce which addresses belonged to your node.

I'm committing this early for code review; I still need to write up
a test plan.

Executive summary of fix: check all transactions received from the network
for penny-flood rate-limiting before adding to the memory pool. But do NOT
ratelimit transactions added to the memory pool:
  - because of blockchain reorgs
  - stored in the wallet and added at startup
  - sent from the GUI or one of the send* RPC commands (CWallet::CommitTransaction)

The limit-free-transactions code really should be a method on CNode, with
counters per-peer. But that is a bigger change for another day.
2013-01-15 09:10:22 -05:00
Gavin Andresen 1b72229797 Merge pull request #2161 from sipa/noclient
Remove fClient
2013-01-14 11:41:19 -08:00
Gregory Maxwell 1f4b80a437 Merge pull request #2145 from sipa/checkcoins
Coin database checks
2013-01-11 06:27:30 -08:00
Pieter Wuille 45a1ec51b1 Merge pull request #2115 from forrestv/getblocktemplate_allfees
Provide fee data for all txs in RPC getblocktemplate response
2013-01-10 13:09:51 -08:00
Pieter Wuille c2b72ba27f Remove fClient
Client (SPV) mode never got implemented entirely, and whatever part was already
working, is likely not been tested (or even executed at all) for the past two
years. This removes it entirely.

If we want an SPV implementation, I think we should first get the block chain
data structures to be encapsulated in a class implementing a standard interface,
and then writing an alternate implementation with SPV semantics.
2013-01-09 22:28:46 +01:00
Pieter Wuille ef0f422519 Remove contention on signature cache during block validation
Since block validation happens in parallel, multiple threads may be
accessing the signature cache simultaneously. To prevent contention:
* Turn the signature cache lock into a shared mutex
* Make reading from the cache only acquire a shared lock
* Let block validations not store their results in the cache
2013-01-08 02:00:59 +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 1d70f4bde8 Remove CheckSig_mode and move logic out of CheckInputs() 2013-01-08 01:49:15 +01:00
Pieter Wuille 2800ce7367 Add CScriptCheck: a closure representing a script check 2013-01-08 01:49:15 +01:00
Pieter Wuille f1136200a6 Move VerifySignature to main 2013-01-08 01:49:14 +01:00
Philip Kaufmann 54413aab13 Bitcoin-Qt: never display own block count > estimated block count
- some users reported it as weird, that the estimated block count could be
  lower than our own nodes block number (which is indeed true and not good)
- this pull adds a new default behaviour, which displays our own block
  number as estimated block number, if own >= est. block count
- the pull raises space for nodes block counts in cPeerBlockCounts to 8 to
  be more accurate
- also removes a reduntant setNumBlocks() call in RPCConsole and moves
  initialisation of numBlocksAtStartup in ClientModel, where it belongs
2013-01-04 17:21:40 +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
Pieter Wuille 8539361e66 Add checksums to undo data
This should be compatible with older code that didn't write checksums.
2013-01-03 15:29:19 +01:00
Pieter Wuille 2cbd71da06 Make DisconnectBlock fault-tolerant 2013-01-03 15:29:19 +01:00
Jeff Garzik 3f964b3c50 Remove 'T' from remaining date/time format strings. 2013-01-01 15:28:28 -05:00
Forrest Voight 03cac0bb8e changed CreateNewBlock to return a CBlockTemplate object, which includes per-tx fee and sigop count data 2012-12-19 16:12:58 -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 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
Gavin Andresen 8b83e2fc2e Merge pull request #2074 from sipa/minor
Two minor inconvenience fixes
2012-12-12 09:10:44 -08:00
Richard Schwab 303b0009dc Change timestamps to use ISO8601 formatting 2012-12-12 16:32:22 +01:00
Pieter Wuille 622da5df6e Merge pull request #2068 from Diapolo/CheckDiskSpace
some CheckDiskSpace() related changes
2012-12-07 13:33:24 -08: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 c8b2e4426b Update the block file counter in database when using -reindex
This problem is like earth (mostly harmless). After/during a
-reindex, it means the statistics about the last block file
reported in debug.log are always of blk00000.dat instead of the
last file. Apart from that, it means a few more database entries
need to be read when finding a file to append to the first time.
2012-12-06 22:04:58 +01:00
Pieter Wuille 89b7019be8 Reconstruct coins/ from scratch when missing. 2012-12-06 17:00:12 +01:00
Pieter Wuille d79775a04d Merge pull request #2057 from Diapolo/FlushBlockFile
FlushBlockFile(): check for valid FILE pointer
2012-12-06 01:35:36 -08:00
Pieter Wuille cd1391ae4d Merge pull request #2056 from sipa/fix_2052
Fixes for obscure mempool-checkpoint interaction
2012-12-05 14:15:17 -08:00
Pieter Wuille 8a28bb6dee Add -benchmark for reporting block processing times 2012-12-05 23:06:01 +01:00
Pieter Wuille a485c1b69e Merge pull request #2063 from Diapolo/CDiskBlockPos
add 2 constructors in CDiskBlockPos to simplify class usage
2012-12-05 14:01:03 -08:00
Philip Kaufmann fa45c26a0e call CheckDiskSpace() before pre-allocating space
- even if we are allowed to fail pre-allocating, it's better to check
  for sufficient space before calling AllocateFileRange() and if we
  are out of disk space return with error()
- the above change allows us to remove the CheckDiskSpace() check
  in CBlock::AcceptBlock()
2012-12-05 14:39:09 +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
Pieter Wuille d33a9218ab Make SetBestChain() atomic
In case a reorganisation fails, the internal state could become
inconsistent (memory only). Previously, a cache per block connect
or disconnect action was used, so blocks could not be applied in
a partial way. Extend this to a cache for the entire reorganisation,
making it atomic entirely. This also simplifies the code a bit.
2012-12-02 01:43:35 +01:00
Philip Kaufmann b19388dd88 FlushBlockFile(): check for valid FILE pointer
- don't call FileCommit() and fclose() if no valid FILE pointer was
  returned by OpenBlockFile()
2012-12-01 11:36:53 +01:00
Pieter Wuille cd7fb7d1de Merge pull request #2033 from sipa/kickconflicts
Bugfix: remove conflicting transactions from memory pool
2012-11-30 17:10:07 -08:00
Pieter Wuille 8259c57321 Only send reorged txn to mempool after checkpoint 2012-12-01 02:09:41 +01:00
Gavin Andresen aaef016a07 Merge pull request #2037 from luke-jr/printpriority
Allow -printpriority without -debug
2012-11-30 16:16:59 -08:00
Pieter Wuille 038784b979 Enable script verification for reorganized mempool tx 2012-12-01 00:45:17 +01:00
Luke Dashjr 2646080e3d Allow -printpriority without -debug 2012-11-26 16:30:54 +00: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
Pieter Wuille 231b399952 Bugfix: remove conflicting transactions from memory pool
When a transaction A is in the memory pool, while a transaction B
(which shares an input with A) gets accepted into a block, A was
kept forever in the memory pool.

This commit adds a CTxMemPool::removeConflicts method, which
removes transactions that conflict with a given transaction, and
all their children.

This results in less transactions in the memory pool, and faster
construction of new blocks.
2012-11-25 11:50:35 +01:00
Pieter Wuille 7818d230a2 Merge pull request #2013 from sipa/blockheader
Split off CBlockHeader from CBlock
2012-11-24 13:54:12 -08:00
Pieter Wuille c07a1a6ee4 Merge pull request #1980 from sipa/noreorgsame
Do not reorganize if new branch has same amount of work
2012-11-22 13:33:03 -08:00
Philip Kaufmann 11406c89fe ConnectBlock(): fix error() format to be unsigned
- I introduced the wrong format macro with my former patch (#2018), this
  needs to be signed not unsigned (thanks Luke-Jr)
2012-11-17 09:57:58 +01:00
Philip Kaufmann 42152c3da9 ensure we use our format macros to avoid compilation warnings
- fixes 2 warnings I observed while compiling on Windows with MinGW
2012-11-16 08:29:47 +01:00
Jeff Garzik 3ef292dc7d Merge pull request #1670 from luke-jr/blksubstr
Use full block hash as unique identifier in debug.log
2012-11-15 18:47:07 -08:00
Jeff Garzik 824e196054 Merge pull request #2005 from Diapolo/fixes_main
some small fixes for main.cpp/.h
2012-11-15 18:20:35 -08:00
Jeff Garzik a0bf93b809 Merge pull request #2012 from luke-jr/invblk_errs
Print error for coinbase-pays-too-much case of ConnectBlock failing
2012-11-15 18:18:55 -08:00
Pieter Wuille e754cf4133 Split off CBlockHeader from CBlock
Cleaner and removes the need for the application-specific flags in
serialize.h.
2012-11-16 00:12:33 +01:00
Pieter Wuille 99d0d0f356 Introduce script verification flags
These flags select features to be enabled/disabled during script
evaluation/checking, instead of several booleans passed along.
Currently these flags are defined:
* SCRIPT_VERIFY_P2SH: enable BIP16-style subscript evaluation
* SCRIPT_VERIFY_STRICTENC: enforce strict adherence to pubkey/sig encoding standards.
2012-11-15 23:00:16 +01:00
Luke Dashjr 4ade04ddbd Print error for coinbase-pays-too-much case of ConnectBlock failing 2012-11-14 19:16:56 +00:00
Luke Dashjr f3a84c3a6b Abstract block hash substr extraction (for debug.log) into BlockHashStr inline 2012-11-13 21:18:32 +00:00
Philip Kaufmann 13e5cce4c3 some small fixes for main.cpp/.h
- remove an unwanted ";" at the end of the ~CCoinsView() destructor
- in FindBlockPos() and FindUndoPos() only call fclose(), is file is open
- fix an error string in the CBlockUndo class
2012-11-11 13:16:42 +01:00
Philip Kaufmann b56585d067 fix some missing indentations in main.cpp for better readability 2012-11-10 14:26:34 +01: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 05d9726805 LoadExternalBlockFile switched to CBufferedFile 2012-11-09 01:06:06 +01:00
Pieter Wuille cd6dc96c4f Do not reorganize if new branch has same amount of work 2012-11-05 21:24:11 +01:00
Pieter Wuille 1c83b0a377 Cache size optimizations 2012-11-04 18:06:25 +01:00
Pieter Wuille 28982cc9dc Remove P2SH transition code: P2SH violations may cause DoS trigger 2012-10-29 00:41:39 +01:00
Pieter Wuille 344620e953 Merge pull request #1904 from laanwj/2012_10_remove_getorder
remove "checkorder" P2P command
2012-10-25 11:41:22 -07:00
Pieter Wuille 66444558a5 Merge pull request #1953 from gmaxwell/createnewblock-race
Fixes a race condition in CreateNewBlock and a future null deref on testnet.
2012-10-25 11:30:51 -07:00
Wladimir J. van der Laan 1f7c5c5a3e Merge pull request #1926 from laanwj/2012_10_maindummybounds
Fix out-of-bounds read in main (issue #1924)
2012-10-25 06:12:10 -07:00
Wladimir J. van der Laan 62e21fb5d0 Show warning when using prerelease version
Implements #1948

- Add macro `CLIENT_VERSION_IS_RELEASE` to clientversion.h
- When running a prerelease (the above macro is `false`):
  - In UI, show an orange warning bar at the top. This will be used for other
    warnings (and alerts) as well, instead of the status bar.
  - For `bitcoind`, show the warning in the "errors" field in `getinfo`
    response.
2012-10-25 07:33:45 +02:00
Wladimir J. van der Laan 4fbad9124e Fix out-of-bounds read noticed by Ricardo Correia
Sizeof() returned the size of a pointer instead of the size of the buffer.
Fixes issue #1924.
2012-10-24 08:26:50 +02:00
Gregory Maxwell faff50d129 Fixes a race condition in CreateNewBlock and a future null deref on testnet.
CreateNewBlock was reading pindexBest at the start before taking the lock
so it was possible to have the the block content not match the prevheader
and this can also trigger a newly added assert in ConnectBlock.

I noticed this during a code review after twobitcoins reported that ab91bf39
(BIP30 for all blocks) could cause a null dereference on a modified node
that mined during the IBD, or on testnet when it reached heights 91842 and
91880 due to CreateNewBlock calling ConnectBlock with pindex->phashBlock NULL.
2012-10-24 02:13:03 -04:00
Pieter Wuille 4afc0b5411 Bugfix: actually use CCoinsViewMemPool 2012-10-23 01:43:33 +02:00
Pieter Wuille c2ed184f98 Added some comments
Some clarifications after a code review by Mike Hearn.
2012-10-23 00:27:17 +02:00
Pieter Wuille 1e64c2d585 Bugfix: off-by-one in priority calculation 2012-10-23 00:23:39 +02:00
Pieter Wuille 9e957fb3b1 Bugfix: add missing fee check 2012-10-23 00:23:39 +02:00
Pieter Wuille 56424040a4 Bugfix: off-by-one error in coinbase maturity check 2012-10-23 00:23:39 +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
Philip Kaufmann 039bcbf12d remove init messages from ThreadImport()
- remove uiInterface.InitMessage() calls from ThreadImport(), as Qt
  doesn't like them getting called out of it's main thread and because the
  thread will continue to run after the GUI was loaded
2012-10-21 21:16:52 +02:00
Pieter Wuille beeb57610c Add gettxout and gettxoutsetinfo RPCs 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 44d40f26dc Flush and sync block data 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 13c51f20f6 Direct CCoins references
To prevent excessive copying of CCoins in and out of the CCoinsView
implementations, introduce a GetCoins() function in CCoinsViewCache
with returns a direct reference. The block validation and connection
logic is updated to require caching CCoinsViews, and exploits the
GetCoins() function heavily.
2012-10-20 23:08:57 +02:00
Pieter Wuille 64dd46fd05 Transaction hash caching
Use CBlock's vMerkleTree to cache transaction hashes, and pass them
along as argument in more function calls. During initial block download,
this results in every transaction's hash to be only computed once.
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 bba89aa82a Pre-allocate block and undo files in chunks
Introduce a AllocateFileRange() function in util, which wipes or
at least allocates a given range of a file. It can be overriden
by more efficient OS-dependent versions if necessary.

Block and undo files are now allocated in chunks of 16 and 1 MiB,
respectively.
2012-10-20 23:08:57 +02:00
Pieter Wuille 5382bcf8cd Multiple blocks per file
Change the block storage layer again, this time with multiple files
per block, but tracked by txindex.dat database entries. The file
format is exactly the same as the earlier blk00001.dat, but with
smaller files (128 MiB for now).

The database entries track how many bytes each block file already
uses, how many blocks are in it, which range of heights is present
and which range of dates.
2012-10-20 23:08:57 +02:00
Pieter Wuille 8adf48dc9b Preliminary undo file creation
Create files (one per block) with undo information for the transactions
in it.
2012-10-20 23:08:57 +02:00
Pieter Wuille 630fd8dcb6 One file per block
Refactor of the block storage code, which now stores one file per block.
This will allow easier pruning, as blocks can be removed individually.
2012-10-20 23:08:57 +02:00
Pieter Wuille 0fa593d0fb Compact serialization for amounts
Special serializer/deserializer for amount values. It is optimized for
values which have few non-zero digits in decimal representation. Most
amounts currently in the txout set take only 1 or 2 bytes to
represent.
2012-10-20 23:08:56 +02:00
Jeff Garzik 38ac953b9d Merge pull request #1880 from sipa/threadimport
Move external block import to separate thread
2012-10-20 13:36:36 -07:00
Jeff Garzik dee0ee2ac9 Merge pull request #1742 from sipa/canonical
Check for canonical public keys and signatures
2012-10-20 10:56:04 -07:00
Pieter Wuille 66b02c93e6 Move external block import to separate thread 2012-10-20 01:54:10 +02:00
Jeff Garzik de2b9459bd Merge pull request #1834 from jgarzik/kickblocks
P2P: Do not request blocks from peers with fewer blocks than us
2012-10-08 15:15:58 -07: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
Wladimir J. van der Laan 529a4d4824 remove "checkorder" and "reply" P2P commands
These command are a leftover from send-to-IP transactions, which have been
removed a long time ago.
Also removes CNode::mapRequests and CNode::PushRequests, as these were
only used for the mentioned commands.
2012-10-03 20:09:33 +02:00
Philip Kaufmann d210f4f5b8 fix -Wformat warnings all over the source 2012-10-01 19:45:42 +02: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 93dd68e924 P2P: Do not request blocks from peers with fewer blocks than us
If the remote node has a shorter chain, do not waste our
special getblocks request on them.
2012-09-24 13:26:09 -04:00
Pieter Wuille 58bc86e37f Check for canonical public keys and signatures
Only enabled inside tests for now.
2012-09-21 01:24:25 +02:00
Jeff Garzik b1d3e95a0a When rejected TX relay due to lack of fees, log full txid 2012-09-18 15:24:31 -04:00
Jeff Garzik f8c449b5c8 Merge pull request #1812 from jgarzik/misc-07
Two minor generic cleanups done during OP_DROP hacking
2012-09-18 09:14:53 -07:00
Gregory Maxwell ab91bf39b7 Apply BIP30 checks to all blocks except the two historic violations.
Matt pointed out some time ago that there existed a minor DOS
attack where a node in its initial block download could be wedged
by an overwrite attack in a fork created between checkpoints before
a time where BIP30 was enforced. Now that the BIP30 timestamp
is irreversibly past the check can be more aggressive and apply to
all blocks except the two historic violations.
2012-09-09 20:11:04 -04:00
Jeff Garzik 17f8d6e400 Improve debug logging, for mempool TXs that do not include sufficient fees 2012-09-09 17:05:26 -04:00
Jeff Garzik 76970091f1 Cosmetic: move CTransaction::GetMinFee out of header file 2012-09-09 17:01:18 -04:00
Gavin Andresen 91c218a1cb Merge branch 'testnet_alert' of git://github.com/gavinandresen/bitcoin-git 2012-09-05 11:38:38 -04:00
Philip Kaufmann 8d367c7e66 fix signed/unsigned usage in BlockFilePath() 2012-09-05 08:34:41 +02:00
Jeff Garzik 42613c97d5 Add block file naming helper, BlockFilePath() 2012-09-04 21:40:26 -04:00
Jeff Garzik bec02998b4 Merge pull request #1779 from xanatos/patch-15
Useless vector declaration
2012-09-04 08:59:05 -07:00
xanatos 89fbd1f11c Useless vector declaration
The vector isn't referenced in the small code block it's declared. I don't see any "useful" side effect in its declaration.
2012-09-03 17:53:27 +03: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
Gavin Andresen f35c6c4fb9 Refactor: move alert code from main to alert.cpp/h 2012-08-28 17:04:54 -04:00
Gavin Andresen ea2fda46c3 Special-case the last alert for alert-key-compromised case
Hard-code a special nId=max int alert, to be broadcast if the
alert key is ever compromised. It applies to all versions, never
expires, cancels all previous alerts, and has a fixed message:
   URGENT: Alert key compromised, upgrade required

Variations are not allowed (ignored), so an attacker with
the private key cannot broadcast empty-message nId=max alerts.
2012-08-27 10:22:57 -04:00
Gavin Andresen d5a52d9b3e Alert system DoS prevention
This fixes two alert system vulnerabilities found by
Sergio Lerner; you could send peers unlimited numbers
of invalid alert message to try to either fill up their
debug.log with messages and/or keep their CPU busy
checking signatures.

Fixed by disconnecting/banning peers if they send 10 or more
bad (invalid/expired/cancelled) alerts.
2012-08-26 17:08:18 -04:00
Pieter Wuille 65ce215641 Make 0-value outputs non-standard 2012-08-24 12:15:12 +02:00
Gregory Maxwell bdab0cf58c Avoid leaving return types or function attributes on their own lines. 2012-08-24 02:48:19 -04:00
Pieter Wuille 5c88e3c108 Do not accept orphan blocks in -loadblock mode 2012-08-21 19:18:53 +02:00
Gavin Andresen d18f2fd9d6 Reject block.nVersion<=1 blocks if network has upgraded to version=2
If 950 of the last 1,000 blocks are nVersion=2, reject nVersion=1
(or zero, but no bitcoin release has created block.nVersion=0) blocks
-- 75 of last 100 on testnet3.

This rule is being put in place now so that we don't have to go
through another "express support" process to get what we really
want, which is for every single new block to include the block height
in the coinbase.
2012-08-20 10:46:07 -04:00
Gavin Andresen de237cbfa4 Block height in coinbase as a new block rule
"Version 2" blocks are blocks that have nVersion=2 and
have the block height as the first item in their coinbase.
Block-height-in-the-coinbase is strictly enforced when
version=2 blocks are a supermajority in the block chain
(750 of the last 1,000 blocks on main net, 51 of 100 for
testnet). This does not affect old clients/miners at all,
which will continue producing nVersion=1 blocks, and
which will continue to be valid.
2012-08-20 10:46:07 -04:00
Jeff Garzik b3a570d158 Merge pull request #1641 from jgarzik/mempool
Add 'mempool' P2P command, and extend 'getdata' behavior
2012-08-20 07:21:34 -07:00
Jeff Garzik dabb95b892 Merge pull request #1678 from Diapolo/LoadExternalBlockFile_add_timer
log how long LoadExternalBlockFile() takes in ms (Benchmark)
2012-08-17 08:45:11 -07:00
Philip Kaufmann 1e7027b41e fix a compiler sign warning in OpenBlockFile() 2012-08-17 10:35:51 +02:00
Philip Kaufmann 746f502a79 log how long LoadExternalBlockFile() takes in ms (Benchmark) 2012-08-17 00:14:40 +02:00
Gregory Maxwell 8ce7915aad Merge pull request #1612 from luke-jr/opti_getblkhash
Optimize JSON-RPC getblockhash
2012-08-01 11:49:26 -07:00
Luke Dashjr 1be064190e Optimize JSON-RPC getblockhash
- If the height is in the first half, start at the genesis block and go up, rather than at the top
- Cache the last lookup and use it as a reference point if it's close to the next request, to make linear lookups always fast
2012-08-01 18:23:30 +00: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 05a85b2b38 Add 'mempool' P2P command, and extend 'getdata' behavior
to permit downloading of mempool transactions from the remote peer.
2012-07-31 17:42:35 -04:00
Gregory Maxwell a9d811a976 Switch testnet3's message bytes to avoid connecting to old nodes.
The new bytes are based on "11" to appeal to Gavin's 11 fetish.

This breaks existing testnet3 nodes as the blockchain files
are also versioned.  To upgrade a node delete everything
except wallet.dat from your .bitcoin/testnet3 folder.
2012-07-26 17:50:23 -04:00
Gavin Andresen e0e54740b1 Handle should-never-happen case of orphan in mempool 2012-07-26 15:29:59 -04: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
Gavin Andresen 29c8fb0d93 Merge branch 'checknewblock' of git://github.com/luke-jr/bitcoin 2012-07-26 13:55:27 -04:00
Rune K. Svendsen 5f2e4b0565 Let the comment in GetBlockValue() reflect the uncertainty about the time interval between subsidy reductions 2012-07-18 09:37:05 +02:00
Giel van Schijndel 9f46ab62b1 Fix thread names after review
* Fix wrong thread name for wallet *relocking* thread
  - Was named the unlocking thread
 * Use consistent naming

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-07-17 01:50:35 +02: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
Luke Dashjr 639b61d78e Tests for CreateNewBlock 2012-07-12 16:35:34 +00:00
Luke Dashjr fbf99a9cdc Merge branch 'checknewblock_0.6.0' into checknewblock
Conflicts:
	src/main.cpp
2012-07-11 04:24:58 +00:00
Gavin Andresen 2a919e396d Warn if blockchain majority doesn't match CBlock::CURRENT_VERSION
This adds a warning "this version is obsolete, upgrade required" if
more than 50 of the previous 100 blocks in the blockchain are
a new version.
2012-07-06 11:37:01 -04:00
Gavin Andresen dae3e10a5a Treat non-version-1 transactions as non-standard
Adds CBlock::CURRENT_VERSION and CTransaction::CURRENT_VERSION
constants, and makes non-CURRENT_VERSION transactions nonstandard.
This will help make future upgrades smoother.
2012-07-06 11:37:01 -04:00
Jeff Garzik 6e3a1a3742 Merge pull request #1304 from rebroad/ShowBlockTimestamp
Show block timestamp
2012-07-05 15:28:42 -07:00
Jeff Garzik f77654a0e9 CTxMemPool: eliminate redundant lock, GetHash() call
::addUnchecked()'s only caller already takes the necessary lock,
and has already calculated the TX's hash.
2012-07-04 01:12:44 -04:00
Matt Corallo 96929a5515 Remove duplicate GetHash() in ConnectBlock 2012-07-04 00:04:57 -04:00
Jeff Garzik e75acc006e Merge pull request #1511 from jgarzik/quieten2
Quieten 'getdata' P2P message output
2012-06-27 09:06:59 -07:00
Pieter Wuille abbb9a829c Merge pull request #1347 from rebroad/FixAlreadyAskedFor
mapAlreadyAskedFor gets additions when AlreadyHave()
2012-06-27 08:06:57 -07:00
Matt Corallo 9d6cd04b3b Stop processing messages on full send buffer and dont disconnect.
Also decrease default send/receive buffer sizes from 10 to 5 mb
as this patch makes it easy for a node to fill both instead of
only send.
2012-06-27 15:31:34 +02:00
Gregory Maxwell 817ee0d826 Merge pull request #1174 from sipa/torhs
Tor hidden service support
2012-06-23 19:21:13 -07:00
Gregory Maxwell 0ae2ac5431 Merge pull request #1503 from gmaxwell/testnet_tweaks
Remove some rule differences which aren't needed with testnet3.
2012-06-23 19:02:55 -07:00
Jeff Garzik 983e4bdef0 Quieten 'getdata' P2P message output
Output one message per getdata, not one message per 'inv' entry.
2012-06-23 21:38:33 -04:00