aboutsummaryrefslogtreecommitdiff
path: root/src/coins.cpp
diff options
context:
space:
mode:
authorRussell Yanofsky <[email protected]>2016-12-09 12:28:22 -0500
committerRussell Yanofsky <[email protected]>2017-01-04 14:56:17 -0500
commitdd44ea39bb6e1e2a244630909647ea7fbb052941 (patch)
tree08d82a140c158aca5a47f6c35c92f3e8beaa8d5e /src/coins.cpp
parentMerge #9107: Safer modify new coins (diff)
downloaddiscoin-dd44ea39bb6e1e2a244630909647ea7fbb052941.tar.xz
discoin-dd44ea39bb6e1e2a244630909647ea7fbb052941.zip
Check FRESH validity in CCoinsViewCache::BatchWrite
Diffstat (limited to 'src/coins.cpp')
-rw-r--r--src/coins.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/coins.cpp b/src/coins.cpp
index 68f32a9da..4d0e4bc0a 100644
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -207,6 +207,13 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlockIn
entry.flags |= CCoinsCacheEntry::FRESH;
}
} else {
+ // Assert that the child cache entry was not marked FRESH if the
+ // parent cache entry has unspent outputs. If this ever happens,
+ // it means the FRESH flag was misapplied and there is a logic
+ // error in the calling code.
+ if ((it->second.flags & CCoinsCacheEntry::FRESH) && !itUs->second.coins.IsPruned())
+ throw std::logic_error("FRESH flag misapplied to cache entry for base transaction with spendable outputs");
+
// Found the entry in the parent cache
if ((itUs->second.flags & CCoinsCacheEntry::FRESH) && it->second.coins.IsPruned()) {
// The grandparent does not have an entry, and the child is