Skip to content

Commit ad08d0b

Browse files
committed
Bugfix: make CCoinsViewMemPool support pruned entries in underlying cache
1 parent cdb4193 commit ad08d0b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/txmempool.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,14 +602,15 @@ void CTxMemPool::ClearPrioritisation(const uint256 hash)
602602
CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView &baseIn, CTxMemPool &mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { }
603603

604604
bool CCoinsViewMemPool::GetCoins(const uint256 &txid, CCoins &coins) {
605-
if (base->GetCoins(txid, coins))
606-
return true;
605+
// If an entry in the mempool exists, always return that one, as it's guaranteed to never
606+
// conflict with the underlying cache, and it cannot have pruned entries (as it contains full)
607+
// transactions. First checking the underlying cache risks returning a pruned entry instead.
607608
CTransaction tx;
608609
if (mempool.lookup(txid, tx)) {
609610
coins = CCoins(tx, MEMPOOL_HEIGHT);
610611
return true;
611612
}
612-
return false;
613+
return (base->GetCoins(txid, coins) && !coins.IsPruned());
613614
}
614615

615616
bool CCoinsViewMemPool::HaveCoins(const uint256 &txid) {

0 commit comments

Comments
 (0)