mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-06 14:19:59 -05:00
validation: Pass in chainstate to ::NotifyHeaderTip
[META] This commit should be followed up by removing the comments and assertions meant only to show that the change is correct.
This commit is contained in:
parent
9c300cc8b3
commit
2a696472a1
1 changed files with 7 additions and 6 deletions
|
@ -2770,7 +2770,7 @@ static SynchronizationState GetSynchronizationState(bool init)
|
||||||
return SynchronizationState::INIT_DOWNLOAD;
|
return SynchronizationState::INIT_DOWNLOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool NotifyHeaderTip() LOCKS_EXCLUDED(cs_main) {
|
static bool NotifyHeaderTip(CChainState& chainstate) LOCKS_EXCLUDED(cs_main) {
|
||||||
bool fNotify = false;
|
bool fNotify = false;
|
||||||
bool fInitialBlockDownload = false;
|
bool fInitialBlockDownload = false;
|
||||||
static CBlockIndex* pindexHeaderOld = nullptr;
|
static CBlockIndex* pindexHeaderOld = nullptr;
|
||||||
|
@ -2781,7 +2781,8 @@ static bool NotifyHeaderTip() LOCKS_EXCLUDED(cs_main) {
|
||||||
|
|
||||||
if (pindexHeader != pindexHeaderOld) {
|
if (pindexHeader != pindexHeaderOld) {
|
||||||
fNotify = true;
|
fNotify = true;
|
||||||
fInitialBlockDownload = ::ChainstateActive().IsInitialBlockDownload();
|
assert(std::addressof(::ChainstateActive()) == std::addressof(chainstate));
|
||||||
|
fInitialBlockDownload = chainstate.IsInitialBlockDownload();
|
||||||
pindexHeaderOld = pindexHeader;
|
pindexHeaderOld = pindexHeader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3664,7 +3665,7 @@ bool ChainstateManager::ProcessNewBlockHeaders(const std::vector<CBlockHeader>&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (NotifyHeaderTip()) {
|
if (NotifyHeaderTip(::ChainstateActive())) {
|
||||||
if (::ChainstateActive().IsInitialBlockDownload() && ppindex && *ppindex) {
|
if (::ChainstateActive().IsInitialBlockDownload() && ppindex && *ppindex) {
|
||||||
LogPrintf("Synchronizing blockheaders, height: %d (~%.2f%%)\n", (*ppindex)->nHeight, 100.0/((*ppindex)->nHeight+(GetAdjustedTime() - (*ppindex)->GetBlockTime()) / Params().GetConsensus().nPowTargetSpacing) * (*ppindex)->nHeight);
|
LogPrintf("Synchronizing blockheaders, height: %d (~%.2f%%)\n", (*ppindex)->nHeight, 100.0/((*ppindex)->nHeight+(GetAdjustedTime() - (*ppindex)->GetBlockTime()) / Params().GetConsensus().nPowTargetSpacing) * (*ppindex)->nHeight);
|
||||||
}
|
}
|
||||||
|
@ -3800,7 +3801,7 @@ bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NotifyHeaderTip();
|
NotifyHeaderTip(::ChainstateActive());
|
||||||
|
|
||||||
BlockValidationState state; // Only used to report errors, not invalidity - ignore it
|
BlockValidationState state; // Only used to report errors, not invalidity - ignore it
|
||||||
if (!::ChainstateActive().ActivateBestChain(state, chainparams, pblock))
|
if (!::ChainstateActive().ActivateBestChain(state, chainparams, pblock))
|
||||||
|
@ -4685,7 +4686,7 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NotifyHeaderTip();
|
NotifyHeaderTip(::ChainstateActive());
|
||||||
|
|
||||||
// Recursively process earlier encountered successors of this block
|
// Recursively process earlier encountered successors of this block
|
||||||
std::deque<uint256> queue;
|
std::deque<uint256> queue;
|
||||||
|
@ -4711,7 +4712,7 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
|
||||||
}
|
}
|
||||||
range.first++;
|
range.first++;
|
||||||
mapBlocksUnknownParent.erase(it);
|
mapBlocksUnknownParent.erase(it);
|
||||||
NotifyHeaderTip();
|
NotifyHeaderTip(::ChainstateActive());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue