diff options
author | Carl Dong <contact@carldong.me> | 2022-02-15 18:37:32 -0500 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2022-05-23 14:50:35 -0400 |
commit | 524463daf6a10b20a4e20116a68101a684929eda (patch) | |
tree | 257ecace292cba8614f8b1e4592f524561293016 /src/validation.cpp | |
parent | 46eb9fc56a296a2acea10ec7e5bf7b1827f73c45 (diff) | |
download | bitcoin-524463daf6a10b20a4e20116a68101a684929eda.tar.xz |
coinstats: Return purely out-param CCoinsStats
In previous commits in this patchset, we removed all in-param members of
CCoinsStats. Now that that's done, we can modify GetUTXOStats to return
an optional CCoinsStats instead of a status bool. Callers are modified
accordingly.
In rpc/blockchain.cpp, we discover that GetUTXOStats' status bool when
getting UTXO stats for pprev was not checked for error. We fix this as
well.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 5fdf0398df..40c2618db9 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5095,22 +5095,22 @@ bool ChainstateManager::PopulateAndValidateSnapshot( assert(coins_cache.GetBestBlock() == base_blockhash); - CCoinsStats stats{}; auto breakpoint_fnc = [] { /* TODO insert breakpoint here? */ }; // As above, okay to immediately release cs_main here since no other context knows // about the snapshot_chainstate. CCoinsViewDB* snapshot_coinsdb = WITH_LOCK(::cs_main, return &snapshot_chainstate.CoinsDB()); - if (!GetUTXOStats(snapshot_coinsdb, m_blockman, stats, CoinStatsHashType::HASH_SERIALIZED, breakpoint_fnc)) { + const std::optional<CCoinsStats> maybe_stats = GetUTXOStats(snapshot_coinsdb, m_blockman, CoinStatsHashType::HASH_SERIALIZED, breakpoint_fnc); + if (!maybe_stats.has_value()) { LogPrintf("[snapshot] failed to generate coins stats\n"); return false; } // Assert that the deserialized chainstate contents match the expected assumeutxo value. - if (AssumeutxoHash{stats.hashSerialized} != au_data.hash_serialized) { + if (AssumeutxoHash{maybe_stats->hashSerialized} != au_data.hash_serialized) { LogPrintf("[snapshot] bad snapshot content hash: expected %s, got %s\n", - au_data.hash_serialized.ToString(), stats.hashSerialized.ToString()); + au_data.hash_serialized.ToString(), maybe_stats->hashSerialized.ToString()); return false; } |