mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
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.
This commit is contained in:
parent
e0dc305727
commit
ea4fed9021
1 changed files with 4 additions and 3 deletions
|
@ -3644,6 +3644,7 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS
|
|||
// Exposed wrapper for AcceptBlockHeader
|
||||
bool ChainstateManager::ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, BlockValidationState& state, const CChainParams& chainparams, const CBlockIndex** ppindex)
|
||||
{
|
||||
assert(std::addressof(::ChainstateActive()) == std::addressof(ActiveChainstate()));
|
||||
AssertLockNotHeld(cs_main);
|
||||
{
|
||||
LOCK(cs_main);
|
||||
|
@ -3651,7 +3652,7 @@ bool ChainstateManager::ProcessNewBlockHeaders(const std::vector<CBlockHeader>&
|
|||
CBlockIndex *pindex = nullptr; // Use a temp pindex instead of ppindex to avoid a const_cast
|
||||
bool accepted = m_blockman.AcceptBlockHeader(
|
||||
header, state, chainparams, &pindex);
|
||||
::ChainstateActive().CheckBlockIndex(chainparams.GetConsensus());
|
||||
ActiveChainstate().CheckBlockIndex(chainparams.GetConsensus());
|
||||
|
||||
if (!accepted) {
|
||||
return false;
|
||||
|
@ -3661,8 +3662,8 @@ bool ChainstateManager::ProcessNewBlockHeaders(const std::vector<CBlockHeader>&
|
|||
}
|
||||
}
|
||||
}
|
||||
if (NotifyHeaderTip(::ChainstateActive())) {
|
||||
if (::ChainstateActive().IsInitialBlockDownload() && ppindex && *ppindex) {
|
||||
if (NotifyHeaderTip(ActiveChainstate())) {
|
||||
if (ActiveChainstate().IsInitialBlockDownload() && ppindex && *ppindex) {
|
||||
LogPrintf("Synchronizing blockheaders, height: %d (~%.2f%%)\n", (*ppindex)->nHeight, 100.0/((*ppindex)->nHeight+(GetAdjustedTime() - (*ppindex)->GetBlockTime()) / Params().GetConsensus().nPowTargetSpacing) * (*ppindex)->nHeight);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue