aboutsummaryrefslogtreecommitdiff
path: root/src/coins.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2023-01-30 11:45:14 -0500
committerPieter Wuille <pieter@wuille.net>2023-01-30 13:13:54 -0500
commit2e16054a66b0576ec93d4032d6b74f0930a44fef (patch)
tree2df926aa81a0cadb5964b120352af80dd71fbd44 /src/coins.cpp
parent941feb6ca28522806c4710f85ae5673abdbdb0b9 (diff)
downloadbitcoin-2e16054a66b0576ec93d4032d6b74f0930a44fef.tar.xz
Add assertions that BatchWrite(erase=true) erases
Diffstat (limited to 'src/coins.cpp')
-rw-r--r--src/coins.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/coins.cpp b/src/coins.cpp
index e240136576..31ac67674a 100644
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -250,7 +250,10 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlockIn
bool CCoinsViewCache::Flush() {
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;
return fOk;
}