Bitcoin ABC 0.32.4
P2P Digital Currency
chainstatemanager_args.cpp
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 http://www.opensource.org/licenses/mit-license.php.
4
6
7#include <arith_uint256.h>
9#include <common/args.h>
12#include <node/database_args.h>
13#include <tinyformat.h>
14#include <uint256.h>
15#include <util/strencodings.h>
16#include <util/translation.h>
17#include <validation.h>
18
19#include <chrono>
20#include <optional>
21#include <string>
22
23namespace node {
24std::optional<bilingual_str>
26 if (auto value{args.GetBoolArg("-checkblockindex")}) {
27 opts.check_block_index = *value;
28 }
29
30 if (auto value{args.GetBoolArg("-checkpoints")}) {
31 opts.checkpoints_enabled = *value;
32 }
33
34 if (auto value{args.GetArg("-minimumchainwork")}) {
35 if (!IsHexNumber(*value)) {
36 return strprintf(
38 "Invalid non-hex (%s) minimum chain work value specified"),
39 *value);
40 }
42 }
43
44 if (auto value{args.GetArg("-assumevalid")}) {
46 }
47
48 if (auto value{args.GetIntArg("-maxtipage")}) {
49 opts.max_tip_age = std::chrono::seconds{*value};
50 }
51
52 if (auto value{args.GetIntArg("-stopatheight")}) {
53 opts.stop_at_height = *value;
54 }
55
57 ReadDatabaseArgs(args, opts.coins_db);
58 ReadCoinsViewArgs(args, opts.coins_view);
59
60 if (auto value{args.GetBoolArg("-persistrecentheaderstime")}) {
61 opts.store_recent_headers_time = *value;
62 }
63
64 // When supplied with a max_size of 0, both the signature cache and
65 // script execution cache create the minimum possible cache (2
66 // elements). Therefore, we can use 0 as a floor here.
67 if (auto max_size = args.GetIntArg("-maxscriptcachesize")) {
69 std::max<int64_t>(*max_size, 0) * (1 << 20);
70 }
71 if (auto max_size = args.GetIntArg("-maxsigcachesize")) {
73 std::max<int64_t>(*max_size, 0) * (1 << 20);
74 ;
75 }
76
77 if (auto value{args.GetBoolArg("-parkdeepreorg")}) {
78 opts.park_deep_reorg = *value;
79 }
80
82 "-automaticunparking",
83 !args.GetBoolArg("-avalanche", AVALANCHE_DEFAULT_ENABLED));
84
86 gArgs.GetIntArg("-replayprotectionactivationtime");
87
88 return std::nullopt;
89}
90} // namespace node
ArgsManager gArgs
Definition: args.cpp:40
arith_uint256 UintToArith256(const uint256 &a)
static constexpr bool AVALANCHE_DEFAULT_ENABLED
Is avalanche enabled by default.
Definition: avalanche.h:22
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
Definition: args.cpp:495
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: args.cpp:463
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: args.cpp:525
Definition: init.h:31
void ReadCoinsViewArgs(const ArgsManager &args, CoinsViewOptions &options)
void ReadDatabaseArgs(const ArgsManager &args, DBOptions &options)
void ApplyArgsManOptions(const ArgsManager &args, const Config &config, BlockFitter::Options &options)
Apply options from ArgsManager to BlockFitter options.
Definition: blockfitter.cpp:40
static BlockHash fromHex(const std::string &str)
Definition: blockhash.h:17
An options struct for ChainstateManager, more ergonomically referred to as ChainstateManager::Options...
std::optional< bool > check_block_index
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.
std::optional< BlockHash > assumed_valid_block
If set, it will override the block hash whose ancestors we will assume to have valid scripts without ...
bool store_recent_headers_time
If set, store and load the last few block headers reception time to speed up RTT bootstraping.
std::optional< int64_t > replay_protection_activation_time
If set, this overwrites the timestamp at which replay protection activates.
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1202
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
Definition: translation.h:36
uint256 uint256S(const char *str)
uint256 from const char *.
Definition: uint256.h:143
bool IsHexNumber(std::string_view str)
Return true if the string is a hex number, optionally prefixed with "0x".