Changeset View
Changeset View
Standalone View
Standalone View
src/node/chainstatemanager_args.cpp
// Copyright (c) 2022 The Bitcoin Core developers | // Copyright (c) 2022 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <node/chainstatemanager_args.h> | #include <node/chainstatemanager_args.h> | ||||
#include <arith_uint256.h> | |||||
#include <tinyformat.h> | |||||
#include <uint256.h> | |||||
#include <util/strencodings.h> | |||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <util/translation.h> | |||||
#include <validation.h> | |||||
#include <chrono> | #include <chrono> | ||||
#include <optional> | #include <optional> | ||||
#include <string> | |||||
namespace node { | namespace node { | ||||
void ApplyArgsManOptions(const ArgsManager &args, | std::optional<bilingual_str> | ||||
ChainstateManager::Options &opts) { | ApplyArgsManOptions(const ArgsManager &args, ChainstateManager::Options &opts) { | ||||
if (auto value{args.GetArg("-minimumchainwork")}) { | |||||
if (!IsHexNumber(*value)) { | |||||
return strprintf( | |||||
Untranslated( | |||||
"Invalid non-hex (%s) minimum chain work value specified"), | |||||
*value); | |||||
} | |||||
opts.minimum_chain_work = UintToArith256(uint256S(*value)); | |||||
} | |||||
if (auto value{args.GetArg("-assumevalid")}) { | if (auto value{args.GetArg("-assumevalid")}) { | ||||
opts.assumed_valid_block = BlockHash::fromHex(*value); | opts.assumed_valid_block = BlockHash::fromHex(*value); | ||||
} | } | ||||
if (auto value{args.GetIntArg("-maxtipage")}) { | if (auto value{args.GetIntArg("-maxtipage")}) { | ||||
opts.max_tip_age = std::chrono::seconds{*value}; | opts.max_tip_age = std::chrono::seconds{*value}; | ||||
} | } | ||||
return std::nullopt; | |||||
} | } | ||||
} // namespace node | } // namespace node |