Merge df5c643f92 into merged_master (Bitcoin PR bitcoin/bitcoin#31556)

This commit is contained in:
ivanlele 2026-04-09 12:54:35 +00:00
commit 5a8d695fd6
No known key found for this signature in database
2 changed files with 19 additions and 3 deletions

View file

@ -4013,6 +4013,10 @@ bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr<
bool fInvalidFound = false;
std::shared_ptr<const CBlock> nullBlockPtr;
// BlockConnected signals must be sent for the original role;
// in case snapshot validation is completed during ActivateBestChainStep, the
// result of GetRole() changes from BACKGROUND to NORMAL.
const ChainstateRole chainstate_role{this->GetRole()};
if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : nullBlockPtr, fInvalidFound, connectTrace, fStall)) {
// A system error occurred
return false;
@ -4028,7 +4032,7 @@ bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr<
for (const PerBlockConnectTrace& trace : connectTrace.GetBlocksConnected()) {
assert(trace.pblock && trace.pindex);
if (m_chainman.m_options.signals) {
m_chainman.m_options.signals->BlockConnected(this->GetRole(), trace.pblock, trace.pindex);
m_chainman.m_options.signals->BlockConnected(chainstate_role, trace.pblock, trace.pindex);
}
}