MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / PreciousBlock

Method PreciousBlock

src/validation.cpp:2931–2958  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2929}
2930
2931bool 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}
2959bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIndex *pindex) {
2960 return g_chainstate.PreciousBlock(state, params, pindex);
2961}

Callers 1

PreciousBlockFunction · 0.80

Calls 5

ActivateBestChainFunction · 0.85
TipMethod · 0.45
eraseMethod · 0.45
IsValidMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected