diff --git a/src/validation.cpp b/src/validation.cpp index 812290021b4..270ade3557b 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3409,16 +3409,15 @@ static bool NotifyHeaderTip(ChainstateManager& chainman) LOCKS_EXCLUDED(cs_main) { bool fNotify = false; bool fInitialBlockDownload = false; - static CBlockIndex* pindexHeaderOld = nullptr; CBlockIndex* pindexHeader = nullptr; { LOCK(cs_main); pindexHeader = chainman.m_best_header; - if (pindexHeader != pindexHeaderOld) { + if (pindexHeader != chainman.m_last_notified_header) { fNotify = true; fInitialBlockDownload = chainman.IsInitialBlockDownload(); - pindexHeaderOld = pindexHeader; + chainman.m_last_notified_header = pindexHeader; } } // Send block tip changed notifications without cs_main diff --git a/src/validation.h b/src/validation.h index 92377aa5fc9..ea4ec842423 100644 --- a/src/validation.h +++ b/src/validation.h @@ -1063,6 +1063,9 @@ public: /** Best header we've seen so far (used for getheaders queries' starting points). */ CBlockIndex* m_best_header GUARDED_BY(::cs_main){nullptr}; + /** The last header for which a headerTip notification was issued. */ + CBlockIndex* m_last_notified_header GUARDED_BY(::cs_main){nullptr}; + //! The total number of bytes available for us to use across all in-memory //! coins caches. This will be split somehow across chainstates. int64_t m_total_coinstip_cache{0};