aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Wuille <sipa@ulyssis.org>2014-07-23 15:28:45 +0200
committerPieter Wuille <sipa@ulyssis.org>2014-07-23 15:40:52 +0200
commitad08d0b95bd8e35b74f5f36cfa3c48ae9583b28c (patch)
treefbba1503e4b787381dc44f7d38befd204bfd8176
parentcdb4193a317e1360be806eed9838010e642b6388 (diff)
Bugfix: make CCoinsViewMemPool support pruned entries in underlying cache
-rw-r--r--src/txmempool.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index ebb1369e31..164e2741a2 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -602,14 +602,15 @@ void CTxMemPool::ClearPrioritisation(const uint256 hash)
CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView &baseIn, CTxMemPool &mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { }
bool CCoinsViewMemPool::GetCoins(const uint256 &txid, CCoins &coins) {
- if (base->GetCoins(txid, coins))
- return true;
+ // If an entry in the mempool exists, always return that one, as it's guaranteed to never
+ // conflict with the underlying cache, and it cannot have pruned entries (as it contains full)
+ // transactions. First checking the underlying cache risks returning a pruned entry instead.
CTransaction tx;
if (mempool.lookup(txid, tx)) {
coins = CCoins(tx, MEMPOOL_HEIGHT);
return true;
}
- return false;
+ return (base->GetCoins(txid, coins) && !coins.IsPruned());
}
bool CCoinsViewMemPool::HaveCoins(const uint256 &txid) {