mirror of https://github.com/bitcoin/bitcoin.git
refactor: assert newly-created parent cache entry has zero memory usage
When promoting a child entry during `BatchWrite`, we `try_emplace` a parent entry that holds a default-constructed `Coin`, which is empty, so `DynamicMemoryUsage()` must be `0`. Assert this invariant to document why there is no `cachedCoinsUsage` decrement before the assignment at this site. Co-authored-by: Andrew Toth <andrewstoth@gmail.com>
This commit is contained in:
parent
b510893d00
commit
8d5e323b5f
|
@ -195,6 +195,7 @@ bool CCoinsViewCache::BatchWrite(CoinsViewCacheCursor& cursor, const uint256 &ha
|
|||
// and mark it as dirty.
|
||||
itUs = cacheCoins.try_emplace(it->first).first;
|
||||
CCoinsCacheEntry& entry{itUs->second};
|
||||
assert(entry.coin.DynamicMemoryUsage() == 0);
|
||||
if (cursor.WillErase(*it)) {
|
||||
// Since this entry will be erased,
|
||||
// we can move the coin into us instead of copying it
|
||||
|
|
Loading…
Reference in New Issue