Skip to content

Commit 2d8860e

Browse files
committed
Fix removeForReorg to use MedianTimePast
1 parent b7fa4aa commit 2d8860e

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2570,7 +2570,7 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
25702570
}
25712571

25722572
if (fBlocksDisconnected) {
2573-
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1);
2573+
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
25742574
mempool.TrimToSize(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000);
25752575
}
25762576
mempool.check(pcoinsTip);
@@ -2681,7 +2681,7 @@ bool InvalidateBlock(CValidationState& state, const Consensus::Params& consensus
26812681
// ActivateBestChain considers blocks already in chainActive
26822682
// unconditionally valid already, so force disconnect away from it.
26832683
if (!DisconnectTip(state, consensusParams)) {
2684-
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1);
2684+
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
26852685
return false;
26862686
}
26872687
}
@@ -2699,7 +2699,7 @@ bool InvalidateBlock(CValidationState& state, const Consensus::Params& consensus
26992699
}
27002700

27012701
InvalidChainFound(pindex);
2702-
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1);
2702+
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
27032703
return true;
27042704
}
27052705

src/txmempool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,14 +481,14 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list<CTransaction>& rem
481481
}
482482
}
483483

484-
void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight)
484+
void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags)
485485
{
486486
// Remove transactions spending a coinbase which are now immature and no-longer-final transactions
487487
LOCK(cs);
488488
list<CTransaction> transactionsToRemove;
489489
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
490490
const CTransaction& tx = it->GetTx();
491-
if (!IsFinalTx(tx, nMemPoolHeight, GetAdjustedTime())) {
491+
if (!CheckFinalTx(tx, flags)) {
492492
transactionsToRemove.push_back(tx);
493493
} else if (it->GetSpendsCoinbase()) {
494494
BOOST_FOREACH(const CTxIn& txin, tx.vin) {

src/txmempool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ class CTxMemPool
379379
bool addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, setEntries &setAncestors, bool fCurrentEstimate = true);
380380

381381
void remove(const CTransaction &tx, std::list<CTransaction>& removed, bool fRecursive = false);
382-
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight);
382+
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags);
383383
void removeConflicts(const CTransaction &tx, std::list<CTransaction>& removed);
384384
void removeForBlock(const std::vector<CTransaction>& vtx, unsigned int nBlockHeight,
385385
std::list<CTransaction>& conflicts, bool fCurrentEstimate = true);

0 commit comments

Comments
 (0)