Skip to content

Commit 2e16054

Browse files
committed
Add assertions that BatchWrite(erase=true) erases
1 parent 941feb6 commit 2e16054

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/coins.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,10 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlockIn
250250

251251
bool CCoinsViewCache::Flush() {
252252
bool fOk = base->BatchWrite(cacheCoins, hashBlock, /*erase=*/true);
253-
cacheCoins.clear();
253+
if (fOk && !cacheCoins.empty()) {
254+
/* BatchWrite must erase all cacheCoins elements when erase=true. */
255+
throw std::logic_error("Not all cached coins were erased");
256+
}
254257
cachedCoinsUsage = 0;
255258
return fOk;
256259
}

0 commit comments

Comments
 (0)