Commit graph

167 commits

Author SHA1 Message Date
Pieter Wuille ed6d0b5f85 Remove headers.h 2012-04-17 20:00:55 +02:00
Gavin Andresen b97d54355e Merge pull request #1106 from jgarzik/sign-compare
Fix many sign-comparison warnings found in bitcoin codebase
2012-04-17 10:55:56 -07:00
Jeff Garzik ce8c93498a main.cpp: replace tabs with spaces
Sometimes they sneak in through the 'vi' door
2012-04-17 12:31:51 -04:00
Jeff Garzik 8bff8ac079 AlreadyHave(): only hold lock during mapTransactions access 2012-04-17 12:30:00 -04:00
Jeff Garzik dd21ce5f1b Merge pull request #1094 from jgarzik/already-have-locking
Locking fix for AlreadyHave()
2012-04-17 09:23:49 -07:00
Jeff Garzik 865a0c1674 Merge pull request #1081 from jgarzik/pong
BIP 0031: pong message
2012-04-17 08:51:17 -07:00
Jeff Garzik c376ac359e Fix loop index var types, fixing many minor sign comparison warnings
foo.size() typically returns an unsigned integral type; make loop variables
match those types' signedness.
2012-04-15 16:52:09 -04:00
Wladimir J. van der Laan da7bbd9dfd fix warnings: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses] 2012-04-15 13:40:14 +02:00
Jeff Garzik 8deb9822e4 Locking fix for AlreadyHave()
Access to mapTransactions[] must be guarded by cs_mapTransactions lock.

Also, reformat long lines to make the switch statement more readable.
2012-04-13 18:24:55 -04:00
Jeff Garzik 9925d34a49 Database micro-optimization for "tx" network message
Open database once per "tx" message, rather than multiple times,
in the case of orphan transaction presence.

As a side effect, a now-unused CTransaction::AcceptToMemoryPool()
variant is removed.
2012-04-13 17:48:15 -04:00
Jeff Garzik 8b09cd3a4d Replace several network protocol version numbers with named constants
stored in version.h.

Also, a minor CAddress code reformat while we're in there, fixing
some incorrect indentation.
2012-04-12 20:07:49 -04:00
Jeff Garzik 460b66b14b Remove obsolete Win32 AffinityBugWorkaround()
Reference miner exists for testnet-in-a-box type situations, and as a
reference.  We don't care enough about highly optimized internal
mining to keep workarounds like this.
2012-04-12 13:24:00 -04:00
Jeff Garzik 93e447b631 BIP 0031: pong message
Add a pong message that is sent in reply to a ping. It echoes back a nonce
field that is now added to the ping message. Send a nonce of zero in ping
messages.

Original author: Mike Hearn @ Google

Modified Mike's change to introduce a mild form of protocol documentation in
version.h.
2012-04-12 12:11:56 -04:00
Pieter Wuille ee12c3d60c Use filesystem::path instead of manual string tinkering
Where possible, use boost::filesystem::path instead of std::string or
char* for filenames. This avoids a lot of manual string tinkering, in
favor of path::operator/.

GetDataDir is also reworked significantly, it now only keeps two cached
directory names (the network-specific data dir, and the root data dir),
which are decided through a parameter instead of pre-initialized global
variables.

Finally, remove the "upgrade from 0.1.5" case where a debug.log in the
current directory has to be removed.
2012-04-11 22:30:23 +02:00
Pieter Wuille 702764f53b Merge pull request #1054 from sipa/buildinfo
Build identification strings
2012-04-10 13:31:12 -07:00
Pieter Wuille a20c0d0f67 Build identification strings
All client version information is moved to version.cpp, which optionally
(-DHAVE_BUILD_INFO) includes build.h. build.h is automatically generated
on supporting platforms via contrib/genbuild.sh, using git describe.

The git export-subst attribute is used to put the commit id statically
in version.cpp inside generated archives, and this value is used if no
build.h is present.

