Commit graph

891 commits

Author SHA1 Message Date
Wladimir J. van der Laan c362c57568
Merge pull request #4798
d920f7d Move g_signals.SetBestChain(..) below SyncWithWallets (Cozz Lovan)
2014-09-15 10:32:59 +02:00
jtimon 6dcfda2dc4 Don't pass nHashType to EvalScript nor CheckSig 2014-09-12 20:04:31 +02:00
jtimon 2b23a87599 Don't pass nHashType to VerifyScript 2014-09-12 20:04:31 +02:00
jtimon ce3649fb61 Remove CScriptCheck::nHashType (was always 0) 2014-09-12 20:03:03 +02:00
jtimon 358562b651 Remove unused function main:VerifySignature 2014-09-12 20:03:03 +02:00
Pieter Wuille efad808aae Avoid reject message feedback loops 2014-09-12 17:50:31 +02:00
Gavin Andresen aa3c697e90
Store fewer orphan tx by default, add -maxorphantx option
There is no reason to store thousands of orphan transactions;
normally an orphan's parents will either be broadcast or
mined reasonably quickly.

This pull drops the maximum number of orphans from 10,000 down
to 100, and adds a command-line option (-maxorphantx) that is
just like -maxorphanblocks to override the default.
2014-09-10 14:09:40 -04:00
Gavin Andresen c74332c678
Stricter handling of orphan transactions
Prevent denial-of-service attacks by banning
peers that send us invalid orphan transactions
and only storing orphan transactions given to
us by a peer while the peer is connected.
2014-09-10 14:09:40 -04:00
Suhas Daftuar ec7eb0fa80 When reindexing check for file before trying to open (refactored) 2014-09-10 13:51:53 -04:00
Gavin Andresen def2fdb4b9
Fix crashing bug caused by orphan(s) with duplicate prevout.hash 2014-09-10 16:53:54 +02:00
Wladimir J. van der Laan d6af9856b0
Merge pull request #4878
540ac45 Avoid returning many "inv" orphans (Jeff Garzik)
d4168c8 Limit CNode::mapAskFor (Wladimir J. van der Laan)
2014-09-10 16:52:57 +02:00
Pieter Wuille f7cdcb80ab
Merge pull request #4822
629d75f Combine CCoinsViewCache's HaveCoins and const GetCoins into AccessCoins. (Pieter Wuille)
2014-09-10 01:44:30 +02:00
Pieter Wuille 1575c5171f
Merge pull request #4868
2c2cc5d Remove some unnecessary c_strs() in logging and the GUI (Philip Kaufmann)
f7d0a86 netbase: Use .data() instead of .c_str() on binary string (Wladimir J. van der Laan)
2014-09-09 16:43:06 +02:00
Philip Kaufmann 2c2cc5dac1
Remove some unnecessary c_strs() in logging and the GUI
Includes `core: remove unneeded c_str() / Qt: replace c_str() with Qt code`
by P. Kaufmann.
2014-09-09 11:31:17 +02:00
Jeff Garzik 540ac4514d Avoid returning many "inv" orphans 2014-09-09 09:26:52 +02:00
jtimon e8b5f0d549 Move CBlockIndex, CChain and related code out of main 2014-09-08 22:17:19 +02:00
jtimon 6db83db3eb Decouple CChain from mapBlockIndex 2014-09-08 22:14:24 +02:00
Wladimir J. van der Laan 89d91f6aa7 Avoid repeated lookups in mapOrphanTransactions and mapOrphanTransactionsByPrev 2014-09-08 17:38:43 +02:00
R E Broadley 346193bd93 Cleanup messy error messages 2014-09-06 14:18:32 +07:00
Pieter Wuille 145d5be896 Introduce BlockMap type for mapBlockIndex 2014-09-04 02:04:51 +02:00
Pieter Wuille a0dbe433bd checkpoints.cpp depends on main, it can use mapBlockIndex directly 2014-09-04 02:01:10 +02:00
Pieter Wuille 629d75faac Combine CCoinsViewCache's HaveCoins and const GetCoins into AccessCoins.
The efficient version of CCoinsViewCache::GetCoins only works for known-to-exist
cache entries, requiring a separate HaveCoins call beforehand. This is
inefficient as both perform a hashtable lookup.

Replace the non-mutable GetCoins with AccessCoins, which returns a potentially-NULL
pointer. This also decreases the overloading of GetCoins.

Also replace some copying (inefficient) GetCoins calls with equivalent AccessCoins,
decreasing the copying.
2014-09-03 14:24:52 +02:00
Wladimir J. van der Laan 93f97aab62
Merge pull request #4768
2e28031 Perform CVerifyDB on pcoinsdbview instead of pcoinsTip (Wladimir J. van der Laan)
2014-09-01 09:42:10 +02:00
Cozz Lovan d920f7dcf8 Move g_signals.SetBestChain(..) below SyncWithWallets 2014-08-31 16:17:39 +02:00
Jeff Garzik 135a43df7b
Merge pull request #4778 2014-08-29 20:22:06 -04:00
Jeff Garzik 309aa76d27
Merge pull request #4599 2014-08-29 15:23:13 -04:00
Wladimir J. van der Laan 0101483f46
Move CMerkleTx to wallet.cpp/h
It is only used by the wallet so it has no place in main.
2014-08-29 17:26:01 +02:00
Pieter Wuille d1062e32fa
Merge pull request #4377
654871d replace ComputeMinWork with CheckMinWork (jtimon)
b343c1a Move CBlockIndex::GetBlockWork() to pow::GetProofIncrement(nBits) (jtimon)
c2c02f3 Move UpdateTime to pow (jtimon)
2014-08-27 22:39:28 +02:00
Pieter Wuille cd3d80be67
Merge pull request #4764
92bb6f2 Bypass reloading blocks from disk (Pieter Wuille)
2014-08-27 22:21:33 +02:00
Wladimir J. van der Laan 70352e11c0
Revert "Add a getutxos command to the p2p protocol. It allows querying of the UTXO set"
This reverts commit da2ec100f3.
2014-08-27 18:04:29 +02:00
Wladimir J. van der Laan 2e280311b8
Perform CVerifyDB on pcoinsdbview instead of pcoinsTip
Bypassing the main coins cache allows more thorough checking with the same
memory budget.

This has no effect on performance because everything ends up in the child
cache created by VerifyDB itself.

It has bugged me ever since #4675, which effectively reduced the
number of checked blocks to reduce peak memory usage.

- Pass the coinsview to use as argument to VerifyDB

- This also avoids that the first `pcoinsTip->Flush()` after VerifyDB
  writes a large slew of unchanged coin records back to the database.
2014-08-27 09:20:33 +02:00
Pieter Wuille 3da58b216b
Merge pull request #4748
ad49c25 Split up util.cpp/h (Wladimir J. van der Laan)
f841aa2 Move `COIN` and `CENT` to core.h (Wladimir J. van der Laan)
6e5fd00 Move `*Version()` functions to version.h/cpp (Wladimir J. van der Laan)
b4aa769 Move `S_I*` constants and `MSG_NOSIGNAL` to compat.h (Wladimir J. van der Laan)
af8297c Move functions in wallet.h to implementation file (Wladimir J. van der Laan)
651480c move functions in main and net to implementation files (Wladimir J. van der Laan)
610a8c0 Move SetThreadPriority implementation to util.cpp instead of the header (Wladimir J. van der Laan)
f780e65 Remove unused function `ByteReverse` from util.h (Wladimir J. van der Laan)
121d6ad Remove unused `alignup` function from util.h (Wladimir J. van der Laan)
d1e26d4 Move CMedianFilter to timedata.cpp (Wladimir J. van der Laan)
2014-08-26 16:57:05 +02:00
Wladimir J. van der Laan ad49c256c3 Split up util.cpp/h
Split up util.cpp/h into:

- string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach)
- money utilities (parsesmoney, formatmoney)
- time utilities (gettime*, sleep, format date):
- and the rest (logging, argument parsing, config file parsing)

The latter is basically the environment and OS handling,
and is stripped of all utility functions, so we may want to
rename it to something else than util.cpp/h for clarity (Matt suggested
osinterface).

Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-26 13:25:22 +02:00
Wladimir J. van der Laan 651480c8e4 move functions in main and net to implementation files 2014-08-26 13:25:21 +02:00
Daniel Kraft d0867acb0e Use const CCoinsView's at some places.
At some places where it is possible (e. g., CheckInputs), use a const
version of CCoinsView instead of a non-const one.
2014-08-26 11:29:18 +02:00
Pieter Wuille 92bb6f2f17 Bypass reloading blocks from disk 2014-08-26 02:26:41 +02:00
Wladimir J. van der Laan 49f954f154
Merge pull request #4716
0d27dad Clean-up SyncWithWallets/SyncTransaction (Cozz Lovan)
2014-08-25 15:04:28 +02:00
Wladimir J. van der Laan 11270ebde4
Merge pull request #4351
da2ec10 Add a getutxos command to the p2p protocol. It allows querying of the UTXO set given a set of outpoints. (Mike Hearn)
2014-08-25 10:37:40 +02:00
Pieter Wuille 5cd00bc8cb
Merge pull request #4618
eb0b56b Simplify serialize.h's exception handling (Pieter Wuille)
2014-08-24 02:06:09 +02:00
jtimon 654871d436 replace ComputeMinWork with CheckMinWork 2014-08-23 13:21:51 +02:00
jtimon c2c02f3fa9 Move UpdateTime to pow 2014-08-23 13:21:50 +02:00
Wladimir J. van der Laan 3802224110 Remove all other print() methods
All unused.
2014-08-20 20:54:27 +02:00
Wladimir J. van der Laan 21e7a5690f
Merge pull request #4655
216e9a4 Add a way to limit deserialized string lengths (Pieter Wuille)
2014-08-18 09:55:24 +02:00
Cozz Lovan 0d27dad845 Clean-up SyncWithWallets/SyncTransaction 2014-08-17 17:39:30 +02:00
Jeff Garzik c7b6117deb Create new signal for notification of new blocks. Use w/ -blocknotify 2014-08-14 12:32:34 -04:00
Jeff Garzik beb36e800c ui_interface: remove unused NotifyBlocksChanged signal 2014-08-14 12:19:54 -04:00
Peter Todd 9ee09dc64f
Reapply: Reject transactions with excessive numbers of sigops
Reverting was based on a misunderstanding, it appears.

