Bitcoin ABC  0.29.3
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>
8 #include <tinyformat.h>
9 #include <uint256.h>
10 #include <util/strencodings.h>
11 #include <util/system.h>
12 #include <util/translation.h>
13 #include <validation.h>
14 
15 #include <chrono>
16 #include <optional>
17 #include <string>
18 
19 namespace node {
20 std::optional<bilingual_str>
22  if (auto value{args.GetBoolArg("-checkblockindex")}) {
23  opts.check_block_index = *value;
24  }
25 
26  if (auto value{args.GetBoolArg("-checkpoints")}) {
27  opts.checkpoints_enabled = *value;
28  }
29 
30  if (auto value{args.GetArg("-minimumchainwork")}) {
31  if (!IsHexNumber(*value)) {
32  return strprintf(
34  "Invalid non-hex (%s) minimum chain work value specified"),
35  *value);
36  }
38  }
39 
40  if (auto value{args.GetArg("-assumevalid")}) {
42  }
43 
44  if (auto value{args.GetIntArg("-maxtipage")}) {
45  opts.max_tip_age = std::chrono::seconds{*value};
46  }
47  return std::nullopt;
48 }
49 } // namespace node
arith_uint256 UintToArith256(const uint256 &a)
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
Definition: system.cpp:635
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: system.cpp:603
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:665
Definition: init.h:28
std::optional< bilingual_str > ApplyArgsManOptions(const ArgsManager &args, BlockManager::Options &opts)
bool IsHexNumber(const std::string &str)
Return true if the string is a hex number, optionally prefixed with "0x".
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 ...
#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