Move ::nMinimumChainWork into ChainstateManager

This changes the minimum chain work for the bitcoin-chainstate
executable. Previously it was uint256{}, now it is the chain's default
minimum chain work.
This commit is contained in:
MacroFake
2022-07-21 11:13:13 +02:00
parent fa29d0b57c
commit cccca83099
8 changed files with 53 additions and 33 deletions

View File

@@ -4,16 +4,32 @@
#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/translation.h>
#include <validation.h>
#include <chrono>
#include <optional>
#include <string>
namespace node {
void ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts)
std::optional<bilingual_str> 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")}) opts.assumed_valid_block = uint256S(*value);
if (auto value{args.GetIntArg("-maxtipage")}) opts.max_tip_age = std::chrono::seconds{*value};
return std::nullopt;
}
} // namespace node