mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-17 02:57:33 +02:00
Merge bitcoin/bitcoin#25153: scripted-diff: Use getInt<T> over get_int/get_int64
fa9af21878scripted-diff: Use getInt<T> over get_int/get_int64 (MacroFake) Pull request description: Seems better to see the return type directly and be able to modify it easier, as the return type is used for exceptions (in-range checking and parsing feedback). ACKs for top commit: fanquake: ACKfa9af21878Tree-SHA512: 284aa2527d0f663ca01550115025c9c64c787531d595f866c718f6ad09b9b0cac1e683a7d77f8009b75de990fd37166b44063ffa83fba8a04e9a31600b4c2725
This commit is contained in:
@@ -110,7 +110,7 @@ static const CBlockIndex* ParseHashOrHeight(const UniValue& param, ChainstateMan
|
||||
CChain& active_chain = chainman.ActiveChain();
|
||||
|
||||
if (param.isNum()) {
|
||||
const int height{param.get_int()};
|
||||
const int height{param.getInt<int>()};
|
||||
if (height < 0) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Target block height %d is negative", height));
|
||||
}
|
||||
@@ -271,7 +271,7 @@ static RPCHelpMan waitfornewblock()
|
||||
{
|
||||
int timeout = 0;
|
||||
if (!request.params[0].isNull())
|
||||
timeout = request.params[0].get_int();
|
||||
timeout = request.params[0].getInt<int>();
|
||||
|
||||
CUpdatedBlock block;
|
||||
{
|
||||
@@ -317,7 +317,7 @@ static RPCHelpMan waitforblock()
|
||||
uint256 hash(ParseHashV(request.params[0], "blockhash"));
|
||||
|
||||
if (!request.params[1].isNull())
|
||||
timeout = request.params[1].get_int();
|
||||
timeout = request.params[1].getInt<int>();
|
||||
|
||||
CUpdatedBlock block;
|
||||
{
|
||||
@@ -361,10 +361,10 @@ static RPCHelpMan waitforblockheight()
|
||||
{
|
||||
int timeout = 0;
|
||||
|
||||
int height = request.params[0].get_int();
|
||||
int height = request.params[0].getInt<int>();
|
||||
|
||||
if (!request.params[1].isNull())
|
||||
timeout = request.params[1].get_int();
|
||||
timeout = request.params[1].getInt<int>();
|
||||
|
||||
CUpdatedBlock block;
|
||||
{
|
||||
@@ -445,7 +445,7 @@ static RPCHelpMan getblockfrompeer()
|
||||
PeerManager& peerman = EnsurePeerman(node);
|
||||
|
||||
const uint256& block_hash{ParseHashV(request.params[0], "blockhash")};
|
||||
const NodeId peer_id{request.params[1].get_int64()};
|
||||
const NodeId peer_id{request.params[1].getInt<int64_t>()};
|
||||
|
||||
const CBlockIndex* const index = WITH_LOCK(cs_main, return chainman.m_blockman.LookupBlockIndex(block_hash););
|
||||
|
||||
@@ -485,7 +485,7 @@ static RPCHelpMan getblockhash()
|
||||
LOCK(cs_main);
|
||||
const CChain& active_chain = chainman.ActiveChain();
|
||||
|
||||
int nHeight = request.params[0].get_int();
|
||||
int nHeight = request.params[0].getInt<int>();
|
||||
if (nHeight < 0 || nHeight > active_chain.Height())
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
|
||||
|
||||
@@ -694,7 +694,7 @@ static RPCHelpMan getblock()
|
||||
if (request.params[1].isBool()) {
|
||||
verbosity = request.params[1].get_bool() ? 1 : 0;
|
||||
} else {
|
||||
verbosity = request.params[1].get_int();
|
||||
verbosity = request.params[1].getInt<int>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -759,7 +759,7 @@ static RPCHelpMan pruneblockchain()
|
||||
CChainState& active_chainstate = chainman.ActiveChainstate();
|
||||
CChain& active_chain = active_chainstate.m_chain;
|
||||
|
||||
int heightParam = request.params[0].get_int();
|
||||
int heightParam = request.params[0].getInt<int>();
|
||||
if (heightParam < 0) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative block height.");
|
||||
}
|
||||
@@ -1050,8 +1050,8 @@ static RPCHelpMan verifychain()
|
||||
},
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
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()};
|
||||
const int check_level{request.params[0].isNull() ? DEFAULT_CHECKLEVEL : request.params[0].getInt<int>()};
|
||||
const int check_depth{request.params[1].isNull() ? DEFAULT_CHECKBLOCKS : request.params[1].getInt<int>()};
|
||||
|
||||
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||
LOCK(cs_main);
|
||||
@@ -1585,7 +1585,7 @@ static RPCHelpMan getchaintxstats()
|
||||
if (request.params[0].isNull()) {
|
||||
blockcount = std::max(0, std::min(blockcount, pindex->nHeight - 1));
|
||||
} else {
|
||||
blockcount = request.params[0].get_int();
|
||||
blockcount = request.params[0].getInt<int>();
|
||||
|
||||
if (blockcount < 0 || (blockcount > 0 && blockcount >= pindex->nHeight)) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block count: should be between 0 and the block's height - 1");
|
||||
|
||||
Reference in New Issue
Block a user