mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 18:52:29 +02:00
validation: add ChainstateRole
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <chain.h>
|
||||
#include <interfaces/chain.h>
|
||||
#include <kernel/chain.h>
|
||||
#include <sync.h>
|
||||
#include <uint256.h>
|
||||
|
||||
@@ -25,3 +26,13 @@ interfaces::BlockInfo MakeBlockInfo(const CBlockIndex* index, const CBlock* data
|
||||
return info;
|
||||
}
|
||||
} // namespace kernel
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const ChainstateRole& role) {
|
||||
switch(role) {
|
||||
case ChainstateRole::NORMAL: os << "normal"; break;
|
||||
case ChainstateRole::ASSUMEDVALID: os << "assumedvalid"; break;
|
||||
case ChainstateRole::BACKGROUND: os << "background"; break;
|
||||
default: os.setstate(std::ios_base::failbit);
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef BITCOIN_KERNEL_CHAIN_H
|
||||
#define BITCOIN_KERNEL_CHAIN_H
|
||||
|
||||
#include<iostream>
|
||||
|
||||
class CBlock;
|
||||
class CBlockIndex;
|
||||
namespace interfaces {
|
||||
@@ -14,6 +16,24 @@ struct BlockInfo;
|
||||
namespace kernel {
|
||||
//! Return data from block index.
|
||||
interfaces::BlockInfo MakeBlockInfo(const CBlockIndex* block_index, const CBlock* data = nullptr);
|
||||
|
||||
} // namespace kernel
|
||||
|
||||
//! This enum describes the various roles a specific Chainstate instance can take.
|
||||
//! Other parts of the system sometimes need to vary in behavior depending on the
|
||||
//! existence of a background validation chainstate, e.g. when building indexes.
|
||||
enum class ChainstateRole {
|
||||
// Single chainstate in use, "normal" IBD mode.
|
||||
NORMAL,
|
||||
|
||||
// Doing IBD-style validation in the background. Implies use of an assumed-valid
|
||||
// chainstate.
|
||||
BACKGROUND,
|
||||
|
||||
// Active assumed-valid chainstate. Implies use of a background IBD chainstate.
|
||||
ASSUMEDVALID,
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const ChainstateRole& role);
|
||||
|
||||
#endif // BITCOIN_KERNEL_CHAIN_H
|
||||
|
||||
Reference in New Issue
Block a user