mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
[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.
This commit is contained in:
parent
1b3a11e126
commit
bedf246f1e
1 changed files with 8 additions and 4 deletions
|
@ -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++) {
|
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
|
||||||
const CTransaction& tx = it->GetTx();
|
const CTransaction& tx = it->GetTx();
|
||||||
LockPoints lp = it->GetLockPoints();
|
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);
|
CCoinsViewMemPool view_mempool(&active_chainstate.CoinsTip(), *this);
|
||||||
if (!CheckFinalTx(active_chainstate.m_chain.Tip(), tx, flags)
|
if (!CheckFinalTx(active_chainstate.m_chain.Tip(), tx, flags)
|
||||||
|| !CheckSequenceLocks(active_chainstate.m_chain.Tip(), view_mempool, tx, flags, &lp, validLP)) {
|
|| !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;
|
setEntries setAllRemoves;
|
||||||
for (txiter it : txToRemove) {
|
for (txiter it : txToRemove) {
|
||||||
CalculateDescendants(it, setAllRemoves);
|
CalculateDescendants(it, setAllRemoves);
|
||||||
}
|
}
|
||||||
RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG);
|
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)
|
void CTxMemPool::removeConflicts(const CTransaction &tx)
|
||||||
|
|
Loading…
Reference in a new issue