Add assertions that BatchWrite(erase=true) erases

This commit is contained in:
Pieter Wuille committed 2023-01-30 13:13:54 -05:00
1 parent 941feb6ca2
commit 2e16054a66
1 file changed
+4 -1
+4 -1
View File
@@ -250,7 +250,10 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlockIn
bool CCoinsViewCache::Flush() { bool CCoinsViewCache::Flush() {
bool fOk = base->BatchWrite(cacheCoins, hashBlock, /*erase=*/true); bool fOk = base->BatchWrite(cacheCoins, hashBlock, /*erase=*/true);
cacheCoins.clear(); if (fOk && !cacheCoins.empty()) {
/* BatchWrite must erase all cacheCoins elements when erase=true. */
throw std::logic_error("Not all cached coins were erased");
}
cachedCoinsUsage = 0; cachedCoinsUsage = 0;
return fOk; return fOk;
} }