mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
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.
This commit is contained in:
parent
3443943f86
commit
39f9b80fba
2 changed files with 5 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue