aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorglozow <gloriajzhao@gmail.com>2021-11-30 11:15:58 +0000
committerglozow <gloriajzhao@gmail.com>2021-11-30 12:10:19 +0000
commitbedf246f1e2497a3641093c6e8fa11fb34dddac4 (patch)
tree0c949ec52314dc8419e15179450c5eea9643bcb8 /src/txmempool.cpp
parent1b3a11e126b258fba975ed7c452221608f2c5472 (diff)
[mempool] only update lockpoints for non-removed entries
Each entry's lockpoints are independent of one another, so there isn't any reason to update lockpoints for entries that will be removed. Separating the loops also allows us to move validation logic out and leave lockpoints in txmempool.
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r--src/txmempool.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 05b22bb39b..4cde0993a8 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -642,7 +642,7 @@ void CTxMemPool::removeForReorg(CChainState& active_chainstate, int flags)
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
const CTransaction& tx = it->GetTx();
LockPoints lp = it->GetLockPoints();
- bool validLP = TestLockPointValidity(active_chainstate.m_chain, &lp);
+ const bool validLP = TestLockPointValidity(active_chainstate.m_chain, &lp);
CCoinsViewMemPool view_mempool(&active_chainstate.CoinsTip(), *this);
if (!CheckFinalTx(active_chainstate.m_chain.Tip(), tx, flags)
|| !CheckSequenceLocks(active_chainstate.m_chain.Tip(), view_mempool, tx, flags, &lp, validLP)) {
@@ -663,15 +663,19 @@ void CTxMemPool::removeForReorg(CChainState& active_chainstate, int flags)
}
}
}
- if (!validLP) {
- mapTx.modify(it, update_lock_points(lp));
- }
}
setEntries setAllRemoves;
for (txiter it : txToRemove) {
CalculateDescendants(it, setAllRemoves);
}
RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG);
+ auto chain = active_chainstate.m_chain;
+ for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
+ LockPoints lp = it->GetLockPoints();
+ if (!TestLockPointValidity(chain, &lp)) {
+ mapTx.modify(it, update_lock_points(lp));
+ }
+ }
}
void CTxMemPool::removeConflicts(const CTransaction &tx)