mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
Merge bitcoin/bitcoin#31896: refactor: Remove redundant and confusing calls to IsArgSet
0000fb3fd9doc: Remove outdated and stale todo comment (MarcoFalke)fa2b529f92refactor: Remove redundant call to IsArgSet (MarcoFalke)fa29842c1frefactor: Remove IsArgSet guard when fallback value is provided (MarcoFalke) Pull request description: `IsArgSet` is problematic: * It returns whether an arg has been set, even if it has been negated. `IsArgSet` is sometimes used to check for a truthy value, which is wrong, but usually harmless. Cleanup of those cases may or may not be done in a follow-up. * In most other cases, calling it is redundant, because the immediately following `Get*Arg` calls can already return an `std::optional` nullopt value to indicate an unset arg. So relieve both issues by removing all `IsArgSet` that are redundant. ACKs for top commit: pablomartin4btc: re-ACK0000fb3fd9ryanofsky: Code review ACK0000fb3fd9. No changes since last review other than rebase. Tree-SHA512: d142d71d136b2dbd5fd005667875099777704176f5e08fdeb38f05d6afce40b435a257c5bb6a1f545459fe4f81f967cee3083ab666cb0befdef3f6234f1e3d32
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