@@ -1078,13 +1078,11 @@ UniValue gettxout(const JSONRPCRequest& request)
1078
1078
1079
1079
static UniValue verifychain (const JSONRPCRequest& request)
1080
1080
{
1081
- int nCheckLevel = gArgs .GetArg (" -checklevel" , DEFAULT_CHECKLEVEL);
1082
- int nCheckDepth = gArgs .GetArg (" -checkblocks" , DEFAULT_CHECKBLOCKS);
1083
1081
RPCHelpMan{" verifychain" ,
1084
1082
" \n Verifies blockchain database.\n " ,
1085
1083
{
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." },
1088
1086
},
1089
1087
RPCResult{
1090
1088
RPCResult::Type::BOOL, " " , " Verified or not" },
@@ -1094,15 +1092,12 @@ static UniValue verifychain(const JSONRPCRequest& request)
1094
1092
},
1095
1093
}.Check (request);
1096
1094
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 ()};
1098
1097
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);
1103
1099
1104
- return CVerifyDB ().VerifyDB (
1105
- Params (), &::ChainstateActive ().CoinsTip (), nCheckLevel, nCheckDepth);
1100
+ return CVerifyDB ().VerifyDB (Params (), &::ChainstateActive ().CoinsTip (), check_level, check_depth);
1106
1101
}
1107
1102
1108
1103
static void BuriedForkDescPushBack (UniValue& softforks, const std::string &name, int height) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
0 commit comments