File tree Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -495,7 +495,7 @@ class CRegTestParams : public CChainParams
495
495
{
496
496
.height = 110 ,
497
497
.hash_serialized = AssumeutxoHash{uint256S (" 0x1ebbf5850204c0bdb15bf030f47c7fe91d45c44c712697e4509ba67adb01c618" )},
498
- .nChainTx = 110 ,
498
+ .nChainTx = 111 ,
499
499
.blockhash = uint256S (" 0x696e92821f65549c7ee134edceeeeaaa4105647a3c4fd9f298c0aec0ab50425c" )
500
500
},
501
501
{
Original file line number Diff line number Diff line change @@ -138,11 +138,11 @@ BOOST_AUTO_TEST_CASE(test_assumeutxo)
138
138
139
139
const auto out110 = *params->AssumeutxoForHeight (110 );
140
140
BOOST_CHECK_EQUAL (out110.hash_serialized .ToString (), " 1ebbf5850204c0bdb15bf030f47c7fe91d45c44c712697e4509ba67adb01c618" );
141
- BOOST_CHECK_EQUAL (out110.nChainTx , 110U );
141
+ BOOST_CHECK_EQUAL (out110.nChainTx , 111U );
142
142
143
143
const auto out110_2 = *params->AssumeutxoForBlockhash (uint256S (" 0x696e92821f65549c7ee134edceeeeaaa4105647a3c4fd9f298c0aec0ab50425c" ));
144
144
BOOST_CHECK_EQUAL (out110_2.hash_serialized .ToString (), " 1ebbf5850204c0bdb15bf030f47c7fe91d45c44c712697e4509ba67adb01c618" );
145
- BOOST_CHECK_EQUAL (out110_2.nChainTx , 110U );
145
+ BOOST_CHECK_EQUAL (out110_2.nChainTx , 111U );
146
146
}
147
147
148
148
BOOST_AUTO_TEST_SUITE_END ()
Original file line number Diff line number Diff line change @@ -4844,10 +4844,14 @@ void ChainstateManager::CheckBlockIndex()
4844
4844
CBlockIndex* pindexFirstAssumeValid = nullptr ; // Oldest ancestor of pindex which has BLOCK_ASSUMED_VALID
4845
4845
while (pindex != nullptr ) {
4846
4846
nNodes++;
4847
- if (pindex->pprev && pindex->nTx > 0 ) {
4848
- // nChainTx should increase monotonically
4849
- assert (pindex->pprev ->nChainTx <= pindex->nChainTx );
4850
- }
4847
+ // Make sure nChainTx sum is correctly computed.
4848
+ unsigned int prev_chain_tx = pindex->pprev ? pindex->pprev ->nChainTx : 0 ;
4849
+ assert ((pindex->nChainTx == pindex->nTx + prev_chain_tx)
4850
+ // For testing, allow transaction counts to be completely unset.
4851
+ || (pindex->nChainTx == 0 && pindex->nTx == 0 )
4852
+ // For testing, allow this nChainTx to be unset if previous is also unset.
4853
+ || (pindex->nChainTx == 0 && prev_chain_tx == 0 && pindex->pprev ));
4854
+
4851
4855
if (pindexFirstAssumeValid == nullptr && pindex->nStatus & BLOCK_ASSUMED_VALID) pindexFirstAssumeValid = pindex;
4852
4856
if (pindexFirstInvalid == nullptr && pindex->nStatus & BLOCK_FAILED_VALID) pindexFirstInvalid = pindex;
4853
4857
if (pindexFirstMissing == nullptr && !(pindex->nStatus & BLOCK_HAVE_DATA)) {
You can’t perform that action at this time.
0 commit comments