mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-15 04:11:02 +01:00
test: simplify coins sanity check
This commit is contained in:
parent
147cd50501
commit
4c9c30eda3
1 changed files with 7 additions and 6 deletions
|
@ -311,12 +311,13 @@ void CCoinsViewCache::SanityCheck() const
|
||||||
size_t recomputed_usage = 0;
|
size_t recomputed_usage = 0;
|
||||||
size_t count_flagged = 0;
|
size_t count_flagged = 0;
|
||||||
for (const auto& [_, entry] : cacheCoins) {
|
for (const auto& [_, entry] : cacheCoins) {
|
||||||
unsigned attr = 0;
|
if (entry.coin.IsSpent()) {
|
||||||
if (entry.IsDirty()) attr |= 1;
|
// A spent coin must be dirty and cannot be fresh
|
||||||
if (entry.IsFresh()) attr |= 2;
|
assert(entry.IsDirty() && !entry.IsFresh());
|
||||||
if (entry.coin.IsSpent()) attr |= 4;
|
} else {
|
||||||
// Only 4 combinations are possible.
|
// An unspent coin must not be fresh if not dirty
|
||||||
assert(attr != 2 && attr != 4 && attr != 6 && attr != 7);
|
assert(entry.IsDirty() || !entry.IsFresh());
|
||||||
|
}
|
||||||
|
|
||||||
// Recompute cachedCoinsUsage.
|
// Recompute cachedCoinsUsage.
|
||||||
recomputed_usage += entry.coin.DynamicMemoryUsage();
|
recomputed_usage += entry.coin.DynamicMemoryUsage();
|
||||||
|
|
Loading…
Add table
Reference in a new issue