MCPcopy Create free account
hub / github.com/ElementsProject/elements / InvalidChainFound

Method InvalidChainFound

src/validation.cpp:1636–1655  ·  view source on GitHub ↗

Called both upon regular invalid block discovery *and* InvalidateBlock

Source from the content-addressed store, hash-verified

1634
1635// Called both upon regular invalid block discovery *and* InvalidateBlock
1636void CChainState::InvalidChainFound(CBlockIndex* pindexNew)
1637{
1638 AssertLockHeld(cs_main);
1639 if (!m_chainman.m_best_invalid || pindexNew->nChainWork > m_chainman.m_best_invalid->nChainWork) {
1640 m_chainman.m_best_invalid = pindexNew;
1641 }
1642 if (pindexBestHeader != nullptr && pindexBestHeader->GetAncestor(pindexNew->nHeight) == pindexNew) {
1643 pindexBestHeader = m_chain.Tip();
1644 }
1645
1646 LogPrintf("%s: invalid block=%s height=%d date=%s\n", __func__,
1647 pindexNew->GetBlockHash().ToString(), pindexNew->nHeight,
1648 FormatISO8601DateTime(pindexNew->GetBlockTime()));
1649 CBlockIndex *tip = m_chain.Tip();
1650 assert (tip);
1651 LogPrintf("%s: current best=%s height=%d date=%s\n", __func__,
1652 tip->GetBlockHash().ToString(), m_chain.Height(),
1653 FormatISO8601DateTime(tip->GetBlockTime()));
1654 CheckForkWarningConditions();
1655}
1656
1657// Same as InvalidChainFound, above, except not called directly from InvalidateBlock,
1658// which does its own setBlockIndexCandidates management.

Callers

nothing calls this directly

Calls 6

GetAncestorMethod · 0.80
HeightMethod · 0.80
TipMethod · 0.45
ToStringMethod · 0.45
GetBlockHashMethod · 0.45
GetBlockTimeMethod · 0.45

Tested by

no test coverage detected