Github-Pull: #4150
2014-08-13 14:37:56 +02:00
Wladimir J. van der Laan 3b72fdfb86 Revert "Reject transactions with excessive numbers of sigops"
This reverts commit 4fad8e6d83.
2014-08-12 15:06:20 +02:00
Wladimir J. van der Laan 8ebe42435a
Merge pull request #4150
4fad8e6 Reject transactions with excessive numbers of sigops (Peter Todd)
2014-08-12 14:57:13 +02:00
Mike Hearn da2ec100f3 Add a getutxos command to the p2p protocol. It allows querying of the UTXO set
given a set of outpoints.
2014-08-11 13:59:47 +02:00
Wladimir J. van der Laan ea100c73fa Reduce maximum coinscache size during verification
Due to growing coinsviewcaches, the memory usage with checklevel=3
(and standard settings for dbcache) could be up to 500MiB on a
64-bit system. This is about twice the peak during reindexing,
unnecessarily extending bitcoind's memory envelope.

This commit reduces the maximum total size of the caches used during
verification to just nCoinCacheSize, which should be the limit.
2014-08-11 08:43:06 +02:00
Pieter Wuille eb0b56b190 Simplify serialize.h's exception handling
Remove the 'state' and 'exceptmask' from serialize.h's stream implementations,
as well as related methods.

As exceptmask always included 'failbit', and setstate was always called with
bits = failbit, all it did was immediately raise an exception. Get rid of
those variables, and replace the setstate with direct exception throwing
(which also removes some dead code).

As a result, good() is never reached after a failure (there are only 2
calls, one of which is in tests), and can just be replaced by !eof().

fail(), clear(n) and exceptions() are just never called. Delete them.
2014-08-09 01:43:23 +02:00
Pieter Wuille 216e9a4456 Add a way to limit deserialized string lengths
and use it for most strings being serialized.
2014-08-09 01:37:16 +02:00
Jeff Garzik 70b9d36a2c
Log "version" message IP addresses in client connect summary
The only other method of logging remote addresses is via

     -logips=1 -debug=net

which increases the logged activity by 100x or more.

Github-Pull: #4608
Amended-By: Wladimir J. van der Laan <laanwj@gmail.com>
2014-08-04 16:59:28 +02:00
Daniel Kraft b33bd7a3be Implement "getchaintips" RPC command to monitor blockchain forks.
Port over https://github.com/chronokings/huntercoin/pull/19 from
Huntercoin:  This implements a new RPC command "getchaintips" that can be
used to find all currently active chain heads.  This is similar to the
-printblocktree startup option, but it can be used without restarting
just via the RPC interface on a running daemon.
2014-08-03 18:12:19 +02:00
Pieter Wuille e8cb5c30b0
Merge pull request #4497
714a3e6 Only keep setBlockIndexValid entries that are possible improvements (Pieter Wuille)
2014-07-31 00:07:47 +02:00
Pieter Wuille d70bc52ee3 Rework block processing benchmark code
* Replace -benchmark (and the related fBenchmark) with a regular debug option, -debug=bench.
* Increase coverage and granularity of individual block processing steps.
* Add cummulative times.
2014-07-27 00:41:03 +02:00
Wladimir J. van der Laan 70d0325999
Merge pull request #4496
5734d4d Only remove actualy failed blocks from setBlockIndexValid (Pieter Wuille)
2014-07-24 16:55:48 +02:00
Wladimir J. van der Laan 98e84aae7a Revert "Relay double-spends, subject to anti-DOS"
This reverts commit d640a3ceab.
2014-07-21 07:46:34 +02:00
Wladimir J. van der Laan ad26dc9c31 Revert "Formatting, spelling, comment fixes."
This reverts commit 7a19efe040.
2014-07-21 07:46:33 +02:00
Wladimir J. van der Laan cd057bfd41 Revert "Check signatures before respend relay"
This reverts commit 88dd3598d2.
2014-07-21 07:46:33 +02:00
Wladimir J. van der Laan 67cc8f25c2 Revert "Remove signal DoubleSpendDetected, use function"
This reverts commit 0da6b3fd18.
2014-07-21 07:46:33 +02:00
Jeff Garzik 3da434a2ef Introduce option to disable relay/mining of bare multisig scripts in TX outputs
First and foremost, this defaults to OFF.

This option lets a node consider such transactions non-standard,
meaning they will not be relayed or mined by default, but other miners
are free to mine these as usual.
2014-07-18 10:16:47 -04:00
Wladimir J. van der Laan ea8c288a35
Merge pull request #4533
43005cf Fix semantic typo in state.CorruptionPossible check (kazcw)
2014-07-17 13:57:51 +02:00
R E Broadley 604ee2aa7d Remove tx from AlreadyAskedFor list once we receive it, not when we process it. 2014-07-16 18:00:34 +07:00
Wladimir J. van der Laan 2c0f019bfc
Merge pull request #4505
d4d3fbd Do not flush the cache after every block outside of IBD (Pieter Wuille)
2014-07-15 09:14:33 +02:00
kazcw 43005cffa3 Fix semantic typo in state.CorruptionPossible check
state.Invalid() is always false, check should be IsInvalid()

Broken since 942b33a
2014-07-14 19:57:43 -07:00
Wladimir J. van der Laan 6513a9f703
Merge pull request #4400
4eedf4f make RandAddSeed() use OPENSSL_cleanse() (Philip Kaufmann)
6354935 move rand functions from util to new random.h/.cpp (Philip Kaufmann)
001a53d add GetRandBytes() as wrapper for RAND_bytes() (Philip Kaufmann)
2014-07-14 11:35:30 +02:00
Wladimir J. van der Laan c9bc398ad9
Merge pull request #4378
dc942e6 Introduce whitelisted peers. (Pieter Wuille)
2014-07-14 10:23:39 +02:00
Peter Todd 4fad8e6d83
Reject transactions with excessive numbers of sigops 2014-07-13 10:12:49 -04:00
Pieter Wuille d4d3fbd828 Do not flush the cache after every block outside of IBD 2014-07-11 16:44:53 +02:00
Pieter Wuille 714a3e6505 Only keep setBlockIndexValid entries that are possible improvements 2014-07-11 15:59:32 +02:00
Luke Dashjr ff6a7af154 getblocktemplate: longpolling support 2014-07-11 14:48:02 +02:00
Pieter Wuille dc942e6f27 Introduce whitelisted peers.
This adds a -whitelist option to specify subnet ranges from which peers
that connect are whitelisted. In addition, there is a -whitebind option
which works like -bind, except peers connecting to it are also
whitelisted (allowing a separate listen port for trusted connections).

Being whitelisted has two effects (for now):
* They are immune to DoS disconnection/banning.
* Transactions they broadcast (which are valid) are always relayed,
  even if they were already in the mempool. This means that a node
  can function as a gateway for a local network, and that rebroadcasts
  from the local network will work as expected.

Whitelisting replaces the magic exemption localhost had for DoS
disconnection (local addresses are still never banned, though), which
implied hidden service connects (from a localhost Tor node) were
incorrectly immune to DoS disconnection as well. This old
behaviour is removed for that reason, but can be restored using
-whitelist=127.0.0.1 or -whitelist=::1 can be specified. -whitebind
is safer to use in case non-trusted localhost connections are expected
(like hidden services).
2014-07-09 20:40:14 +02:00
Pieter Wuille 5734d4d1e6 Only remove actualy failed blocks from setBlockIndexValid 2014-07-09 18:30:44 +02:00
Philip Kaufmann 001a53d742 add GetRandBytes() as wrapper for RAND_bytes()
- add a small wrapper in util around RAND_bytes() and replace with
  GetRandBytes() in the code to log errors from calling RAND_bytes()
- remove OpenSSL header rand.h where no longer needed
2014-07-09 09:42:18 +02:00
Wladimir J. van der Laan c6ac5fcfc2
Merge pull request #4471
40f5cb8 Send rejects and apply DoS scoring for errors in direct block validation. (Pieter Wuille)
2014-07-07 17:31:05 +02:00
Wladimir J. van der Laan 4851d09603
Merge pull request #4446
209377a Use GetBlockTime() more (jtimon)
2014-07-07 10:29:10 +02:00
Wladimir J. van der Laan 5e1b7a23b0
Merge pull request #4470
f4b00be Add CChain::GetLocator() unit test (Pieter Wuille)
3c85d2e Fix CChain::GetLocator (Pieter Wuille)
2014-07-07 10:28:09 +02:00
jtimon 209377a7cb Use GetBlockTime() more 2014-07-07 10:20:28 +02:00
Wladimir J. van der Laan e1f7c7d173
Merge pull request #4472
9f4da19 Use pong receive time rather than processing time (Pieter Wuille)
2014-07-07 06:28:43 +02:00
Pieter Wuille 9f4da19bab Use pong receive time rather than processing time 2014-07-06 16:08:18 +02:00
Pieter Wuille 40f5cb878e Send rejects and apply DoS scoring for errors in direct block validation.
75f51f2a introduced asynchronous processing for blocks, where reject messages
and DoS scoring could be applied outside of ProcessBlock, because block
validation may happen later.

