Skip to content

Commit f100687

Browse files
committed
kernel: Use ComputeUTXOStats in validation
This is the "fruit of our labor" for this patchset. ChainstateManager::PopulateAndValidateSnapshot can now directly call ComputeUTXOStats(...). Our consensus engine is now fully decoupled from all indices. See the src/Makefile.am for some satisfying removals.
1 parent faa5238 commit f100687

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/Makefile.am

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,15 +872,12 @@ libbitcoinkernel_la_SOURCES = \
872872
flatfile.cpp \
873873
fs.cpp \
874874
hash.cpp \
875-
index/base.cpp \
876-
index/coinstatsindex.cpp \
877875
init/common.cpp \
878876
kernel/coinstats.cpp \
879877
key.cpp \
880878
logging.cpp \
881879
node/blockstorage.cpp \
882880
node/chainstate.cpp \
883-
node/coinstats.cpp \
884881
node/ui_interface.cpp \
885882
policy/feerate.cpp \
886883
policy/fees.cpp \

src/validation.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
#include <cuckoocache.h>
1919
#include <flatfile.h>
2020
#include <hash.h>
21+
#include <kernel/coinstats.h>
2122
#include <logging.h>
2223
#include <logging/timer.h>
2324
#include <node/blockstorage.h>
24-
#include <node/coinstats.h>
2525
#include <node/ui_interface.h>
2626
#include <node/utxo_snapshot.h>
2727
#include <policy/policy.h>
@@ -60,6 +60,7 @@
6060

6161
using kernel::CCoinsStats;
6262
using kernel::CoinStatsHashType;
63+
using kernel::ComputeUTXOStats;
6364

6465
using node::BLOCKFILE_CHUNK_SIZE;
6566
using node::BlockManager;
@@ -69,7 +70,6 @@ using node::CBlockIndexWorkComparator;
6970
using node::fImporting;
7071
using node::fPruneMode;
7172
using node::fReindex;
72-
using node::GetUTXOStats;
7373
using node::nPruneTarget;
7474
using node::OpenBlockFile;
7575
using node::ReadBlockFromDisk;
@@ -4988,7 +4988,8 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
49884988
CBlockIndex* snapshot_start_block = WITH_LOCK(::cs_main, return m_blockman.LookupBlockIndex(base_blockhash));
49894989

49904990
if (!snapshot_start_block) {
4991-
// Needed for GetUTXOStats and ExpectedAssumeutxo to determine the height and to avoid a crash when base_blockhash.IsNull()
4991+
// Needed for ComputeUTXOStats and ExpectedAssumeutxo to determine the
4992+
// height and to avoid a crash when base_blockhash.IsNull()
49924993
LogPrintf("[snapshot] Did not find snapshot start blockheader %s\n",
49934994
base_blockhash.ToString());
49944995
return false;
@@ -5102,7 +5103,7 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
51025103
// about the snapshot_chainstate.
51035104
CCoinsViewDB* snapshot_coinsdb = WITH_LOCK(::cs_main, return &snapshot_chainstate.CoinsDB());
51045105

5105-
const std::optional<CCoinsStats> maybe_stats = GetUTXOStats(snapshot_coinsdb, m_blockman, CoinStatsHashType::HASH_SERIALIZED, breakpoint_fnc);
5106+
const std::optional<CCoinsStats> maybe_stats = ComputeUTXOStats(CoinStatsHashType::HASH_SERIALIZED, snapshot_coinsdb, m_blockman, breakpoint_fnc);
51065107
if (!maybe_stats.has_value()) {
51075108
LogPrintf("[snapshot] failed to generate coins stats\n");
51085109
return false;

test/lint/lint-circular-dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel",
2222
"wallet/fees -> wallet/wallet -> wallet/fees",
2323
"wallet/wallet -> wallet/walletdb -> wallet/wallet",
24-
"node/coinstats -> validation -> node/coinstats",
24+
"kernel/coinstats -> validation -> kernel/coinstats",
2525
)
2626

2727
CODE_DIR = "src"

0 commit comments

Comments
 (0)