aboutsummaryrefslogtreecommitdiff
path: root/src/node/chainstatemanager_args.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/node/chainstatemanager_args.cpp')
-rw-r--r--src/node/chainstatemanager_args.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/node/chainstatemanager_args.cpp b/src/node/chainstatemanager_args.cpp
index bc4a815a3e..b86d0b2991 100644
--- a/src/node/chainstatemanager_args.cpp
+++ b/src/node/chainstatemanager_args.cpp
@@ -32,13 +32,20 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& args, ChainstateManage
if (auto value{args.GetBoolArg("-checkpoints")}) opts.checkpoints_enabled = *value;
if (auto value{args.GetArg("-minimumchainwork")}) {
- if (!IsHexNumber(*value)) {
- return util::Error{strprintf(Untranslated("Invalid non-hex (%s) minimum chain work value specified"), *value)};
+ if (auto min_work{uint256::FromUserHex(*value)}) {
+ opts.minimum_chain_work = UintToArith256(*min_work);
+ } else {
+ return util::Error{strprintf(Untranslated("Invalid minimum work specified (%s), must be up to %d hex digits"), *value, uint256::size() * 2)};
}
- opts.minimum_chain_work = UintToArith256(uint256S(*value));
}
- if (auto value{args.GetArg("-assumevalid")}) opts.assumed_valid_block = uint256S(*value);
+ if (auto value{args.GetArg("-assumevalid")}) {
+ if (auto block_hash{uint256::FromUserHex(*value)}) {
+ opts.assumed_valid_block = *block_hash;
+ } else {
+ return util::Error{strprintf(Untranslated("Invalid assumevalid block hash specified (%s), must be up to %d hex digits (or 0 to disable)"), *value, uint256::size() * 2)};
+ }
+ }
if (auto value{args.GetIntArg("-maxtipage")}) opts.max_tip_age = std::chrono::seconds{*value};
@@ -56,6 +63,16 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& args, ChainstateManage
opts.worker_threads_num = std::clamp(script_threads - 1, 0, MAX_SCRIPTCHECK_THREADS);
LogPrintf("Script verification uses %d additional threads\n", opts.worker_threads_num);
+ if (auto max_size = args.GetIntArg("-maxsigcachesize")) {
+ // 1. When supplied with a max_size of 0, both the signature cache and
+ // script execution cache create the minimum possible cache (2
+ // elements). Therefore, we can use 0 as a floor here.
+ // 2. Multiply first, divide after to avoid integer truncation.
+ size_t clamped_size_each = std::max<int64_t>(*max_size, 0) * (1 << 20) / 2;
+ opts.script_execution_cache_bytes = clamped_size_each;
+ opts.signature_cache_bytes = clamped_size_each;
+ }
+
return {};
}
} // namespace node