mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 15:19:07 +01:00
refactor: Remove redundant call to IsArgSet
Checking for IsArgSet before calling GetArg while providing an arbitrary default value as fallback is both confusing and fragile. It is confusing, because the provided fallback is dead code. So it would be better to just call GetArg without a fallback. Even better would be to provide the true fallback value and sanitize it as if it were user-input, but this can be done in a follow-up. Removing the redundant call to IsArgSet will have to be done either way, so do it now.
This commit is contained in:
@@ -48,20 +48,20 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& argsman, const CChainP
|
||||
|
||||
// incremental relay fee sets the minimum feerate increase necessary for replacement in the mempool
|
||||
// and the amount the mempool min fee increases above the feerate of txs evicted due to mempool limiting.
|
||||
if (argsman.IsArgSet("-incrementalrelayfee")) {
|
||||
if (std::optional<CAmount> inc_relay_fee = ParseMoney(argsman.GetArg("-incrementalrelayfee", ""))) {
|
||||
if (const auto arg{argsman.GetArg("-incrementalrelayfee")}) {
|
||||
if (std::optional<CAmount> inc_relay_fee = ParseMoney(*arg)) {
|
||||
mempool_opts.incremental_relay_feerate = CFeeRate{inc_relay_fee.value()};
|
||||
} else {
|
||||
return util::Error{AmountErrMsg("incrementalrelayfee", argsman.GetArg("-incrementalrelayfee", ""))};
|
||||
return util::Error{AmountErrMsg("incrementalrelayfee", *arg)};
|
||||
}
|
||||
}
|
||||
|
||||
if (argsman.IsArgSet("-minrelaytxfee")) {
|
||||
if (std::optional<CAmount> min_relay_feerate = ParseMoney(argsman.GetArg("-minrelaytxfee", ""))) {
|
||||
if (const auto arg{argsman.GetArg("-minrelaytxfee")}) {
|
||||
if (std::optional<CAmount> min_relay_feerate = ParseMoney(*arg)) {
|
||||
// High fee check is done afterward in CWallet::Create()
|
||||
mempool_opts.min_relay_feerate = CFeeRate{min_relay_feerate.value()};
|
||||
} else {
|
||||
return util::Error{AmountErrMsg("minrelaytxfee", argsman.GetArg("-minrelaytxfee", ""))};
|
||||
return util::Error{AmountErrMsg("minrelaytxfee", *arg)};
|
||||
}
|
||||
} else if (mempool_opts.incremental_relay_feerate > mempool_opts.min_relay_feerate) {
|
||||
// Allow only setting incremental fee to control both
|
||||
@@ -71,11 +71,11 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& argsman, const CChainP
|
||||
|
||||
// Feerate used to define dust. Shouldn't be changed lightly as old
|
||||
// implementations may inadvertently create non-standard transactions
|
||||
if (argsman.IsArgSet("-dustrelayfee")) {
|
||||
if (std::optional<CAmount> parsed = ParseMoney(argsman.GetArg("-dustrelayfee", ""))) {
|
||||
if (const auto arg{argsman.GetArg("-dustrelayfee")}) {
|
||||
if (std::optional<CAmount> parsed = ParseMoney(*arg)) {
|
||||
mempool_opts.dust_relay_feerate = CFeeRate{parsed.value()};
|
||||
} else {
|
||||
return util::Error{AmountErrMsg("dustrelayfee", argsman.GetArg("-dustrelayfee", ""))};
|
||||
return util::Error{AmountErrMsg("dustrelayfee", *arg)};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user