The gitian descriptors are modified to use git archive instead of a
copy, to create the src/ directory in the output. This way,
src/src/version.cpp will contain the static commit id. To prevent
gitian builds from getting the "-dirty" marker in their git-describe
generated identifiers, no touching of files or running sed on the
makefile is performed anymore. This does not seem to influence
determinism.
2012-04-10 18:16:53 +02:00
Pieter Wuille f8dcd5ca6f Use scoped locks instead of CRITICAL_BLOCK 2012-04-09 01:59:46 +02:00
Wladimir J. van der Laan 7cfbe1fee4 qtui.h/noui.h interface cleanup
- rename wxMessageBox, remove redundant arguments to noui/qtui calls
- also, add flag to force blocking, modal dialog box for disk space warning etc
- clarify function naming
- no more special MessageBox needed from AppInit2, as window object is created before calling AppInit2
2012-04-04 09:37:25 +02:00
Wladimir J. van der Laan 1a3f0da922 support RPC stop and encryptwallet with UI 2012-04-04 09:35:01 +02:00
Wladimir J. van der Laan f0b5e9e116 remove unused CalledSetStatusBar and UIThreadCall notifications 2012-04-04 09:35:01 +02:00
Gavin Andresen 85ea8b4f43 Merge pull request #951 from TheBlueMatt/headerslimit
Limit getheaders to a hard 2000.
2012-04-02 11:22:11 -07:00
Gavin Andresen a6b4a11385 Merge branch 'addrman' of https://github.com/sipa/bitcoin 2012-03-22 09:19:01 -04:00
Gavin Andresen 8f188ece3c Remove -bip16 and -paytoscripthashtime command-line arguments 2012-03-21 15:45:58 -04:00
Gavin Andresen b2fe3a5ca6 Merge pull request #948 from sipa/unstuck
Prevent stuck block download in large reorganisations
2012-03-21 12:16:28 -07:00
Pieter Wuille a1a0469f91 More debug output for failed reorganizations 2012-03-21 13:15:27 +01:00
Pieter Wuille 0aa89c08ff Prevent stuck block download in large reorganisations
In cases of very large reorganisations (hundreds of blocks), a situation
may appear where an 'inv' is sent as response to a 'getblocks', but the
last block mentioned in the inv is already known to the receiver node.
However, the supplying node uses a request for this last block as a
trigger to send the rest of the inv blocks. If it never comes, the block
chain download is stuck.

This commit makes the receiver node always request the last inv'ed block,
even if it is already known, to prevent this problem.
2012-03-21 05:09:02 +01:00
Gavin Andresen eae82d8ee5 Use last checkpoint instead of hard-coded 140,700. Fixes #913. 2012-03-20 13:45:45 -04:00
Pieter Wuille 9aa459b294 assertion in CBlock::SetBestChainInner was too strong 2012-03-20 16:41:36 +01:00
Matt Corallo ecf07f2729 Limit getheaders to a hard 2000.
Previously getheaders would return any number of headers up to
2000 + the distance the locator parameter was back (which is up to
~ the number of items in the locator ^ 2).

The only client I was able to find which actually handles the headers
message is BitcoinJ, and it clearly expects no more than 2000 headers
See:
http://code.google.com/p/bitcoinj/source/browse/core/src/main/java/com/google/bitcoin/core/HeadersMessage.java#35

Additionally, the wiki clearly states that getheaders will only ever
return 2000 headers: https://en.bitcoin.it/wiki/Network#Messages
2012-03-19 00:13:15 -04:00
Pieter Wuille d68dcf741e Limit the impact of reorganisations on the database
Sometimes a new block arrives in a new chain that was already the
best valid one, but wasn't marked that way. This happens for example
when network rules change to recover after a fork.

In this case, it is not necessary to do the entire reorganisation
inside a single db commit. These can become huge, and exceed the
objects/lockers limits in bdb. This patch limits the blocks the
actual reorganisation is applied to, and adds the next blocks
afterwards in separate db transactions.
2012-03-12 20:31:56 +01:00
Pieter Wuille a206b0ea12 Do not allow overwriting unspent transactions (BIP 30)
Introduce the following network rule:
 * a block is not valid if it contains a transaction whose hash
   already exists in the block chain, unless all that transaction's
   outputs were already spent before said block.

