mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 03:18:09 -03:00
validation: Send correct notification during snapshot completion
If AssumeUtxo background sync is completed in this ActivateBestChain() call, the GetRole() function returns "normal" instead of "background" for this chainstate. This would make the wallet (which ignores BlockConnected notifcation for the background chainstate) process it, change m_last_block_processed_height, and display an incorrect balance.
This commit is contained in:
parent
fc7b214847
commit
226d03dd61
1 changed files with 5 additions and 1 deletions
|
@ -3526,6 +3526,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)) {
|
||||
// A system error occurred
|
||||
return false;
|
||||
|
@ -3541,7 +3545,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue