Bitcoin ABC 0.30.5
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 <common/args.h>
11#include <node/database_args.h>
12#include <tinyformat.h>
13#include <uint256.h>
14#include <util/strencodings.h>
15#include <util/translation.h>
16#include <validation.h>
17
18#include <chrono>
19#include <optional>
20#include <string>
21
22namespace node {
23std::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
52 ReadDatabaseArgs(args, opts.coins_db);
53 ReadCoinsViewArgs(args, opts.coins_view);
54
55 if (auto value{args.GetBoolArg("-persistrecentheaderstime")}) {
56 opts.store_recent_headers_time = *value;
57 }
58
59 return std::nullopt;
60}
61} // 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: args.cpp:526
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: args.cpp:494
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: args.cpp:556
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)
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.
#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".