diff options
author | TheCharlatan <seb.kung@gmail.com> | 2024-06-23 12:54:49 +0200 |
---|---|---|
committer | TheCharlatan <seb.kung@gmail.com> | 2024-07-08 21:19:22 +0200 |
commit | 39f9b80fba85d9818222c4d76e99ea1a804f5dda (patch) | |
tree | 3b42583dc4f698114325262089d143efc5339d45 /src/validation.cpp | |
parent | 3443943f86678eb27d9895f3871fcf3945eb1c4f (diff) |
refactor: De-globalize last notified header index
In future, users of the kernel library might run multiple chainstates in
parallel, or create and destroy multiple chainstates over the lifetime
of a process. Having static, mutable variables could lead to state
inconsistencies in these scenarios.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 812290021b..270ade3557 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 |