mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 15:32:34 +02:00
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.
This commit is contained in:
parent
faa52387e8
commit
f100687566
@ -872,15 +872,12 @@ libbitcoinkernel_la_SOURCES = \
|
|||||||
flatfile.cpp \
|
flatfile.cpp \
|
||||||
fs.cpp \
|
fs.cpp \
|
||||||
hash.cpp \
|
hash.cpp \
|
||||||
index/base.cpp \
|
|
||||||
index/coinstatsindex.cpp \
|
|
||||||
init/common.cpp \
|
init/common.cpp \
|
||||||
kernel/coinstats.cpp \
|
kernel/coinstats.cpp \
|
||||||
key.cpp \
|
key.cpp \
|
||||||
logging.cpp \
|
logging.cpp \
|
||||||
node/blockstorage.cpp \
|
node/blockstorage.cpp \
|
||||||
node/chainstate.cpp \
|
node/chainstate.cpp \
|
||||||
node/coinstats.cpp \
|
|
||||||
node/ui_interface.cpp \
|
node/ui_interface.cpp \
|
||||||
policy/feerate.cpp \
|
policy/feerate.cpp \
|
||||||
policy/fees.cpp \
|
policy/fees.cpp \
|
||||||
|
@ -18,10 +18,10 @@
|
|||||||
#include <cuckoocache.h>
|
#include <cuckoocache.h>
|
||||||
#include <flatfile.h>
|
#include <flatfile.h>
|
||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
|
#include <kernel/coinstats.h>
|
||||||
#include <logging.h>
|
#include <logging.h>
|
||||||
#include <logging/timer.h>
|
#include <logging/timer.h>
|
||||||
#include <node/blockstorage.h>
|
#include <node/blockstorage.h>
|
||||||
#include <node/coinstats.h>
|
|
||||||
#include <node/ui_interface.h>
|
#include <node/ui_interface.h>
|
||||||
#include <node/utxo_snapshot.h>
|
#include <node/utxo_snapshot.h>
|
||||||
#include <policy/policy.h>
|
#include <policy/policy.h>
|
||||||
@ -60,6 +60,7 @@
|
|||||||
|
|
||||||
using kernel::CCoinsStats;
|
using kernel::CCoinsStats;
|
||||||
using kernel::CoinStatsHashType;
|
using kernel::CoinStatsHashType;
|
||||||
|
using kernel::ComputeUTXOStats;
|
||||||
|
|
||||||
using node::BLOCKFILE_CHUNK_SIZE;
|
using node::BLOCKFILE_CHUNK_SIZE;
|
||||||
using node::BlockManager;
|
using node::BlockManager;
|
||||||
@ -69,7 +70,6 @@ using node::CBlockIndexWorkComparator;
|
|||||||
using node::fImporting;
|
using node::fImporting;
|
||||||
using node::fPruneMode;
|
using node::fPruneMode;
|
||||||
using node::fReindex;
|
using node::fReindex;
|
||||||
using node::GetUTXOStats;
|
|
||||||
using node::nPruneTarget;
|
using node::nPruneTarget;
|
||||||
using node::OpenBlockFile;
|
using node::OpenBlockFile;
|
||||||
using node::ReadBlockFromDisk;
|
using node::ReadBlockFromDisk;
|
||||||
@ -4988,7 +4988,8 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
|
|||||||
CBlockIndex* snapshot_start_block = WITH_LOCK(::cs_main, return m_blockman.LookupBlockIndex(base_blockhash));
|
CBlockIndex* snapshot_start_block = WITH_LOCK(::cs_main, return m_blockman.LookupBlockIndex(base_blockhash));
|
||||||
|
|
||||||
if (!snapshot_start_block) {
|
if (!snapshot_start_block) {
|
||||||
// Needed for GetUTXOStats and ExpectedAssumeutxo to determine the height and to avoid a crash when base_blockhash.IsNull()
|
// Needed for ComputeUTXOStats and ExpectedAssumeutxo to determine the
|
||||||
|
// height and to avoid a crash when base_blockhash.IsNull()
|
||||||
LogPrintf("[snapshot] Did not find snapshot start blockheader %s\n",
|
LogPrintf("[snapshot] Did not find snapshot start blockheader %s\n",
|
||||||
base_blockhash.ToString());
|
base_blockhash.ToString());
|
||||||
return false;
|
return false;
|
||||||
@ -5102,7 +5103,7 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
|
|||||||
// about the snapshot_chainstate.
|
// about the snapshot_chainstate.
|
||||||
CCoinsViewDB* snapshot_coinsdb = WITH_LOCK(::cs_main, return &snapshot_chainstate.CoinsDB());
|
CCoinsViewDB* snapshot_coinsdb = WITH_LOCK(::cs_main, return &snapshot_chainstate.CoinsDB());
|
||||||
|
|
||||||
const std::optional<CCoinsStats> maybe_stats = GetUTXOStats(snapshot_coinsdb, m_blockman, CoinStatsHashType::HASH_SERIALIZED, breakpoint_fnc);
|
const std::optional<CCoinsStats> maybe_stats = ComputeUTXOStats(CoinStatsHashType::HASH_SERIALIZED, snapshot_coinsdb, m_blockman, breakpoint_fnc);
|
||||||
if (!maybe_stats.has_value()) {
|
if (!maybe_stats.has_value()) {
|
||||||
LogPrintf("[snapshot] failed to generate coins stats\n");
|
LogPrintf("[snapshot] failed to generate coins stats\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -21,7 +21,7 @@ EXPECTED_CIRCULAR_DEPENDENCIES = (
|
|||||||
"qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel",
|
"qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel",
|
||||||
"wallet/fees -> wallet/wallet -> wallet/fees",
|
"wallet/fees -> wallet/wallet -> wallet/fees",
|
||||||
"wallet/wallet -> wallet/walletdb -> wallet/wallet",
|
"wallet/wallet -> wallet/walletdb -> wallet/wallet",
|
||||||
"node/coinstats -> validation -> node/coinstats",
|
"kernel/coinstats -> validation -> kernel/coinstats",
|
||||||
)
|
)
|
||||||
|
|
||||||
CODE_DIR = "src"
|
CODE_DIR = "src"
|
||||||
|
Loading…
Reference in New Issue
Block a user