mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
Return optional error from ApplyArgsManOptions
Also pass in a (for now unused) reference to the params. Both changes are needed for the next commit.
This commit is contained in:
parent
816ca01650
commit
fa468bdfb6
5 changed files with 21 additions and 4 deletions
|
@ -44,6 +44,7 @@ if [ "${RUN_TIDY}" = "true" ]; then
|
|||
" src/dbwrapper.cpp"\
|
||||
" src/init"\
|
||||
" src/kernel"\
|
||||
" src/mempool_args.cpp"\
|
||||
" src/node/chainstate.cpp"\
|
||||
" src/policy/feerate.cpp"\
|
||||
" src/policy/packages.cpp"\
|
||||
|
|
|
@ -1418,7 +1418,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
.estimator = node.fee_estimator.get(),
|
||||
.check_ratio = chainparams.DefaultConsistencyChecks() ? 1 : 0,
|
||||
};
|
||||
ApplyArgsManOptions(args, mempool_opts);
|
||||
if (const auto err{ApplyArgsManOptions(args, chainparams, mempool_opts)}) {
|
||||
return InitError(*err);
|
||||
}
|
||||
mempool_opts.check_ratio = std::clamp<int>(mempool_opts.check_ratio, 0, 1'000'000);
|
||||
|
||||
int64_t descendant_limit_bytes = mempool_opts.limits.descendant_size_vbytes * 40;
|
||||
|
|
|
@ -7,7 +7,13 @@
|
|||
#include <kernel/mempool_limits.h>
|
||||
#include <kernel/mempool_options.h>
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util/system.h>
|
||||
#include <util/translation.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
||||
using kernel::MemPoolLimits;
|
||||
using kernel::MemPoolOptions;
|
||||
|
@ -25,7 +31,7 @@ void ApplyArgsManOptions(const ArgsManager& argsman, MemPoolLimits& mempool_limi
|
|||
}
|
||||
}
|
||||
|
||||
void ApplyArgsManOptions(const ArgsManager& argsman, MemPoolOptions& mempool_opts)
|
||||
std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& argsman, const CChainParams& chainparams, MemPoolOptions& mempool_opts)
|
||||
{
|
||||
mempool_opts.check_ratio = argsman.GetIntArg("-checkmempool", mempool_opts.check_ratio);
|
||||
|
||||
|
@ -36,4 +42,6 @@ void ApplyArgsManOptions(const ArgsManager& argsman, MemPoolOptions& mempool_opt
|
|||
mempool_opts.full_rbf = argsman.GetBoolArg("-mempoolfullrbf", mempool_opts.full_rbf);
|
||||
|
||||
ApplyArgsManOptions(argsman, mempool_opts.limits);
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
|
|
@ -5,18 +5,23 @@
|
|||
#ifndef BITCOIN_MEMPOOL_ARGS_H
|
||||
#define BITCOIN_MEMPOOL_ARGS_H
|
||||
|
||||
#include <optional>
|
||||
|
||||
class ArgsManager;
|
||||
class CChainParams;
|
||||
struct bilingual_str;
|
||||
namespace kernel {
|
||||
struct MemPoolOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Overlay the options set in \p argsman on top of corresponding members in \p mempool_opts.
|
||||
* Returns an error if one was encountered.
|
||||
*
|
||||
* @param[in] argsman The ArgsManager in which to check set options.
|
||||
* @param[in,out] mempool_opts The MemPoolOptions to modify according to \p argsman.
|
||||
*/
|
||||
void ApplyArgsManOptions(const ArgsManager& argsman, kernel::MemPoolOptions& mempool_opts);
|
||||
[[nodiscard]] std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& argsman, const CChainParams& chainparams, kernel::MemPoolOptions& mempool_opts);
|
||||
|
||||
|
||||
#endif // BITCOIN_MEMPOOL_ARGS_H
|
||||
|
|
|
@ -160,7 +160,8 @@ CTxMemPool::Options MemPoolOptionsForTest(const NodeContext& node)
|
|||
// chainparams.DefaultConsistencyChecks for tests
|
||||
.check_ratio = 1,
|
||||
};
|
||||
ApplyArgsManOptions(*node.args, mempool_opts);
|
||||
const auto err{ApplyArgsManOptions(*node.args, ::Params(), mempool_opts)};
|
||||
Assert(!err);
|
||||
return mempool_opts;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue