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

@@ -6,7 +6,6 @@
#ifndef BITCOIN_VALIDATIONINTERFACE_H
#define BITCOIN_VALIDATIONINTERFACE_H
#include <kernel/chain.h>
#include <kernel/cs_main.h>
#include <primitives/transaction.h>
#include <sync.h>
@@ -17,6 +16,9 @@
#include <memory>
#include <vector>
namespace kernel {
struct ChainstateRole;
} // namespace kernel
namespace util {
class TaskRunnerInterface;
} // namespace util
@@ -118,7 +120,7 @@ protected:
*
* Called on a background thread.
*/
virtual void BlockConnected(ChainstateRole role, const std::shared_ptr<const CBlock> &block, const CBlockIndex *pindex) {}
virtual void BlockConnected(const kernel::ChainstateRole& role, const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex) {}
/**
* Notifies listeners of a block being disconnected
* Provides the block that was disconnected.
@@ -143,7 +145,7 @@ protected:
*
* Called on a background thread.
*/
virtual void ChainStateFlushed(ChainstateRole role, const CBlockLocator &locator) {}
virtual void ChainStateFlushed(const kernel::ChainstateRole& role, const CBlockLocator& locator) {}
/**
* Notifies listeners of a block validation result.
* If the provided BlockValidationState IsValid, the provided block
@@ -221,9 +223,9 @@ public:
void TransactionAddedToMempool(const NewMempoolTransactionInfo&, uint64_t mempool_sequence);
void TransactionRemovedFromMempool(const CTransactionRef&, MemPoolRemovalReason, uint64_t mempool_sequence);
void MempoolTransactionsRemovedForBlock(const std::vector<RemovedMempoolTransactionInfo>&, unsigned int nBlockHeight);
void BlockConnected(ChainstateRole, const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex);
void BlockConnected(const kernel::ChainstateRole&, const std::shared_ptr<const CBlock>&, const CBlockIndex* pindex);
void BlockDisconnected(const std::shared_ptr<const CBlock> &, const CBlockIndex* pindex);
void ChainStateFlushed(ChainstateRole, const CBlockLocator &);
void ChainStateFlushed(const kernel::ChainstateRole&, const CBlockLocator&);
void BlockChecked(const std::shared_ptr<const CBlock>&, const BlockValidationState&);
void NewPoWValidBlock(const CBlockIndex *, const std::shared_ptr<const CBlock>&);
};