Commit graph

639 commits

Author SHA1 Message Date
Peter Todd 68f7d1d7af Create (MANDATORY|STANDARD)_SCRIPT_VERIFY_FLAGS constants 2014-05-05 05:35:27 -04:00
Wladimir J. van der Laan 191b087e0e
Merge pull request #4109
6b29ccc Correct indentation (R E Broadley)
2014-05-01 08:09:20 +02:00
Philip Kaufmann 1cc7f54a8d use standard __func__ instead of __PRETTY_FUNCTION__ 2014-04-30 14:45:24 +02:00
R E Broadley 6b29ccc9f9 Correct indentation 2014-04-30 14:57:11 +08:00
Simon de la Rouviere 0caf2b187f Add MESSAGE_START_SIZE from chainparams when loading blocks from external files. 2014-04-24 14:32:11 +02:00
Wladimir J. van der Laan b39a07dc42 Add missing AssertLockHeld in ConnectBlock 2014-04-23 09:07:18 +02:00
Wladimir J. van der Laan 55a1db4fa2 Solve chainActive-related locking issues
- In wallet and GUI code LOCK cs_main as well as cs_wallet when
  necessary
- In main.cpp SendMessages move the TRY_LOCK(cs_main) up, to encompass the call
  to IsInitialBlockDownload.
- Make ActivateBestChain, AddToBlockIndex, IsInitialBlockDownload,
  InitBlockIndex acquire the cs_main lock

Fixes #3997
2014-04-18 12:49:41 +02:00
Wladimir J. van der Laan e07c943ce8 Add AssertLockHeld for cs_main to ChainActive-using functions
All functions that use ChainActive but do not aquire the cs_main
lock themselves, need to be called with the cs_main lock held.

This commit adds assertions to all externally callable functions
that use chainActive or chainMostWork.

This will flag usages when built with -DDEBUG_LOCKORDER.
2014-04-17 16:46:01 +02:00
Gregory Maxwell 94c8bfb23b Move assert(pindexNew); to above where we dereference pindexNew. 2014-04-05 22:11:16 -07:00
Gavin Andresen 8556b0298d Merge pull request #3842 from ditto-b/master
Fix for GetBlockValue() after block 13,440,000
2014-04-02 21:31:17 -04:00
Wladimir J. van der Laan af4c2ac8ce Fix -printblocktree output
PrintBlockTree output was broken starting from e010af70.
Everything appears on one line.

PrintWallet() added the newline after a block, but this functionality
was removed and no newline was added.

Seemingly, no one noticed. Add a newline after the block information
to fix this.
2014-03-29 16:25:47 +01:00
Philip Kaufmann 2b45345aac minor style cleanups 2014-03-11 17:26:05 +01:00
Gavin Andresen 669264c176 Merge branch 'match_relay_fee' of git://github.com/mikehearn/bitcoin 2014-03-11 11:20:07 -04:00
Wladimir J. van der Laan 1264b3647d
Merge pull request #3696
c4656e0 Add progress to initial display of latest block downloaded. (R E Broadley)
75b8953 Display progress of rescan. (R E Broadley)
2014-03-11 09:18:16 +01:00
ditto-b c5a9d2ca9e Fix for GetBlockValue() after block 13,440,000
Forces the block reward to zero when right shift in GetBlockValue() is
undefined, after 64 reward halvings (block height 13,440,000).
2014-03-10 19:02:36 -05:00
Mike Hearn 037b4f1485 Make mining fee policy match relay fee policy.
This resolves a case in which a mismatch could be used to bloat up the
mempool by sending transactions that pay enough fee to relay, but not
to be mined, with the default policies.
2014-03-10 19:17:18 +01:00
Wladimir J. van der Laan b76733d8e8
Merge pull request #3514
f59d8f0 Per-peer block download tracking and stalled download detection. (Pieter Wuille)
2014-03-10 13:23:18 +01:00
Gavin Andresen f60e49d49c Merge pull request #3694 from gavinandresen/vfspent
Remove CWalletTx::vfSpent
2014-02-28 15:16:25 -05:00
Gavin Andresen e3e65d29b7 Merge pull request #3735 from laanwj/2014_02_remove_PRIx64_completely
Remove PRIx64 usage completely
2014-02-26 12:16:03 -05:00
Gavin Andresen 93a18a3650 Remove CWalletTx::vfSpent
Use the spent outpoint multimap to figure out which wallet transaction
outputs are unspent, instead of a vfSpent array that is saved
to disk.
2014-02-26 11:53:51 -05:00
Jeff Garzik beabca2be0 Merge pull request #3305 from mikehearn/fee_drop
Drop fees by 10x due to the persistently higher exchange rate.
2014-02-24 14:05:54 -05:00
Wladimir J. van der Laan f48742c2bf Get rid of C99 PRI?64 usage in source files
Amend to d5f1e72. It turns out that BerkelyDB was including inttypes.h
indirectly, so we cannot fix this with just macros.

