aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-06-26 15:40:22 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-06-26 15:40:59 +0200
commit24f24896d602bef3323c5ff66bbccc92448e89d5 (patch)
treeb1483c6100918e3e72c03c80c00fafec2b597644
parent41076aad0cbdfa4c4cf376e345114a5c29086f81 (diff)
parent4f40716dcb61f492f93a781751bfa25f712cba8b (diff)
Merge pull request #6299
4f40716 test: Move reindex test to standard tests (Wladimir J. van der Laan) 36c97b4 Bugfix: Don't check the genesis block header before accepting it (Jorge Timón)
-rwxr-xr-xqa/pull-tester/rpc-tests.sh2
-rw-r--r--src/main.cpp41
2 files changed, 22 insertions, 21 deletions
diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh
index d9a72fae2d..2a7caf98de 100755
--- a/qa/pull-tester/rpc-tests.sh
+++ b/qa/pull-tester/rpc-tests.sh
@@ -34,6 +34,7 @@ testScripts=(
'signrawtransactions.py'
'walletbackup.py'
'nodehandling.py'
+ 'reindex.py'
);
testScriptsExt=(
'bipdersig-p2p.py'
@@ -45,7 +46,6 @@ testScriptsExt=(
'invalidateblock.py'
'keypool.py'
'receivedby.py'
- 'reindex.py'
'rpcbind_test.py'
# 'script_test.py'
'smartfees.py'
diff --git a/src/main.cpp b/src/main.cpp
index a3e43e0cc5..6c4cfe75aa 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2810,36 +2810,37 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
uint256 hash = block.GetHash();
BlockMap::iterator miSelf = mapBlockIndex.find(hash);
CBlockIndex *pindex = NULL;
- if (miSelf != mapBlockIndex.end()) {
- // Block header is already known.
- pindex = miSelf->second;
- if (ppindex)
- *ppindex = pindex;
- if (pindex->nStatus & BLOCK_FAILED_MASK)
- return state.Invalid(error("%s: block is marked invalid", __func__), 0, "duplicate");
- return true;
- }
+ if (hash != chainparams.GetConsensus().hashGenesisBlock) {
- if (!CheckBlockHeader(block, state))
- return false;
+ if (miSelf != mapBlockIndex.end()) {
+ // Block header is already known.
+ pindex = miSelf->second;
+ if (ppindex)
+ *ppindex = pindex;
+ if (pindex->nStatus & BLOCK_FAILED_MASK)
+ return state.Invalid(error("%s: block is marked invalid", __func__), 0, "duplicate");
+ return true;
+ }
- // Get prev block index
- CBlockIndex* pindexPrev = NULL;
- if (hash != chainparams.GetConsensus().hashGenesisBlock) {
+ if (!CheckBlockHeader(block, state))
+ return false;
+
+ // Get prev block index
+ CBlockIndex* pindexPrev = NULL;
BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
if (mi == mapBlockIndex.end())
return state.DoS(10, error("%s: prev block not found", __func__), 0, "bad-prevblk");
pindexPrev = (*mi).second;
if (pindexPrev->nStatus & BLOCK_FAILED_MASK)
return state.DoS(100, error("%s: prev block invalid", __func__), REJECT_INVALID, "bad-prevblk");
- }
- assert(pindexPrev);
- if (fCheckpointsEnabled && !CheckIndexAgainstCheckpoint(pindexPrev, state, chainparams, hash))
- return error("%s: CheckIndexAgainstCheckpoint(): %s", __func__, state.GetRejectReason().c_str());
- if (!ContextualCheckBlockHeader(block, state, pindexPrev))
- return false;
+ assert(pindexPrev);
+ if (fCheckpointsEnabled && !CheckIndexAgainstCheckpoint(pindexPrev, state, chainparams, hash))
+ return error("%s: CheckIndexAgainstCheckpoint(): %s", __func__, state.GetRejectReason().c_str());
+ if (!ContextualCheckBlockHeader(block, state, pindexPrev))
+ return false;
+ }
if (pindex == NULL)
pindex = AddToBlockIndex(block);