From 1e59acdf17309f567c370885f0cf02605e2baa58 Mon Sep 17 00:00:00 2001 From: James O'Beirne Date: Thu, 24 Aug 2023 16:51:16 -0400 Subject: [PATCH] validation: only call UpdatedBlockTip for active chainstate This notification isn't needed for background chainstates. `kernel::Notifications::blockTip` are also skipped. --- src/validation.cpp | 2 +- src/validationinterface.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 9a543d3a389..4873eb964ca 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3263,7 +3263,7 @@ bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr< // Notify external listeners about the new tip. // Enqueue while holding cs_main to ensure that UpdatedBlockTip is called in the order in which blocks are connected - if (pindexFork != pindexNewTip) { + if (this == &m_chainman.ActiveChainstate() && pindexFork != pindexNewTip) { // Notify ValidationInterface subscribers GetMainSignals().UpdatedBlockTip(pindexNewTip, pindexFork, still_in_ibd); diff --git a/src/validationinterface.h b/src/validationinterface.h index 8c20cc8ffbf..5bdd7e01238 100644 --- a/src/validationinterface.h +++ b/src/validationinterface.h @@ -87,7 +87,7 @@ protected: * but may not be called on every intermediate tip. If the latter behavior is desired, * subscribe to BlockConnected() instead. * - * Called on a background thread. + * Called on a background thread. Only called for the active chainstate. */ virtual void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {} /**