MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / InvalidChainFound

Method InvalidChainFound

src/validation.cpp:1970–1990  ·  view source on GitHub ↗

Called both upon regular invalid block discovery *and* InvalidateBlock

Source from the content-addressed store, hash-verified

1968
1969// Called both upon regular invalid block discovery *and* InvalidateBlock
1970void Chainstate::InvalidChainFound(CBlockIndex* pindexNew)
1971{
1972 AssertLockHeld(cs_main);
1973 if (!m_chainman.m_best_invalid || pindexNew->nChainWork > m_chainman.m_best_invalid->nChainWork) {
1974 m_chainman.m_best_invalid = pindexNew;
1975 }
1976 SetBlockFailureFlags(pindexNew);
1977 if (m_chainman.m_best_header != nullptr && m_chainman.m_best_header->GetAncestor(pindexNew->nHeight) == pindexNew) {
1978 m_chainman.RecalculateBestHeader();
1979 }
1980
1981 LogInfo("%s: invalid block=%s height=%d log2_work=%f date=%s", __func__,
1982 pindexNew->GetBlockHash().ToString(), pindexNew->nHeight,
1983 log(pindexNew->nChainWork.getdouble())/log(2.0), FormatISO8601DateTime(pindexNew->GetBlockTime()));
1984 CBlockIndex *tip = m_chain.Tip();
1985 assert (tip);
1986 LogInfo("%s: current best=%s height=%d log2_work=%f date=%s", __func__,
1987 tip->GetBlockHash().ToString(), m_chain.Height(), log(tip->nChainWork.getdouble())/log(2.0),
1988 FormatISO8601DateTime(tip->GetBlockTime()));
1989 CheckForkWarningConditions();
1990}
1991
1992// Same as InvalidChainFound, above, except not called directly from InvalidateBlock,
1993// which does its own setBlockIndexCandidates management.

Callers

nothing calls this directly

Calls 9

FormatISO8601DateTimeFunction · 0.85
RecalculateBestHeaderMethod · 0.80
getdoubleMethod · 0.80
HeightMethod · 0.80
GetAncestorMethod · 0.45
ToStringMethod · 0.45
GetBlockHashMethod · 0.45
GetBlockTimeMethod · 0.45
TipMethod · 0.45

Tested by

no test coverage detected