Skip to content

Commit ea4fed9

Browse files
committed
validation: Use existing chainstate in ChainstateManager::ProcessNewBlockHeaders
[META] This commit should be followed up by removing the comments and assertions meant only to show that the change is correct.
1 parent e0dc305 commit ea4fed9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/validation.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3644,14 +3644,15 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS
36443644
// Exposed wrapper for AcceptBlockHeader
36453645
bool ChainstateManager::ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, BlockValidationState& state, const CChainParams& chainparams, const CBlockIndex** ppindex)
36463646
{
3647+
assert(std::addressof(::ChainstateActive()) == std::addressof(ActiveChainstate()));
36473648
AssertLockNotHeld(cs_main);
36483649
{
36493650
LOCK(cs_main);
36503651
for (const CBlockHeader& header : headers) {
36513652
CBlockIndex *pindex = nullptr; // Use a temp pindex instead of ppindex to avoid a const_cast
36523653
bool accepted = m_blockman.AcceptBlockHeader(
36533654
header, state, chainparams, &pindex);
3654-
::ChainstateActive().CheckBlockIndex(chainparams.GetConsensus());
3655+
ActiveChainstate().CheckBlockIndex(chainparams.GetConsensus());
36553656

36563657
if (!accepted) {
36573658
return false;
@@ -3661,8 +3662,8 @@ bool ChainstateManager::ProcessNewBlockHeaders(const std::vector<CBlockHeader>&
36613662
}
36623663
}
36633664
}
3664-
if (NotifyHeaderTip(::ChainstateActive())) {
3665-
if (::ChainstateActive().IsInitialBlockDownload() && ppindex && *ppindex) {
3665+
if (NotifyHeaderTip(ActiveChainstate())) {
3666+
if (ActiveChainstate().IsInitialBlockDownload() && ppindex && *ppindex) {
36663667
LogPrintf("Synchronizing blockheaders, height: %d (~%.2f%%)\n", (*ppindex)->nHeight, 100.0/((*ppindex)->nHeight+(GetAdjustedTime() - (*ppindex)->GetBlockTime()) / Params().GetConsensus().nPowTargetSpacing) * (*ppindex)->nHeight);
36673668
}
36683669
}

0 commit comments

Comments
 (0)