However, some types of errors are still detected immediately (in particular,
CheckBlock violations), which need acting after ProcessBlock returns.
2014-07-06 14:47:23 +02:00
Pieter Wuille 3c85d2ec37 Fix CChain::GetLocator 2014-07-06 13:42:29 +02:00
Wladimir J. van der Laan 00fa78c35b
Merge pull request #3764
2e36866 Show nodeid instead of addresses (for anonymity) unless otherwise requested. (R E Broadley)
2014-07-04 08:04:30 +02:00
Wladimir J. van der Laan e61c6d69ad
Merge pull request #4450
0da6b3f Remove signal DoubleSpendDetected, use function (Tom Harding)
88dd359 Check signatures before respend relay (Tom Harding)
2014-07-04 05:50:53 +02:00
R E Broadley 2e36866fec Show nodeid instead of addresses (for anonymity) unless otherwise requested. 2014-07-04 09:38:44 +07:00
Gavin Andresen 13fc83c77b
Move fee policy out of core 2014-07-03 14:42:16 -04:00
Gavin Andresen 4b7b1bb1ac
Sanity checks for estimates
Require at least 11 samples before giving fee/priority estimates.

And have wallet-created transactions go throught the fee-sanity-check
code path.
2014-07-03 13:44:56 -04:00
Gavin Andresen b33d1f5ee5
Use fee/priority estimates in wallet CreateTransaction
The wallet now uses the mempool fee estimator with a new
command-line option: -txconfirmtarget (default: 1) instead
of using hard-coded fees or priorities.

A new bitcoind that hasn't seen enough transactions to estimate
will fall back to the old hard-coded minimum priority or
transaction fee.

-paytxfee option overrides -txconfirmtarget.

Relaying and mining code isn't changed.

For Qt, the coin control dialog now uses priority estimates to
label transaction priority (instead of hard-coded constants);
unspent outputs were consistently labeled with a much higher
priority than is justified by the free transactions actually
being accepted into blocks.

I did not implement any GUI for setting -txconfirmtarget; I would
suggest getting rid of the "Pay transaction fee" GUI and replace
it with either "target number of confirmations" or maybe
a "faster confirmation <--> lower fee" slider or select box.
2014-07-03 13:44:33 -04:00
Tom Harding 0da6b3fd18 Remove signal DoubleSpendDetected, use function
Also removes the need for forward reference to RelayableRespend.
2014-07-02 09:27:29 -07:00
Tom Harding 88dd3598d2 Check signatures before respend relay
Check that all inputs are completely valid before actually
relaying a double-spend.
2014-07-01 14:37:10 -07:00
Gavin Andresen 8ceb28afc3 Merge pull request #3883 from dgenr8/first_double_spend
Relay and alert user to double spends
2014-06-30 08:35:12 -04:00
Pieter Wuille c9a0918330 Add a skiplist to the CBlockIndex structure.
This allows fast (O(log n)) access to far predecessor blocks.
Use it to speed up CChain::FindFork and CChain::GetLocator.
2014-06-29 21:51:54 +02:00
Pieter Wuille aa81564700 Track peers' available blocks 2014-06-29 21:50:55 +02:00
Wladimir J. van der Laan 7b8fc9d8ad
Merge pull request #4436
675bcd5 Correct comment for 15-of-15 p2sh script size (Michael Ford)
2014-06-28 15:09:15 +02:00
Wladimir J. van der Laan c8b6c0a2cf
Merge pull request #4425
6ecf3ed Display unknown commands received. (R E Broadley)
2014-06-28 15:07:51 +02:00
Wladimir J. van der Laan 9125ef9421
Merge pull request #4398
86fe1b8 update coding.md to reflect changes by pull (Philip Kaufmann)
e10dcf2 ensure clean and consistent "namespace" usage (Philip Kaufmann)
2014-06-28 15:06:18 +02:00
Michael Ford 675bcd5892 Correct comment for 15-of-15 p2sh script size
The original comment forgets to account for the script push which will
need an OP_PUSHDATA2 + 2-bytes for the 513 script bytes.

props davecgh
fixes #4224
2014-06-28 20:57:46 +08:00
R E Broadley 6ecf3edfee Display unknown commands received. 2014-06-28 10:02:19 +07:00
R E Broadley 0dd5d3a009 Show only one zero instead of many when getblocks request received with a hashStop of uint256(0) 2014-06-28 09:55:24 +07:00
Tom Harding 7a19efe040 Formatting, spelling, comment fixes. 2014-06-27 16:47:33 -07:00
Tom Harding d640a3ceab Relay double-spends, subject to anti-DOS
Allows network wallets and other clients to see transactions that respend
a prevout already spent in an unconfirmed transaction in this node's mempool.

Knowledge of an attempted double-spend is of interest to recipients of the
first spend.  In some cases, it will allow these recipients to withhold
goods or services upon being alerted of a double-spend that deprives them
of payment.

As before, respends are not added to the mempool.

Anti-Denial-of-Service-Attack provisions:
 - Use a bloom filter to relay only one respend per mempool prevout
 - Rate-limit respend relays to a default of 100 thousand bytes/minute
 - Define tx2.IsEquivalentTo(tx1): equality when scriptSigs are not considered
 - Do not relay these equivalent transactions

Remove an unused variable declaration in txmempool.cpp.
2014-06-27 07:54:21 -07:00
Gavin Andresen 6259937388 Merge pull request #4365 from gavinandresen/relax_isstandard
Relax IsStandard rules for pay-to-script-hash transactions
2014-06-27 10:53:24 -04:00
Luke Dashjr 2a72d4591f JSON-RPC method: prioritisetransaction <txid> <priority delta> <priority tx fee>
Accepts the transaction into mined blocks at a higher (or lower) priority
2014-06-26 11:49:46 +00:00
Philip Kaufmann e10dcf27b4 ensure clean and consistent "namespace" usage
- remove some missplaced ;
- ensure end of a namespace is clearly visible
- use same formatting when using namespace
2014-06-26 10:36:57 +02:00
jtimon df852d2bcc Refactor proof of work related functions out of main 2014-06-23 23:10:24 +02:00
Gavin Andresen 7f3b4e9569
Relax IsStandard rules for pay-to-script-hash transactions
Relax the AreInputsStandard() tests for P2SH transactions --
allow any Script in a P2SH transaction to be relayed/mined,
as long as it has 15 or fewer signature operations.

Rationale: https://gist.github.com/gavinandresen/88be40c141bc67acb247

I don't have an easy way to test this, but the code changes are
straightforward and I've updated the AreInputsStandard unit tests.
2014-06-23 15:09:52 -04:00
Pieter Wuille d38da59bf6 Code simplifications after CTransaction::GetHash() caching 2014-06-22 00:06:17 +02:00
Wladimir J. van der Laan b8b98d5642
Merge pull request #4310
7a9e0b6 Move checkpoint based heuristic checks to AcceptBlockHeader (Pieter Wuille)
2014-06-19 14:38:45 +02:00
Wladimir J. van der Laan 3f39b9d455
Merge pull request #2784
f1920e8 Ping automatically every 2 minutes (unconditionally) (Pieter Wuille)
2014-06-12 12:40:09 +02:00
Philip Kaufmann ac14bcc1f1 small formatting, indentation and comment fixes
- contains zero code changes
2014-06-10 18:23:56 +02:00
Pieter Wuille f1920e8606 Ping automatically every 2 minutes (unconditionally)
... instead of after 30 minutes of no sending, for latency measurement
and keep-alive. Also, disconnect if no reply arrives within 20 minutes,
instead of 90 of inactivity (for peers supporting the 'pong' message).
2014-06-09 23:06:56 +02:00
Wladimir J. van der Laan 62fdf381fa
Merge pull request #3824
f0a83fc Use Params().NetworkID() instead of TestNet() from the payment protocol (jtimon)
2871889 net.h was using std namespace through chainparams.h included in protocol.h (jtimon)
c8c52de Replace virtual methods with static attributes, chainparams.h depends on protocol.h instead of the other way around (jtimon)
a3d946e Get rid of TestNet() (jtimon)
6fc0fa6 Add RPCisTestNet chain parameter (jtimon)
cfeb823 Add RequireStandard chain parameter (jtimon)
21913a9 Add AllowMinDifficultyBlocks chain parameter (jtimon)
d754f34 Move majority constants to chainparams (jtimon)
8d26721 Get rid of RegTest() (jtimon)
cb9bd83 Add DefaultCheckMemPool chain parameter (jtimon)
2595b9a Add DefaultMinerThreads chain parameter (jtimon)
bfa9a1a Add MineBlocksOnDemand chain parameter (jtimon)
1712adb Add MiningRequiresPeers chain parameter (jtimon)
2014-06-09 12:52:29 +02:00
Pieter Wuille 18e72167dd Push cs_mains down in ProcessBlock 2014-06-09 02:21:15 +02:00
Pieter Wuille 202e01941c Move all post-chaintip-change notifications to ActivateBestChain 2014-06-09 02:21:15 +02:00
Pieter Wuille 4e0eed88ac Allow ActivateBestChain to release its lock on cs_main 2014-06-09 02:21:15 +02:00
Pieter Wuille 77339e5aec Get rid of the static chainMostWork (optimization) 2014-06-09 02:21:15 +02:00
Pieter Wuille 7a9e0b6460 Move checkpoint based heuristic checks to AcceptBlockHeader 2014-06-09 01:27:56 +02:00
Gavin Andresen 171ca7745e estimatefee / estimatepriority RPC methods
New RPC methods: return an estimate of the fee (or priority) a
transaction needs to be likely to confirm in a given number of
blocks.