Warning: this is effectively a network rule change, with potential
risk for forking the block chain. Leaving this unfixed carries the
same risk however, for attackers that can cause a reorganisation
in part of the network.

Thanks to Russell O'Connor and Ben Reeves.
2012-03-03 18:26:36 +01:00
Gavin Andresen 142e604184 DoS fix for mapOrphanTransactions 2012-02-29 11:46:46 -05:00
Michael Ford 27adfb2e0c "February" 2012-02-28 20:31:56 +08:00
Gavin Andresen 21503e4556 Merge branch 'nodosbip16' of https://github.com/sipa/bitcoin 2012-02-27 15:47:27 -05:00
Gavin Andresen 972060ce0e bitcoind changes to stop storing settings in wallet.dat. 2012-02-26 23:21:33 +01:00
Pieter Wuille db9f2e0117 Do not invoke anti-DoS system for invalid BIP16 transactions
Doing so would allow an attack on old nodes, which would relay a
standard transaction spending a BIP16 output in an invalid way,
until reaching a new node, which will disconnect their peer.

Reported by makomk on IRC.
2012-02-25 19:05:50 +01:00
Pieter Wuille 5fee401fe1 CAddrMan: stochastic address manager
Design goals:
 * Only keep a limited number of addresses around, so that addr.dat does not grow without bound.
 * Keep the address tables in-memory, and occasionally write the table to addr.dat.
 * Make sure no (localized) attacker can fill the entire table with his nodes/addresses.

See comments in addrman.h for more detailed information.
2012-02-24 13:41:04 +01:00
Gavin Andresen 6fe8c45375 Merge branch 'fixnullpfrom' of https://github.com/sipa/bitcoin 2012-02-22 11:25:08 -05:00
Gavin Andresen e7e6ae2104 Merge branch 'postfeb20' of https://github.com/sipa/bitcoin 2012-02-22 11:06:44 -05:00
Gavin Andresen 8c7358e1dd Merge branch 'reorginfo' of https://github.com/sipa/bitcoin 2012-02-22 11:03:19 -05:00
Luke Dashjr c170d03e03 Bugfix: Instead of reporting "bitcoin-qt" for both bitcoind and Bitcoin-Qt, report "Satoshi" which is at least correct 2012-02-22 10:36:19 -05:00
Pieter Wuille 18c0fa97d0 Post-feb20 simplifications
Now the entire network upgraded to (initial) protocol version 209,
crtainl simplifications in the source code are possible.
2012-02-21 20:46:39 +01:00
Pieter Wuille 73aa0421a7 ProcessBlock is sometimes called with pfrom==NULL 2012-02-20 22:35:08 +01:00
Pieter Wuille ceaa13eff2 Report number of (dis)connected blocks in reorganization
Also report old and new best, and fork point.
2012-02-19 20:06:04 +01:00
Gavin Andresen 0a6b081cca Merge branch 'testnetmining' of github.com:gavinandresen/bitcoin-git 2012-02-17 13:48:01 -05:00
Gavin Andresen 0f8cb5db73 Fix issue #848 : broken mining on testnet 2012-02-16 11:37:54 -05:00
Pieter Wuille c59881eaee Symbolic names for threads
Introduce an enum threadId, and use symbolic indices when accessing
vnThreadsRunning.
2012-02-16 12:43:06 +01:00
Chris Moore 74f28bf1fd Fix #794. Only remove transactions from memory pool when they're actually in the memory pool. 2012-02-09 05:21:41 -08:00
Gavin Andresen 882164196e Update all copyrights to 2012 2012-02-07 11:28:30 -05:00
Gavin Andresen 0b452dff5e Merge branch 'standardScriptSigs' of github.com:gavinandresen/bitcoin-git 2012-02-07 09:04:56 -05:00