| 2929 | } |
| 2930 | |
| 2931 | bool CChainState::PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIndex *pindex) |
| 2932 | { |
| 2933 | { |
| 2934 | LOCK(cs_main); |
| 2935 | if (pindex->nChainWork < chainActive.Tip()->nChainWork) { |
| 2936 | // Nothing to do, this block is not at the tip. |
| 2937 | return true; |
| 2938 | } |
| 2939 | if (chainActive.Tip()->nChainWork > nLastPreciousChainwork) { |
| 2940 | // The chain has been extended since the last call, reset the counter. |
| 2941 | nBlockReverseSequenceId = -1; |
| 2942 | } |
| 2943 | nLastPreciousChainwork = chainActive.Tip()->nChainWork; |
| 2944 | setBlockIndexCandidates.erase(pindex); |
| 2945 | pindex->nSequenceId = nBlockReverseSequenceId; |
| 2946 | if (nBlockReverseSequenceId > std::numeric_limits<int32_t>::min()) { |
| 2947 | // We can't keep reducing the counter if somebody really wants to |
| 2948 | // call preciousblock 2**31-1 times on the same set of tips... |
| 2949 | nBlockReverseSequenceId--; |
| 2950 | } |
| 2951 | if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS) && pindex->nChainTx) { |
| 2952 | setBlockIndexCandidates.insert(pindex); |
| 2953 | PruneBlockIndexCandidates(); |
| 2954 | } |
| 2955 | } |
| 2956 | |
| 2957 | return ActivateBestChain(state, params, std::shared_ptr<const CBlock>()); |
| 2958 | } |
| 2959 | bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIndex *pindex) { |
| 2960 | return g_chainstate.PreciousBlock(state, params, pindex); |
| 2961 | } |
no test coverage detected