2022-07-20 18:16:30 +02:00
|
|
|
// Copyright (c) 2022 The Bitcoin Core developers
|
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#include <node/chainstatemanager_args.h>
|
|
|
|
|
2022-07-21 11:13:13 +02:00
|
|
|
#include <arith_uint256.h>
|
|
|
|
#include <tinyformat.h>
|
|
|
|
#include <uint256.h>
|
|
|
|
#include <util/strencodings.h>
|
2022-07-20 18:16:30 +02:00
|
|
|
#include <util/system.h>
|
2022-07-21 11:13:13 +02:00
|
|
|
#include <util/translation.h>
|
|
|
|
#include <validation.h>
|
2022-07-20 18:16:30 +02:00
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
#include <optional>
|
2022-07-21 11:13:13 +02:00
|
|
|
#include <string>
|
2022-07-20 18:16:30 +02:00
|
|
|
|
|
|
|
namespace node {
|
2022-07-21 11:13:13 +02:00
|
|
|
std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts)
|
2022-07-20 18:16:30 +02:00
|
|
|
{
|
2022-07-26 12:59:48 +02:00
|
|
|
if (auto value{args.GetBoolArg("-checkblockindex")}) opts.check_block_index = *value;
|
|
|
|
|
2022-07-26 13:52:48 +02:00
|
|
|
if (auto value{args.GetBoolArg("-checkpoints")}) opts.checkpoints_enabled = *value;
|
|
|
|
|
2022-07-21 11:13:13 +02:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2022-07-20 22:00:11 +02:00
|
|
|
if (auto value{args.GetArg("-assumevalid")}) opts.assumed_valid_block = uint256S(*value);
|
|
|
|
|
2022-07-20 18:16:30 +02:00
|
|
|
if (auto value{args.GetIntArg("-maxtipage")}) opts.max_tip_age = std::chrono::seconds{*value};
|
2022-07-21 11:13:13 +02:00
|
|
|
|
|
|
|
return std::nullopt;
|
2022-07-20 18:16:30 +02:00
|
|
|
}
|
|
|
|
} // namespace node
|