Skip to content

Commit 5257698

Browse files
committed
Change semantics of HaveCoinInCache to match HaveCoin
Previously it was possible for HaveCoinInCache to return true for a spent coin. It is more clear to keep the semantics the same. HaveCoinInCache is used for two reasons: - tracking coins we may want to uncache, in which case it is unlikely there would be spent coins we could uncache (not dirty) - optimistically checking whether we have already included a tx in the blockchain, in which case a spent coin is not a reliable indicator that we have.
1 parent 9c248e3 commit 5257698

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/coins.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ bool CCoinsViewCache::HaveCoin(const COutPoint &outpoint) const {
124124

125125
bool CCoinsViewCache::HaveCoinInCache(const COutPoint &outpoint) const {
126126
CCoinsMap::const_iterator it = cacheCoins.find(outpoint);
127-
return it != cacheCoins.end();
127+
return (it != cacheCoins.end() && !it->second.coin.IsSpent());
128128
}
129129

130130
uint256 CCoinsViewCache::GetBestBlock() const {

0 commit comments

Comments
 (0)