Delete all entries in setBlockIndexCandidates that are worse than the current tip. */
| 2697 | |
| 2698 | /** Delete all entries in setBlockIndexCandidates that are worse than the current tip. */ |
| 2699 | void CChainState::PruneBlockIndexCandidates() { |
| 2700 | // Note that we can't delete the current block itself, as we may need to return to it later in case a |
| 2701 | // reorganization to a better block fails. |
| 2702 | std::set<CBlockIndex*, CBlockIndexWorkComparator>::iterator it = setBlockIndexCandidates.begin(); |
| 2703 | while (it != setBlockIndexCandidates.end() && setBlockIndexCandidates.value_comp()(*it, chainActive.Tip())) { |
| 2704 | setBlockIndexCandidates.erase(it++); |
| 2705 | } |
| 2706 | // Either the current tip or a successor of it we're working towards is left in setBlockIndexCandidates. |
| 2707 | assert(!setBlockIndexCandidates.empty()); |
| 2708 | } |
| 2709 | |
| 2710 | /** |
| 2711 | * Try to make some progress towards making pindexMostWork the active block. |