Trivial commit: apply the following script to all .cpp and .h files:

    # Middle
    sed -i 's/"PRIx64"/x/g' "$1"
    sed -i 's/"PRIu64"/u/g' "$1"
    sed -i 's/"PRId64"/d/g' "$1"
    # Initial
    sed -i 's/PRIx64"/"x/g' "$1"
    sed -i 's/PRIu64"/"u/g' "$1"
    sed -i 's/PRId64"/"d/g' "$1"
    # Trailing
    sed -i 's/"PRIx64/x"/g' "$1"
    sed -i 's/"PRIu64/u"/g' "$1"
    sed -i 's/"PRId64/d"/g' "$1"

After this commit, `git grep` for PRI.64 should turn up nothing except
the defines in util.h.
2014-02-24 09:08:56 +01:00
Wladimir J. van der Laan d5f1e727a8 Don't use PRIx64 formatting derives from inttypes.h
As the tinyformat-based formatting system (introduced in b77dfdc) is
type-safe, no special format characters are needed to specify sizes.

Tinyformat can support (ignore) the C99 prefixes such as "ll" but
chokes on MSVC's inttypes.h defines prefixes such as "I64X". So don't
include inttypes.h and define our own for compatibility.

(an alternative would be to sweep the entire codebase using sed -i to
get rid of the size specifiers but this has less diff impact)
2014-02-22 11:36:37 +01:00
Wladimir J. van der Laan 76a77059f3
Merge pull request #2910
d8b4b49 Don't store or send side-chain blocks lower than last checkpoint. (Ashley Holman)
2014-02-20 12:32:32 +01:00
R E Broadley c4656e0d88 Add progress to initial display of latest block downloaded. 2014-02-19 18:23:13 -08:00
Wladimir J. van der Laan 047ee427e7
Merge pull request #3666
bbfce8a fix non-standard reason string in main.cpp (Philip Kaufmann)
2014-02-17 13:59:50 +01:00
Wladimir J. van der Laan b8d9058a4d
Merge pull request #3646
5770254 Copyright header updates s/2013/2014 on files whose last git commit was done in 2014. contrib/devtools/fix-copyright-headers.py script to be able to perform this maintenance task with ease during the rest of the year, every year. Modifications to contrib/devtools/README.md to document what fix-copyright-headers.py does. (gubatron)
2014-02-16 11:44:48 +01:00
Gavin Andresen 2b72d46f42 Handle "conflicted" transactions properly
Extend CMerkleTx::GetDepthInMainChain with the concept of
a "conflicted" transaction-- a transaction generated by the wallet
that is not in the main chain or in the mempool, and, therefore,
will likely never be confirmed.

GetDepthInMainChain() now returns -1 for conflicted transactions
(0 for unconfirmed-but-in-the-mempool, and >1 for confirmed).

This makes getbalance, getbalance '*', and listunspent all agree when there are
mutated transactions in the wallet.

Before:
 listunspent: one 49BTC output
 getbalance: 96 BTC (change counted twice)
 getbalance '*': 46 BTC (spends counted twice)

After: all agree, 49 BTC available to spend.
2014-02-14 11:08:40 -05:00
Philip Kaufmann bbfce8a4c9 fix non-standard reason string in main.cpp 2014-02-13 15:12:18 +01:00
Pieter Wuille 87fe71e1fc Add HasCanonicalPushes(), and use it in IsStandardTx 2014-02-11 21:11:59 +01:00
gubatron 57702541a2 Copyright header updates s/2013/2014 on files whose last git commit was done in 2014.
contrib/devtools/fix-copyright-headers.py script to be able to perform this maintenance task with ease during the rest of the year, every year. Modifications to contrib/devtools/README.md to document what fix-copyright-headers.py does.
2014-02-09 21:06:06 -05:00
Pieter Wuille f59d8f0b64 Per-peer block download tracking and stalled download detection.
Keep track of which block is being requested (and to be requested) from
each peer, and limit the number of blocks in-flight per peer. In addition,
detect stalled downloads, and disconnect if they persist for too long.

