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

Method UpdateTip

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

Source from the content-addressed store, hash-verified

2894}
2895
2896void Chainstate::UpdateTip(const CBlockIndex* pindexNew)
2897{
2898 AssertLockHeld(::cs_main);
2899 const auto& coins_tip = this->CoinsTip();
2900
2901 // The remainder of the function isn't relevant if we are not acting on
2902 // the active chainstate, so return if need be.
2903 if (this != &m_chainman.ActiveChainstate()) {
2904 // Only log every so often so that we don't bury log messages at the tip.
2905 constexpr int BACKGROUND_LOG_INTERVAL = 2000;
2906 if (pindexNew->nHeight % BACKGROUND_LOG_INTERVAL == 0) {
2907 UpdateTipLog(m_chainman, coins_tip, pindexNew, __func__, "[background validation] ", "", /*background_validation=*/true);
2908 }
2909 return;
2910 }
2911
2912 // New best block
2913 if (m_mempool) {
2914 m_mempool->AddTransactionsUpdated(1);
2915 }
2916
2917 std::vector<bilingual_str> warning_messages;
2918 if (!m_chainman.IsInitialBlockDownload()) {
2919 auto bits = m_chainman.m_versionbitscache.CheckUnknownActivations(pindexNew, m_chainman.GetParams());
2920 for (auto [bit, active] : bits) {
2921 const bilingual_str warning = strprintf(_("Unknown new rules activated (versionbit %i)"), bit);
2922 if (active) {
2923 m_chainman.GetNotifications().warningSet(kernel::Warning::UNKNOWN_NEW_RULES_ACTIVATED, warning);
2924 } else {
2925 warning_messages.push_back(warning);
2926 }
2927 }
2928 }
2929 UpdateTipLog(m_chainman, coins_tip, pindexNew, __func__, "",
2930 util::Join(warning_messages, Untranslated(", ")).original, /*background_validation=*/false);
2931}
2932
2933/** Disconnect m_chain's tip.
2934 * After calling, the mempool will be in an inconsistent state, with

Callers

nothing calls this directly

Calls 8

_Function · 0.85
JoinFunction · 0.85
UntranslatedFunction · 0.85
warningSetMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected