MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / ReconsiderBlock

Function ReconsiderBlock

src/main.cpp:593–621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

591}
592
593bool ReconsiderBlock(CValidationState &state, CBlockIndex *pIndex, bool children) {
594 AssertLockHeld(cs_main);
595
596 // Remove the invalidity flag from this block and all its descendants.
597 map<uint256, CBlockIndex *>::const_iterator it = mapBlockIndex.begin();
598 int32_t height = pIndex->height;
599 if (children) {
600 while (it != mapBlockIndex.end()) {
601 if (it->second->nStatus & BLOCK_FAILED_MASK && it->second->GetAncestor(height) == pIndex) {
602 if (!ReconsiderBlockIndex(it->second)) {
603 return ERRORMSG("reconsider block=%s index failed", it->second->GetIdString());
604 }
605 }
606 it++;
607 }
608 }
609
610 // Remove the invalidity flag from all ancestors too.
611 while (pIndex != nullptr) {
612 if (pIndex->nStatus & BLOCK_FAILED_MASK) {
613 if (!ReconsiderBlockIndex(pIndex)) {
614 return ERRORMSG("reconsider block=%s index failed", pIndex->GetIdString());
615 }
616 }
617 pIndex = pIndex->pprev;
618 }
619
620 return true;
621}
622
623void UpdateTime(CBlockHeader &block, const CBlockIndex *pIndexPrev) {
624 block.SetTime(max(pIndexPrev->GetMedianTimePast() + 1, GetAdjustedTime()));

Callers 1

reconsiderblockFunction · 0.85

Calls 5

ReconsiderBlockIndexFunction · 0.85
GetAncestorMethod · 0.80
GetIdStringMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected