| 3740 | } |
| 3741 | |
| 3742 | void Chainstate::TryAddBlockIndexCandidate(CBlockIndex* pindex) |
| 3743 | { |
| 3744 | AssertLockHeld(cs_main); |
| 3745 | |
| 3746 | // Do not continue building a chainstate that is based on an invalid |
| 3747 | // snapshot. This is a belt-and-suspenders type of check because if an |
| 3748 | // invalid snapshot is loaded, the node will shut down to force a manual |
| 3749 | // intervention. But it is good to handle this case correctly regardless. |
| 3750 | if (m_assumeutxo == Assumeutxo::INVALID) { |
| 3751 | return; |
| 3752 | } |
| 3753 | |
| 3754 | // The block only is a candidate for the most-work-chain if it has the same |
| 3755 | // or more work than our current tip. |
| 3756 | if (m_chain.Tip() != nullptr && setBlockIndexCandidates.value_comp()(pindex, m_chain.Tip())) { |
| 3757 | return; |
| 3758 | } |
| 3759 | |
| 3760 | const CBlockIndex* target_block{TargetBlock()}; |
| 3761 | if (!target_block) { |
| 3762 | // If no specific target block, add all entries that have more |
| 3763 | // work than the tip. |
| 3764 | setBlockIndexCandidates.insert(pindex); |
| 3765 | } else { |
| 3766 | // If there is a target block, only consider connecting blocks |
| 3767 | // towards the target block. |
| 3768 | if (target_block->GetAncestor(pindex->nHeight) == pindex) { |
| 3769 | setBlockIndexCandidates.insert(pindex); |
| 3770 | } |
| 3771 | } |
| 3772 | } |
| 3773 | |
| 3774 | /** Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS). */ |
| 3775 | void ChainstateManager::ReceivedBlockTransactions(const CBlock& block, CBlockIndex* pindexNew, const FlatFilePos& pos) |
no test coverage detected