diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1320,17 +1320,15 @@ static UniValue verifychain(const Config &config, const JSONRPCRequest &request) { - int nCheckLevel = gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL); - int nCheckDepth = gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS); RPCHelpMan{ "verifychain", "Verifies blockchain database.\n", { {"checklevel", RPCArg::Type::NUM, - /* default */ strprintf("%d, range=0-4", nCheckLevel), + /* default */ strprintf("%d, range=0-4", DEFAULT_CHECKLEVEL), "How thorough the block verification is."}, {"nblocks", RPCArg::Type::NUM, - /* default */ strprintf("%d, 0=all", nCheckDepth), + /* default */ strprintf("%d, 0=all", DEFAULT_CHECKBLOCKS), "The number of blocks to check."}, }, RPCResult{RPCResult::Type::BOOL, "", "Verified or not"}, @@ -1339,17 +1337,17 @@ } .Check(request); - LOCK(cs_main); + const int check_level(request.params[0].isNull() + ? DEFAULT_CHECKLEVEL + : request.params[0].get_int()); + const int check_depth{request.params[1].isNull() + ? DEFAULT_CHECKBLOCKS + : request.params[1].get_int()}; - if (!request.params[0].isNull()) { - nCheckLevel = request.params[0].get_int(); - } - if (!request.params[1].isNull()) { - nCheckDepth = request.params[1].get_int(); - } + LOCK(cs_main); return CVerifyDB().VerifyDB(config, &::ChainstateActive().CoinsTip(), - nCheckLevel, nCheckDepth); + check_level, check_depth); } static void BIP9SoftForkDescPushBack(UniValue &softforks,