aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-04-20 13:47:05 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-04-20 13:47:14 +0200
commit2bc6332df843bc90cf1a582141c916b5de02d07a (patch)
tree71c4c9db2c3d4f43b6edd29de83bfe6d4f1b2d49
parent6a0bcb80e4ce380a39f81b4fb01150d5b7e6cdf7 (diff)
parentc1ecee8f723c2635fbd51100fa09acdb0cbec8a0 (diff)
Merge pull request #6010
c1ecee8 Set nSequenceId when a block is fully linked (Suhas Daftuar)
-rw-r--r--src/main.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp
index c6a936c5cc..4352c719a1 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2350,10 +2350,6 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
pindexNew->nUndoPos = 0;
pindexNew->nStatus |= BLOCK_HAVE_DATA;
pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS);
- {
- LOCK(cs_nBlockSequenceId);
- pindexNew->nSequenceId = nBlockSequenceId++;
- }
setDirtyBlockIndex.insert(pindexNew);
if (pindexNew->pprev == NULL || pindexNew->pprev->nChainTx) {
@@ -2366,6 +2362,10 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
CBlockIndex *pindex = queue.front();
queue.pop_front();
pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx;
+ {
+ LOCK(cs_nBlockSequenceId);
+ pindex->nSequenceId = nBlockSequenceId++;
+ }
if (chainActive.Tip() == NULL || !setBlockIndexCandidates.value_comp()(pindex, chainActive.Tip())) {
setBlockIndexCandidates.insert(pindex);
}
@@ -3282,6 +3282,7 @@ void static CheckBlockIndex()
// HAVE_DATA is equivalent to VALID_TRANSACTIONS and equivalent to nTx > 0 (we stored the number of transactions in the block)
assert(!(pindex->nStatus & BLOCK_HAVE_DATA) == (pindex->nTx == 0));
assert(((pindex->nStatus & BLOCK_VALID_MASK) >= BLOCK_VALID_TRANSACTIONS) == (pindex->nTx > 0));
+ if (pindex->nChainTx == 0) assert(pindex->nSequenceId == 0); // nSequenceId can't be set for blocks that aren't linked
// All parents having data is equivalent to all parents being VALID_TRANSACTIONS, which is equivalent to nChainTx being set.
assert((pindexFirstMissing != NULL) == (pindex->nChainTx == 0)); // nChainTx == 0 is used to signal that all parent block's transaction data is available.
assert((pindexFirstNotTransactionsValid != NULL) == (pindex->nChainTx == 0));