mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Merge #17318: replace asserts in RPC code with CHECK_NONFATAL and add linter
c98bd13e67replace asserts in RPC code with CHECK_NONFATAL and add linter (Adam Jonas) Pull request description: - Replace instances of assert in /rpc files and rpcwallet with CHECK_NONFATAL(condition) - Add a linter to prevent future usage of assert being used in RPC code ref https://github.com/bitcoin/bitcoin/pull/17192 ACKs for top commit: practicalswift: ACKc98bd13e67-- diff looks correct Tree-SHA512: a16036b6bbcca73a5334665f66e17e1756377d582317568291da1d727fc9cf8c84bac9d9bd099534e1be315345336e5f7b66b93793135155f320dc5862a2d875
This commit is contained in:
@@ -555,7 +555,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
|
||||
// Need to update only after we know CreateNewBlock succeeded
|
||||
pindexPrev = pindexPrevNew;
|
||||
}
|
||||
assert(pindexPrev);
|
||||
CHECK_NONFATAL(pindexPrev);
|
||||
CBlock* pblock = &pblocktemplate->block; // pointer for convenience
|
||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||
|
||||
@@ -597,7 +597,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
|
||||
entry.pushKV("fee", pblocktemplate->vTxFees[index_in_template]);
|
||||
int64_t nTxSigOps = pblocktemplate->vTxSigOpsCost[index_in_template];
|
||||
if (fPreSegWit) {
|
||||
assert(nTxSigOps % WITNESS_SCALE_FACTOR == 0);
|
||||
CHECK_NONFATAL(nTxSigOps % WITNESS_SCALE_FACTOR == 0);
|
||||
nTxSigOps /= WITNESS_SCALE_FACTOR;
|
||||
}
|
||||
entry.pushKV("sigops", nTxSigOps);
|
||||
@@ -686,9 +686,9 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
|
||||
int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST;
|
||||
int64_t nSizeLimit = MAX_BLOCK_SERIALIZED_SIZE;
|
||||
if (fPreSegWit) {
|
||||
assert(nSigOpLimit % WITNESS_SCALE_FACTOR == 0);
|
||||
CHECK_NONFATAL(nSigOpLimit % WITNESS_SCALE_FACTOR == 0);
|
||||
nSigOpLimit /= WITNESS_SCALE_FACTOR;
|
||||
assert(nSizeLimit % WITNESS_SCALE_FACTOR == 0);
|
||||
CHECK_NONFATAL(nSizeLimit % WITNESS_SCALE_FACTOR == 0);
|
||||
nSizeLimit /= WITNESS_SCALE_FACTOR;
|
||||
}
|
||||
result.pushKV("sigoplimit", nSigOpLimit);
|
||||
|
||||
Reference in New Issue
Block a user