This means blocks are never requested twice, and should eliminate duplicate
downloads during synchronization.
2014-02-08 16:52:19 +01:00
Pieter Wuille bbde1e99c8 Limit the number of orphan blocks
In case the total number of orphan blocks in memory exceeds a limit
(currently set to 750), a random orphan block (which is not
depended on by another orphan block) is dropped. This means it will
need to be downloaded again, but it won't consume memory until then.
2014-01-31 14:16:06 +01:00
Wladimir J. van der Laan 19007cf552
Merge pull request #3592
c117d9e Support for error messages and a few more rejection reasons (Luke Dashjr)
14e7ffc Use standard BIP 22 rejection reasons where applicable (Luke Dashjr)
2014-01-30 16:45:26 +01:00
Gavin Andresen 3581abdd46 Merge pull request #3370 from sipa/headersfirst3
Prepare block connection logic for headers-first
2014-01-29 13:49:15 -08:00
Luke Dashjr c117d9e93a Support for error messages and a few more rejection reasons 2014-01-29 17:39:24 +00:00
Luke Dashjr 14e7ffcc64 Use standard BIP 22 rejection reasons where applicable 2014-01-29 17:39:18 +00:00
Philip Kaufmann b34e88a88f use english for all reason strings in IsStandardTx() 2014-01-28 07:45:42 +01:00
Pieter Wuille 75f51f2a63 Prepare block connection logic for headers-first.
This changes the block processing logic from "try to atomically switch
to a new block" to a continuous "(dis)connect a block, aiming for the
assumed best chain".

This means the smallest atomic operations on the chainstate become
individual block connections or disconnections, instead of entire
reorganizations. It may mean that we try to reorganize to one block,
fail, and rereorganize again to the old block. This is slower, but
doesn't require unbounded RAM.

It also means that a ConnectBlock which fails may be no longer called
from the ProcessBlock which knows which node sent it. To deal with that,
a mapBlockSource is kept, and invalid blocks cause asynchronous "reject"
messages and banning (if necessary).
2014-01-27 21:20:41 +01:00
Pieter Wuille 0ec16f35d6 Move only: extract WriteChainState and UpdatedTip from SetBestChain. 2014-01-27 21:13:48 +01:00
Peter Todd 665bdd3bc9
Fix off-by-one errors in use of IsFinalTx()
Previously CreateNewBlock() didn't take into account the fact that
IsFinalTx() without any arguments tests if the transaction is considered
final in the *current* block, when both those functions really needed to
know if the transaction would be final in the *next* block.

Additionally the UI had a similar misunderstanding.

Also adds some basic tests to check that CreateNewBlock() is in fact
mining nLockTime-using transactions correctly.

Thanks to Wladimir J. van der Laan for rebase.
2014-01-26 21:50:15 -05:00
Wladimir J. van der Laan 7d9d134bf9 Remove redundant .c_str()s
After the tinyformat switch sprintf() family functions support passing
actual std::string objects.

Remove unnecessary c_str calls (236 of them) in logging and formatting.
2014-01-23 16:05:01 +01:00
Wladimir J. van der Laan b77dfdc9e3 Typesafe strprintf/error/LogPrint functions
Switch to tinyformat-based formatting.

Tinyformat is a typesafe drop-in replacement for C99 printf functions:
https://github.com/c42f/tinyformat
2014-01-23 16:05:00 +01:00
Ashley Holman d8b4b49667 Don't store or send side-chain blocks lower than last checkpoint. 2014-01-19 18:15:38 -06:00
Wladimir J. van der Laan 6c19ca1f92
Merge pull request #3490
7e08e29 better std::exception logging for block/undo files (Philip Kaufmann)
2014-01-18 12:25:05 +01:00
Pieter Wuille da0fecffa7 Store orphan blocks in serialized form 2014-01-11 23:39:29 +01:00
Philip Kaufmann 7e08e29117 better std::exception logging for block/undo files 2014-01-06 15:09:26 +01:00
Wladimir J. van der Laan 7aedb91476
Merge pull request #3401
012ca1c LoadWallet: acquire cs_wallet mutex before clearing setKeyPool (Wladimir J. van der Laan)
9569168 Document cs_wallet lock and add AssertLockHeld (Wladimir J. van der Laan)
19a5676 Use mutex pointer instead of name for AssertLockHeld (Wladimir J. van der Laan)
2014-01-06 10:34:01 +01:00
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