refactor: Convert ChainstateRole enum to struct

Change ChainstateRole parameter passed to wallets and indexes. Wallets and
indexes need to know whether chainstate is historical and whether it is fully
validated. They should not be aware of the assumeutxo snapshot validation
process.
This commit is contained in:
Ryan Ofsky
2025-06-18 09:51:34 -04:00
parent 352ad27fc1
commit 4dfe383912
26 changed files with 130 additions and 79 deletions

View File

@@ -7,9 +7,9 @@
#include <chain.h>
#include <consensus/validation.h>
#include <kernel/chain.h>
#include <kernel/mempool_entry.h>
#include <kernel/mempool_removal_reason.h>
#include <kernel/types.h>
#include <logging.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
@@ -21,6 +21,8 @@
#include <unordered_map>
#include <utility>
using kernel::ChainstateRole;
/**
* ValidationSignalsImpl manages a list of shared_ptr<CValidationInterface> callbacks.
*
@@ -209,7 +211,8 @@ void ValidationSignals::TransactionRemovedFromMempool(const CTransactionRef& tx,
RemovalReasonToString(reason));
}
void ValidationSignals::BlockConnected(ChainstateRole role, const std::shared_ptr<const CBlock> &pblock, const CBlockIndex *pindex) {
void ValidationSignals::BlockConnected(const ChainstateRole& role, const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
{
auto event = [role, pblock, pindex, this] {
m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.BlockConnected(role, pblock, pindex); });
};
@@ -238,7 +241,8 @@ void ValidationSignals::BlockDisconnected(const std::shared_ptr<const CBlock>& p
pindex->nHeight);
}
void ValidationSignals::ChainStateFlushed(ChainstateRole role, const CBlockLocator &locator) {
void ValidationSignals::ChainStateFlushed(const ChainstateRole& role, const CBlockLocator& locator)
{
auto event = [role, locator, this] {
m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.ChainStateFlushed(role, locator); });
};