| 591 | } |
| 592 | |
| 593 | bool 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 | |
| 623 | void UpdateTime(CBlockHeader &block, const CBlockIndex *pIndexPrev) { |
| 624 | block.SetTime(max(pIndexPrev->GetMedianTimePast() + 1, GetAdjustedTime())); |
no test coverage detected