diff options
author | James O'Beirne <james.obeirne@pm.me> | 2023-05-05 18:27:56 -0400 |
---|---|---|
committer | James O'Beirne <james.obeirne@pm.me> | 2023-09-30 06:40:17 -0400 |
commit | 9511fb3616b7bbe1d0d2f54a45ea0a650ba0367b (patch) | |
tree | eca9fd77d46e601143f690ad50096807eee59c0a /src/validation.cpp | |
parent | 7fcd21544a333ffdf1910b65c573579860be6a36 (diff) |
validation: assumeutxo: swap m_mempool on snapshot activation
Otherwise we will not receive transactions during background sync until
restart.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 01081011b0..d72b017cc4 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5268,6 +5268,12 @@ bool ChainstateManager::ActivateSnapshot( const bool chaintip_loaded = m_snapshot_chainstate->LoadChainTip(); assert(chaintip_loaded); + // Transfer possession of the mempool to the snapshot chianstate. + // Mempool is empty at this point because we're still in IBD. + Assert(m_active_chainstate->m_mempool->size() == 0); + Assert(!m_snapshot_chainstate->m_mempool); + m_snapshot_chainstate->m_mempool = m_active_chainstate->m_mempool; + m_active_chainstate->m_mempool = nullptr; m_active_chainstate = m_snapshot_chainstate.get(); m_blockman.m_snapshot_height = this->GetSnapshotBaseHeight(); @@ -5747,16 +5753,22 @@ bool ChainstateManager::DetectSnapshotChainstate(CTxMemPool* mempool) LogPrintf("[snapshot] detected active snapshot chainstate (%s) - loading\n", fs::PathToString(*path)); - this->ActivateExistingSnapshot(mempool, *base_blockhash); + this->ActivateExistingSnapshot(*base_blockhash); return true; } -Chainstate& ChainstateManager::ActivateExistingSnapshot(CTxMemPool* mempool, uint256 base_blockhash) +Chainstate& ChainstateManager::ActivateExistingSnapshot(uint256 base_blockhash) { assert(!m_snapshot_chainstate); m_snapshot_chainstate = - std::make_unique<Chainstate>(mempool, m_blockman, *this, base_blockhash); + std::make_unique<Chainstate>(nullptr, m_blockman, *this, base_blockhash); LogPrintf("[snapshot] switching active chainstate to %s\n", m_snapshot_chainstate->ToString()); + + // Mempool is empty at this point because we're still in IBD. + Assert(m_active_chainstate->m_mempool->size() == 0); + Assert(!m_snapshot_chainstate->m_mempool); + m_snapshot_chainstate->m_mempool = m_active_chainstate->m_mempool; + m_active_chainstate->m_mempool = nullptr; m_active_chainstate = m_snapshot_chainstate.get(); return *m_snapshot_chainstate; } |