Fix disconnect block info status
Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
This commit is contained in:
parent
c9637f8e1c
commit
f71391920b
2 changed files with 21 additions and 4 deletions
|
@ -165,8 +165,8 @@ BOOST_AUTO_TEST_CASE(processnewblock_signals_ordering)
|
||||||
// to make sure that eventually we process the full chain - do it here
|
// to make sure that eventually we process the full chain - do it here
|
||||||
for (auto block : blocks) {
|
for (auto block : blocks) {
|
||||||
if (block->vtx.size() == 1) {
|
if (block->vtx.size() == 1) {
|
||||||
bool processed = ProcessNewBlock(Params(), block, true, &ignored, false);
|
ProcessNewBlock(Params(), block, true, &ignored, false);
|
||||||
assert(processed);
|
assert(!ignored);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2600,8 +2600,8 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
|
|
||||||
const CBlockIndex *pindexOldTip = chainActive.Tip();
|
auto pindexOldTip = chainActive.Tip();
|
||||||
const CBlockIndex *pindexFork = chainActive.FindFork(pindexMostWork);
|
auto pindexFork = chainActive.FindFork(pindexMostWork);
|
||||||
|
|
||||||
// Disconnect active blocks which are no longer in the best chain.
|
// Disconnect active blocks which are no longer in the best chain.
|
||||||
bool fBlocksDisconnected = false;
|
bool fBlocksDisconnected = false;
|
||||||
|
@ -2616,6 +2616,23 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
|
||||||
fBlocksDisconnected = true;
|
fBlocksDisconnected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now mark the blocks we just disconnected as descendants invalid
|
||||||
|
// (note this may not be all descendants).
|
||||||
|
if (fBlocksDisconnected) {
|
||||||
|
auto invalid_walk_tip = pindexOldTip;
|
||||||
|
while (invalid_walk_tip != pindexFork) {
|
||||||
|
auto prev = invalid_walk_tip->pprev;
|
||||||
|
if (prev == pindexFork) {
|
||||||
|
InvalidBlockFound(invalid_walk_tip, state);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
invalid_walk_tip->nStatus |= BLOCK_FAILED_CHILD;
|
||||||
|
setDirtyBlockIndex.insert(invalid_walk_tip);
|
||||||
|
setBlockIndexCandidates.erase(invalid_walk_tip);
|
||||||
|
invalid_walk_tip = prev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Build list of new blocks to connect.
|
// Build list of new blocks to connect.
|
||||||
std::vector<CBlockIndex*> vpindexToConnect;
|
std::vector<CBlockIndex*> vpindexToConnect;
|
||||||
bool fContinue = true;
|
bool fContinue = true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue