Bitcoin Core  25.99.0
P2P Digital Currency
Go to the documentation of this file.
1 // Copyright (c) 2022 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or
7 #include <arith_uint256.h>
8 #include <common/args.h>
10 #include <node/coins_view_args.h>
11 #include <node/database_args.h>
12 #include <tinyformat.h>
13 #include <uint256.h>
14 #include <util/result.h>
15 #include <util/strencodings.h>
16 #include <util/translation.h>
17 #include <validation.h>
19 #include <chrono>
20 #include <string>
22 namespace node {
24 {
25  if (auto value{args.GetBoolArg("-checkblockindex")}) opts.check_block_index = *value;
27  if (auto value{args.GetBoolArg("-checkpoints")}) opts.checkpoints_enabled = *value;
29  if (auto value{args.GetArg("-minimumchainwork")}) {
30  if (!IsHexNumber(*value)) {
31  return util::Error{strprintf(Untranslated("Invalid non-hex (%s) minimum chain work value specified"), *value)};
32  }
34  }
36  if (auto value{args.GetArg("-assumevalid")}) opts.assumed_valid_block = uint256S(*value);
38  if (auto value{args.GetIntArg("-maxtipage")}) opts.max_tip_age = std::chrono::seconds{*value};
40  ReadDatabaseArgs(args, opts.block_tree_db);
41  ReadDatabaseArgs(args, opts.coins_db);
42  ReadCoinsViewArgs(args, opts.coins_view);
44  return {};
45 }
46 } // namespace node
arith_uint256 UintToArith256(const uint256 &a)
ArgsManager & args
Definition: bitcoind.cpp:269
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
Definition: args.cpp:481
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: args.cpp:456
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: args.cpp:506
Definition: init.h:25
util::Result< void > ApplyArgsManOptions(const ArgsManager &args, BlockManager::Options &opts)
void ReadCoinsViewArgs(const ArgsManager &args, CoinsViewOptions &options)
void ReadDatabaseArgs(const ArgsManager &args, DBOptions &options)
An options struct for ChainstateManager, more ergonomically referred to as ChainstateManager::Options...
std::optional< bool > check_block_index
std::optional< uint256 > assumed_valid_block
If set, it will override the block hash whose ancestors we will assume to have valid scripts without ...
std::optional< arith_uint256 > minimum_chain_work
If set, it will override the minimum work we will assume exists on some valid chain.
std::chrono::seconds max_tip_age
If the tip is older than this, the node is considered to be in initial block download.
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1162
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
Definition: translation.h:48
uint256 uint256S(const char *str)
Definition: uint256.h:119
bool IsHexNumber(std::string_view str)
Return true if the string is a hex number, optionally prefixed with "0x".