Skip to content

Commit fad691c

Browse files
author
MarcoFalke
committed
rpc: Make verifychain default values static, not depend on global args
1 parent fdeb445 commit fad691c

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/rpc/blockchain.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,13 +1078,11 @@ UniValue gettxout(const JSONRPCRequest& request)
10781078

10791079
static UniValue verifychain(const JSONRPCRequest& request)
10801080
{
1081-
int nCheckLevel = gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL);
1082-
int nCheckDepth = gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS);
10831081
RPCHelpMan{"verifychain",
10841082
"\nVerifies blockchain database.\n",
10851083
{
1086-
{"checklevel", RPCArg::Type::NUM, /* default */ strprintf("%d, range=0-4", nCheckLevel), "How thorough the block verification is."},
1087-
{"nblocks", RPCArg::Type::NUM, /* default */ strprintf("%d, 0=all", nCheckDepth), "The number of blocks to check."},
1084+
{"checklevel", RPCArg::Type::NUM, /* default */ strprintf("%d, range=0-4", DEFAULT_CHECKLEVEL), "How thorough the block verification is."},
1085+
{"nblocks", RPCArg::Type::NUM, /* default */ strprintf("%d, 0=all", DEFAULT_CHECKBLOCKS), "The number of blocks to check."},
10881086
},
10891087
RPCResult{
10901088
RPCResult::Type::BOOL, "", "Verified or not"},
@@ -1094,15 +1092,12 @@ static UniValue verifychain(const JSONRPCRequest& request)
10941092
},
10951093
}.Check(request);
10961094

1097-
LOCK(cs_main);
1095+
const int check_level(request.params[0].isNull() ? DEFAULT_CHECKLEVEL : request.params[0].get_int());
1096+
const int check_depth{request.params[1].isNull() ? DEFAULT_CHECKBLOCKS : request.params[1].get_int()};
10981097

1099-
if (!request.params[0].isNull())
1100-
nCheckLevel = request.params[0].get_int();
1101-
if (!request.params[1].isNull())
1102-
nCheckDepth = request.params[1].get_int();
1098+
LOCK(cs_main);
11031099

1104-
return CVerifyDB().VerifyDB(
1105-
Params(), &::ChainstateActive().CoinsTip(), nCheckLevel, nCheckDepth);
1100+
return CVerifyDB().VerifyDB(Params(), &::ChainstateActive().CoinsTip(), check_level, check_depth);
11061101
}
11071102

11081103
static void BuriedForkDescPushBack(UniValue& softforks, const std::string &name, int height) EXCLUSIVE_LOCKS_REQUIRED(cs_main)

0 commit comments

Comments
 (0)