Mike Hearn created the first version of this method for estimating fees.
It works as follows:

For transactions that took 1 to N (I picked N=25) blocks to confirm,
keep N buckets with at most 100 entries in each recording the
fees-per-kilobyte paid by those transactions.

(separate buckets are kept for transactions that confirmed because
they are high-priority)

The buckets are filled as blocks are found, and are saved/restored
in a new fee_estiamtes.dat file in the data directory.

A few variations on Mike's initial scheme:

To estimate the fee needed for a transaction to confirm in X buckets,
all of the samples in all of the buckets are used and a median of
all of the data is used to make the estimate. For example, imagine
25 buckets each containing the full 100 entries. Those 2,500 samples
are sorted, and the estimate of the fee needed to confirm in the very
next block is the 50'th-highest-fee-entry in that sorted list; the
estimate of the fee needed to confirm in the next two blocks is the
150'th-highest-fee-entry, etc.

That algorithm has the nice property that estimates of how much fee
you need to pay to get confirmed in block N will always be greater
than or equal to the estimate for block N+1. It would clearly be wrong
to say "pay 11 uBTC and you'll get confirmed in 3 blocks, but pay
12 uBTC and it will take LONGER".

A single block will not contribute more than 10 entries to any one
bucket, so a single miner and a large block cannot overwhelm
the estimates.
2014-06-06 10:44:57 -04:00
Gavin Andresen c6cb21d17a Type-safe CFeeRate class
Use CFeeRate instead of an int64_t for quantities that are
fee-per-size.

