Bitcoin ABC  0.29.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 <node/coins_view_args.h>
10 #include <node/database_args.h>
11 #include <tinyformat.h>
12 #include <uint256.h>
13 #include <util/strencodings.h>
14 #include <util/system.h>
15 #include <util/translation.h>
16 #include <validation.h>
17 
18 #include <chrono>
19 #include <optional>
20 #include <string>
21 
22 namespace node {
23 std::optional<bilingual_str>
25  if (auto value{args.GetBoolArg("-checkblockindex")}) {
26  opts.check_block_index = *value;
27  }
28 
29  if (auto value{args.GetBoolArg("-checkpoints")}) {
30  opts.checkpoints_enabled = *value;
31  }
32 
33  if (auto value{args.GetArg("-minimumchainwork")}) {
34  if (!IsHexNumber(*value)) {
35  return strprintf(
37  "Invalid non-hex (%s) minimum chain work value specified"),
38  *value);
39  }
41  }
42 
43  if (auto value{args.GetArg("-assumevalid")}) {
45  }
46 
47  if (auto value{args.GetIntArg("-maxtipage")}) {
48  opts.max_tip_age = std::chrono::seconds{*value};
49  }
50 
51  ReadDatabaseArgs(args, opts.block_tree_db);
52  ReadDatabaseArgs(args, opts.coins_db);
53  ReadCoinsViewArgs(args, opts.coins_view);
54 
55  return std::nullopt;
56 }
57 } // 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)
void ReadCoinsViewArgs(const ArgsManager &args, CoinsViewOptions &options)
void ReadDatabaseArgs(const ArgsManager &args, DBOptions &options)
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