mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 04:12:36 -03:00
Move ::fCheckBlockIndex into ChainstateManager
This changes the flag for the bitcoin-chainstate executable. Previously it was false, now it is the chain's default value (still false for the main chain).
This commit is contained in:
parent
fa43188d86
commit
fa7c834b9f
6 changed files with 8 additions and 7 deletions
|
@ -934,8 +934,6 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
|
||||||
init::SetLoggingCategories(args);
|
init::SetLoggingCategories(args);
|
||||||
init::SetLoggingLevel(args);
|
init::SetLoggingLevel(args);
|
||||||
|
|
||||||
fCheckBlockIndex = args.GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks());
|
|
||||||
|
|
||||||
// block pruning; get the amount of disk space (in MiB) to allot for block & undo files
|
// block pruning; get the amount of disk space (in MiB) to allot for block & undo files
|
||||||
int64_t nPruneArg = args.GetIntArg("-prune", 0);
|
int64_t nPruneArg = args.GetIntArg("-prune", 0);
|
||||||
if (nPruneArg < 0) {
|
if (nPruneArg < 0) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace kernel {
|
||||||
struct ChainstateManagerOpts {
|
struct ChainstateManagerOpts {
|
||||||
const CChainParams& chainparams;
|
const CChainParams& chainparams;
|
||||||
const std::function<NodeClock::time_point()> adjusted_time_callback{nullptr};
|
const std::function<NodeClock::time_point()> adjusted_time_callback{nullptr};
|
||||||
|
std::optional<bool> check_block_index{};
|
||||||
bool checkpoints_enabled{DEFAULT_CHECKPOINTS_ENABLED};
|
bool checkpoints_enabled{DEFAULT_CHECKPOINTS_ENABLED};
|
||||||
//! If set, it will override the minimum work we will assume exists on some valid chain.
|
//! If set, it will override the minimum work we will assume exists on some valid chain.
|
||||||
std::optional<arith_uint256> minimum_chain_work;
|
std::optional<arith_uint256> minimum_chain_work;
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
namespace node {
|
namespace node {
|
||||||
std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts)
|
std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts)
|
||||||
{
|
{
|
||||||
|
if (auto value{args.GetBoolArg("-checkblockindex")}) opts.check_block_index = *value;
|
||||||
|
|
||||||
if (auto value{args.GetBoolArg("-checkpoints")}) opts.checkpoints_enabled = *value;
|
if (auto value{args.GetBoolArg("-checkpoints")}) opts.checkpoints_enabled = *value;
|
||||||
|
|
||||||
if (auto value{args.GetArg("-minimumchainwork")}) {
|
if (auto value{args.GetArg("-minimumchainwork")}) {
|
||||||
|
|
|
@ -146,7 +146,6 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
|
||||||
Assert(InitScriptExecutionCache(validation_cache_sizes.script_execution_cache_bytes));
|
Assert(InitScriptExecutionCache(validation_cache_sizes.script_execution_cache_bytes));
|
||||||
|
|
||||||
m_node.chain = interfaces::MakeChain(m_node);
|
m_node.chain = interfaces::MakeChain(m_node);
|
||||||
fCheckBlockIndex = true;
|
|
||||||
static bool noui_connected = false;
|
static bool noui_connected = false;
|
||||||
if (!noui_connected) {
|
if (!noui_connected) {
|
||||||
noui_connect();
|
noui_connect();
|
||||||
|
@ -194,6 +193,7 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve
|
||||||
const ChainstateManager::Options chainman_opts{
|
const ChainstateManager::Options chainman_opts{
|
||||||
.chainparams = chainparams,
|
.chainparams = chainparams,
|
||||||
.adjusted_time_callback = GetAdjustedTime,
|
.adjusted_time_callback = GetAdjustedTime,
|
||||||
|
.check_block_index = true,
|
||||||
};
|
};
|
||||||
m_node.chainman = std::make_unique<ChainstateManager>(chainman_opts);
|
m_node.chainman = std::make_unique<ChainstateManager>(chainman_opts);
|
||||||
m_node.chainman->m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(m_cache_sizes.block_tree_db, true);
|
m_node.chainman->m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(m_cache_sizes.block_tree_db, true);
|
||||||
|
|
|
@ -121,7 +121,6 @@ GlobalMutex g_best_block_mutex;
|
||||||
std::condition_variable g_best_block_cv;
|
std::condition_variable g_best_block_cv;
|
||||||
uint256 g_best_block;
|
uint256 g_best_block;
|
||||||
bool g_parallel_script_checks{false};
|
bool g_parallel_script_checks{false};
|
||||||
bool fCheckBlockIndex = false;
|
|
||||||
|
|
||||||
const CBlockIndex* Chainstate::FindForkInGlobalIndex(const CBlockLocator& locator) const
|
const CBlockIndex* Chainstate::FindForkInGlobalIndex(const CBlockLocator& locator) const
|
||||||
{
|
{
|
||||||
|
@ -4507,7 +4506,7 @@ void Chainstate::LoadExternalBlockFile(
|
||||||
|
|
||||||
void Chainstate::CheckBlockIndex()
|
void Chainstate::CheckBlockIndex()
|
||||||
{
|
{
|
||||||
if (!fCheckBlockIndex) {
|
if (!m_chainman.ShouldCheckBlockIndex()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5248,6 +5247,7 @@ void ChainstateManager::ResetChainstates()
|
||||||
*/
|
*/
|
||||||
static ChainstateManager::Options&& Flatten(ChainstateManager::Options&& opts)
|
static ChainstateManager::Options&& Flatten(ChainstateManager::Options&& opts)
|
||||||
{
|
{
|
||||||
|
if (!opts.check_block_index.has_value()) opts.check_block_index = opts.chainparams.DefaultConsistencyChecks();
|
||||||
if (!opts.minimum_chain_work.has_value()) opts.minimum_chain_work = UintToArith256(opts.chainparams.GetConsensus().nMinimumChainWork);
|
if (!opts.minimum_chain_work.has_value()) opts.minimum_chain_work = UintToArith256(opts.chainparams.GetConsensus().nMinimumChainWork);
|
||||||
if (!opts.assumed_valid_block.has_value()) opts.assumed_valid_block = opts.chainparams.GetConsensus().defaultAssumeValid;
|
if (!opts.assumed_valid_block.has_value()) opts.assumed_valid_block = opts.chainparams.GetConsensus().defaultAssumeValid;
|
||||||
Assert(opts.adjusted_time_callback);
|
Assert(opts.adjusted_time_callback);
|
||||||
|
|
|
@ -95,7 +95,6 @@ extern uint256 g_best_block;
|
||||||
* False indicates all script checking is done on the main threadMessageHandler thread.
|
* False indicates all script checking is done on the main threadMessageHandler thread.
|
||||||
*/
|
*/
|
||||||
extern bool g_parallel_script_checks;
|
extern bool g_parallel_script_checks;
|
||||||
extern bool fCheckBlockIndex;
|
|
||||||
|
|
||||||
/** Documentation for argument 'checklevel'. */
|
/** Documentation for argument 'checklevel'. */
|
||||||
extern const std::vector<std::string> CHECKLEVEL_DOC;
|
extern const std::vector<std::string> CHECKLEVEL_DOC;
|
||||||
|
@ -691,7 +690,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Make various assertions about the state of the block index.
|
* Make various assertions about the state of the block index.
|
||||||
*
|
*
|
||||||
* By default this only executes fully when using the Regtest chain; see: fCheckBlockIndex.
|
* By default this only executes fully when using the Regtest chain; see: m_options.check_block_index.
|
||||||
*/
|
*/
|
||||||
void CheckBlockIndex();
|
void CheckBlockIndex();
|
||||||
|
|
||||||
|
@ -860,6 +859,7 @@ public:
|
||||||
|
|
||||||
const CChainParams& GetParams() const { return m_options.chainparams; }
|
const CChainParams& GetParams() const { return m_options.chainparams; }
|
||||||
const Consensus::Params& GetConsensus() const { return m_options.chainparams.GetConsensus(); }
|
const Consensus::Params& GetConsensus() const { return m_options.chainparams.GetConsensus(); }
|
||||||
|
bool ShouldCheckBlockIndex() const { return *Assert(m_options.check_block_index); }
|
||||||
const arith_uint256& MinimumChainWork() const { return *Assert(m_options.minimum_chain_work); }
|
const arith_uint256& MinimumChainWork() const { return *Assert(m_options.minimum_chain_work); }
|
||||||
const uint256& AssumedValidBlock() const { return *Assert(m_options.assumed_valid_block); }
|
const uint256& AssumedValidBlock() const { return *Assert(m_options.assumed_valid_block); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue