validation: Use *this in CChainState::ActivateBestChainStep

This commit is contained in:
Carl Dong 2020-09-17 15:46:16 -04:00
parent 4744efc9ba
commit a9d28bcd8d

View file

@ -2725,6 +2725,7 @@ bool CChainState::ActivateBestChainStep(BlockValidationState& state, const CChai
{ {
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
AssertLockHeld(m_mempool.cs); AssertLockHeld(m_mempool.cs);
assert(std::addressof(::ChainstateActive()) == std::addressof(*this));
const CBlockIndex* pindexOldTip = m_chain.Tip(); const CBlockIndex* pindexOldTip = m_chain.Tip();
const CBlockIndex* pindexFork = m_chain.FindFork(pindexMostWork); const CBlockIndex* pindexFork = m_chain.FindFork(pindexMostWork);
@ -2736,7 +2737,7 @@ bool CChainState::ActivateBestChainStep(BlockValidationState& state, const CChai
if (!DisconnectTip(state, chainparams, &disconnectpool)) { if (!DisconnectTip(state, chainparams, &disconnectpool)) {
// This is likely a fatal error, but keep the mempool consistent, // This is likely a fatal error, but keep the mempool consistent,
// just in case. Only remove from the mempool in this case. // just in case. Only remove from the mempool in this case.
UpdateMempoolForReorg(::ChainstateActive(), m_mempool, disconnectpool, false); UpdateMempoolForReorg(*this, m_mempool, disconnectpool, false);
// If we're unable to disconnect a block during normal operation, // If we're unable to disconnect a block during normal operation,
// then that is a failure of our local system -- we should abort // then that is a failure of our local system -- we should abort
@ -2780,7 +2781,7 @@ bool CChainState::ActivateBestChainStep(BlockValidationState& state, const CChai
// A system error occurred (disk space, database error, ...). // A system error occurred (disk space, database error, ...).
// Make the mempool consistent with the current tip, just in case // Make the mempool consistent with the current tip, just in case
// any observers try to use it before shutdown. // any observers try to use it before shutdown.
UpdateMempoolForReorg(::ChainstateActive(), m_mempool, disconnectpool, false); UpdateMempoolForReorg(*this, m_mempool, disconnectpool, false);
return false; return false;
} }
} else { } else {
@ -2797,7 +2798,7 @@ bool CChainState::ActivateBestChainStep(BlockValidationState& state, const CChai
if (fBlocksDisconnected) { if (fBlocksDisconnected) {
// If any blocks were disconnected, disconnectpool may be non empty. Add // If any blocks were disconnected, disconnectpool may be non empty. Add
// any disconnected transactions back to the mempool. // any disconnected transactions back to the mempool.
UpdateMempoolForReorg(::ChainstateActive(), m_mempool, disconnectpool, true); UpdateMempoolForReorg(*this, m_mempool, disconnectpool, true);
} }
m_mempool.check(*this); m_mempool.check(*this);