Skip to content

Commit 150ca00

Browse files
committed
merge bitcoin#23683: valid but different LockPoints after a reorg
1 parent e85862b commit 150ca00

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/txmempool.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,6 @@ struct update_fee_delta
7272
int64_t feeDelta;
7373
};
7474

75-
struct update_lock_points
76-
{
77-
explicit update_lock_points(const LockPoints& _lp) : lp(_lp) { }
78-
79-
void operator() (CTxMemPoolEntry &e) { e.UpdateLockPoints(lp); }
80-
81-
private:
82-
const LockPoints& lp;
83-
};
84-
8575
bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp)
8676
{
8777
AssertLockHeld(cs_main);
@@ -892,10 +882,7 @@ void CTxMemPool::removeForReorg(CChain& chain, std::function<bool(txiter)> check
892882
}
893883
RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG);
894884
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
895-
const LockPoints lp{it->GetLockPoints()};
896-
if (!TestLockPointValidity(chain, lp)) {
897-
mapTx.modify(it, update_lock_points(lp));
898-
}
885+
assert(TestLockPointValidity(chain, it->GetLockPoints()));
899886
}
900887
}
901888

src/txmempool.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,16 @@ class CompareTxMemPoolEntryByAncestorFee
308308
}
309309
};
310310

311+
struct update_lock_points
312+
{
313+
explicit update_lock_points(const LockPoints& _lp) : lp(_lp) { }
314+
315+
void operator() (CTxMemPoolEntry &e) { e.UpdateLockPoints(lp); }
316+
317+
private:
318+
const LockPoints& lp;
319+
};
320+
311321
// Multi_index tag names
312322
struct descendant_score {};
313323
struct entry_time {};

src/validation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ void CChainState::MaybeUpdateMempoolForReorg(
399399
}
400400
}
401401
}
402+
// CheckSequenceLocks updates lp. Update the mempool entry LockPoints.
403+
if (!validLP) m_mempool->mapTx.modify(it, update_lock_points(lp));
402404
return should_remove;
403405
};
404406

0 commit comments

Comments
 (0)