Helps prevent unit-conversion mismatches between the wallet,
relaying, and mining code.
2014-06-06 10:34:18 -04:00
Gavin Andresen 4fee61a905 Merge pull request #4287 from laanwj/2014_06_sideeffect
Remove side effect in assertion in ProcessGetData
2014-06-04 20:15:45 -04:00
Jeff Garzik c79897af31 Merge pull request #4247 from Diapolo/listen
rename fNoListen to fListen and move to net
2014-06-04 15:00:38 -04:00
Wladimir J. van der Laan f0f4904bec
Merge pull request #4258
7b45d94 Make max number of orphan blocks kept in memory a startup parameter (fixes #4253) (shshshsh)
2014-06-04 19:30:44 +02:00
Wladimir J. van der Laan 4a48a0671d
Remove side effect in assertion in ProcessGetData
A side-effect was introduced into an assertion in 7a0e84d. This commit
fixes that.
2014-06-04 16:02:04 +02:00
shshshsh 7b45d943b2 Make max number of orphan blocks kept in memory a startup parameter (fixes #4253) 2014-06-04 11:58:18 +00:00
jtimon cfeb8235fd Add RequireStandard chain parameter 2014-06-04 13:29:36 +02:00
jtimon 21913a9ac9 Add AllowMinDifficultyBlocks chain parameter 2014-06-04 13:29:36 +02:00
jtimon d754f34e8d Move majority constants to chainparams 2014-06-04 13:29:36 +02:00
Cozz Lovan 06a91d9698 VerifyDB progress 2014-06-03 15:21:47 +02:00
Philip Kaufmann 53a088154c rename fNoListen to fListen and move to net
- better code readability and it belongs to net
- this is a prerequisite for a pull to add -listen to the GUI
2014-05-29 14:01:39 +02:00
Wladimir J. van der Laan 0f1040ba52
Merge pull request #4183
f40dbee remove CPubKey::VerifyCompact( ) which is never used (Kamil Domanski)
28b6c1d remove GetMedianTime( ) which is never used (Kamil Domanski)
5bd4adc remove LookupHostNumeric( ) which is never used (Kamil Domanski)
595f691 remove LogException( ) which is never used (Kamil Domanski)
f4057cb remove CTransaction::IsNewerThan which is never used (Kamil Domanski)
0e31e56 remove CWallet::AddReserveKey which is never used (Kamil Domanski)
2014-05-25 16:19:54 +02:00
Pieter Wuille 305ccaa275 Add missing LOCK(cs_main) 2014-05-20 21:45:12 +02:00
Kamil Domanski 28b6c1def5 remove GetMedianTime( ) which is never used 2014-05-20 14:58:21 +02:00
Wladimir J. van der Laan dff9d2f293
Merge pull request #4199
0a59723 Remove extraneous c_str (R E Broadley)
2014-05-20 09:45:40 +02:00
R E Broadley 0a59723ff6 Remove extraneous c_str 2014-05-20 12:31:26 +08:00
Wladimir J. van der Laan aed38cbcb5
Merge pull request #4173
8c93bf4 LoadBlockIndexDB(): Require block db reindex if any blk*.dat files are missing. (Ashley Holman)
7a0e84d ProcessGetData(): abort if a block file is missing from disk (Ashley Holman)
2014-05-19 17:02:29 +02:00
Ashley Holman 8c93bf4c28 LoadBlockIndexDB(): Require block db reindex if any blk*.dat files are missing. 2014-05-12 08:09:09 -05:00
Wladimir J. van der Laan c3ad56f4e0
Merge pull request #4138
783b182 Remove dummy PRIszX macros for formatting (Wladimir J. van der Laan)
2014-05-12 14:01:48 +02:00
Ashley Holman 7a0e84dd63 ProcessGetData(): abort if a block file is missing from disk 2014-05-11 07:06:26 -05:00
Wladimir J. van der Laan 8bcfccbc2d
Merge pull request #4076
397668e Deduplicate uint* comparison operator logic (Pieter Wuille)
df9eb5e Move {Get,Set}Compact from bignum to uint256 (Pieter Wuille)
a703150 Add multiplication and division to uint160/uint256 (Pieter Wuille)
4d480c8 Exception instead of assigning 0 in case of wrong vector length (Pieter Wuille)
eb2cbd7 Deduplicate shared code between uint160 and uint256 (Pieter Wuille)
2014-05-09 17:03:51 +02:00
Wladimir J. van der Laan 82564e21e7
Merge pull request #4134
aa250f0 Remove NumBlocksOfPeers (Wladimir J. van der Laan)
2014-05-09 16:54:07 +02:00
Pieter Wuille df9eb5e14f Move {Get,Set}Compact from bignum to uint256 2014-05-09 16:44:59 +02:00
Wladimir J. van der Laan 54f102248b
Merge pull request #3843
787ee0c Check redeemScript size does not exceed 520 byte limit (Peter Todd)
4d79098 Increase IsStandard() scriptSig length (Peter Todd)
f80cffa Do not trigger a DoS ban if SCRIPT_VERIFY_NULLDUMMY fails (Peter Todd)
6380180 Add rejection of non-null CHECKMULTISIG dummy values (Peter Todd)
29c1749 Let tx (in)valid tests use any SCRIPT_VERIFY flag (Peter Todd)
68f7d1d Create (MANDATORY|STANDARD)_SCRIPT_VERIFY_FLAGS constants (Peter Todd)
2014-05-09 16:09:20 +02:00
Wladimir J. van der Laan d54985f3f1
Merge pull request #3884
942b33a Split AcceptBlockHeader from AcceptBlock. (Pieter Wuille)
f457347 Split up CheckBlock in a block and header version (Pieter Wuille)
2014-05-09 16:00:41 +02:00
Peter Todd 4d79098ad5 Increase IsStandard() scriptSig length
Removes the limits on number of pubkeys for P2SH CHECKMULTISIG outputs.
Previously with the 500 byte scriptSig limit there were odd restrictions
where even a 1-of-12 P2SH could be spent in a standard transaction(1),
yet multisig scriptPubKey's requiring more signatures quickly ran out of
scriptSig space.

From a "stuff-data-in-the-blockchain" point of view not much has changed
as with the prior commit now only allowing the dummy value to be null
the newly allowed scriptSig space can only be used for signatures. In
any case, just using more outputs is trivial and doesn't cost much.

1) See 779b519480d8c5346de6e635119c7ee772e97ec872240c45e558f582a37b4b73
   Mined by BTC Guild.
2014-05-08 00:55:01 -04:00
Peter Todd f80cffa213 Do not trigger a DoS ban if SCRIPT_VERIFY_NULLDUMMY fails 2014-05-08 00:55:01 -04:00
Wladimir J. van der Laan a475285a53
Add missing cs_main lock to VerifyDB
Fixes issue #4139.
2014-05-07 15:15:28 +02:00
Wladimir J. van der Laan 783b182c8f Remove dummy PRIszX macros for formatting
Size specifiers are no longer needed now that we use typesafe tinyformat
for string formatting, instead of the system's sprintf.

No functional changes.

This continues the work in #3735.
2014-05-06 15:29:16 +02:00
Wladimir J. van der Laan aa250f0453 Remove NumBlocksOfPeers
Generally useless information. Only updates on connect time, not after
that. Peers can easily lie and the median filter is not effective in
preventing that.

In the past it was used for progress display in the GUI but
`CheckPoints::guessVerificationProgress` provides a better way that is now used.
It was too easy to mislead it. Peers do lie about it in practice, see issue #4065.

From the RPC, `getpeerinfo` gives the peer raw values, which are more
useful.
2014-05-06 11:09:19 +02:00