mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 15:50: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:
13
src/init.cpp
13
src/init.cpp
@@ -1038,9 +1038,9 @@ bool AppInitParameterInteraction(const ArgsManager& args)
|
||||
|
||||
// Sanity check argument for min fee for including tx in block
|
||||
// TODO: Harmonize which arguments need sanity checking and where that happens
|
||||
if (args.IsArgSet("-blockmintxfee")) {
|
||||
if (!ParseMoney(args.GetArg("-blockmintxfee", ""))) {
|
||||
return InitError(AmountErrMsg("blockmintxfee", args.GetArg("-blockmintxfee", "")));
|
||||
if (const auto arg{args.GetArg("-blockmintxfee")}) {
|
||||
if (!ParseMoney(*arg)) {
|
||||
return InitError(AmountErrMsg("blockmintxfee", *arg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1183,11 +1183,10 @@ bool CheckHostPortOptions(const ArgsManager& args) {
|
||||
"-port",
|
||||
"-rpcport",
|
||||
}) {
|
||||
if (args.IsArgSet(port_option)) {
|
||||
const std::string port = args.GetArg(port_option, "");
|
||||
if (const auto port{args.GetArg(port_option)}) {
|
||||
uint16_t n;
|
||||
if (!ParseUInt16(port, &n) || n == 0) {
|
||||
return InitError(InvalidPortErrMsg(port_option, port));
|
||||
if (!ParseUInt16(*port, &n) || n == 0) {
|
||||
return InitError(InvalidPortErrMsg(port_option, *port));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user