diff options
author | glozow <gzhao408@berkeley.edu> | 2021-02-11 09:36:20 -0800 |
---|---|---|
committer | glozow <gzhao408@berkeley.edu> | 2021-05-20 21:34:31 +0100 |
commit | 42cf8b25df07c45562b7210e0e15c3fd5edb2c11 (patch) | |
tree | 4de5e6b16a997889faf3a055f6037b5e5f68ffc9 /src/txmempool.cpp | |
parent | 710c8ba82953c5fdb7c3c8c9ad6ecf0fd88dface (diff) |
[validation] make CheckSequenceLocks context-free
Allow CheckSequenceLocks to use heights and coins from any CoinsView and
CBlockIndex provided. This means that CheckSequenceLocks() doesn't need
to hold the mempool lock or cs_main. The caller is responsible for
ensuring the CoinsView and CBlockIndex are consistent before passing
them in. The typical usage is still to create a CCoinsViewMemPool from
the mempool and grab the CBlockIndex from the chainstate tip.
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r-- | src/txmempool.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 5957637e81..8bd6e2a6a6 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -515,7 +515,9 @@ void CTxMemPool::removeForReorg(CChainState& active_chainstate, int flags) LockPoints lp = it->GetLockPoints(); assert(std::addressof(::ChainstateActive()) == std::addressof(active_chainstate)); bool validLP = TestLockPointValidity(active_chainstate.m_chain, &lp); - if (!CheckFinalTx(active_chainstate.m_chain.Tip(), tx, flags) || !CheckSequenceLocks(active_chainstate, *this, tx, flags, &lp, validLP)) { + CCoinsViewMemPool viewMempool(&active_chainstate.CoinsTip(), *this); + if (!CheckFinalTx(active_chainstate.m_chain.Tip(), tx, flags) + || !CheckSequenceLocks(active_chainstate.m_chain.Tip(), viewMempool, tx, flags, &lp, validLP)) { // Note if CheckSequenceLocks fails the LockPoints may still be invalid // So it's critical that we remove the tx and not depend on the LockPoints. txToRemove.insert(it); |