mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-02 11:55:42 +02:00
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:
@@ -10,6 +10,7 @@
|
||||
#include <interfaces/chain.h>
|
||||
#include <interfaces/types.h>
|
||||
#include <kernel/chain.h>
|
||||
#include <kernel/types.h>
|
||||
#include <logging.h>
|
||||
#include <node/abort.h>
|
||||
#include <node/blockstorage.h>
|
||||
@@ -42,6 +43,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using kernel::ChainstateRole;
|
||||
|
||||
constexpr uint8_t DB_BEST_BLOCK{'B'};
|
||||
|
||||
constexpr auto SYNC_LOG_INTERVAL{30s};
|
||||
@@ -323,15 +326,13 @@ bool BaseIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_ti
|
||||
return true;
|
||||
}
|
||||
|
||||
void BaseIndex::BlockConnected(ChainstateRole role, const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex)
|
||||
void BaseIndex::BlockConnected(const ChainstateRole& role, const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex)
|
||||
{
|
||||
// Ignore events from the assumed-valid chain; we will process its blocks
|
||||
// (sequentially) after it is fully verified by the background chainstate. This
|
||||
// is to avoid any out-of-order indexing.
|
||||
// Ignore events from not fully validated chains to avoid out-of-order indexing.
|
||||
//
|
||||
// TODO at some point we could parameterize whether a particular index can be
|
||||
// built out of order, but for now just do the conservative simple thing.
|
||||
if (role == ChainstateRole::ASSUMEDVALID) {
|
||||
if (!role.validated) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -377,11 +378,10 @@ void BaseIndex::BlockConnected(ChainstateRole role, const std::shared_ptr<const
|
||||
}
|
||||
}
|
||||
|
||||
void BaseIndex::ChainStateFlushed(ChainstateRole role, const CBlockLocator& locator)
|
||||
void BaseIndex::ChainStateFlushed(const ChainstateRole& role, const CBlockLocator& locator)
|
||||
{
|
||||
// Ignore events from the assumed-valid chain; we will process its blocks
|
||||
// (sequentially) after it is fully verified by the background chainstate.
|
||||
if (role == ChainstateRole::ASSUMEDVALID) {
|
||||
// Ignore events from not fully validated chains to avoid out-of-order indexing.
|
||||
if (!role.validated) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user