Skip to content

Commit fa62707

Browse files
author
MarcoFalke
committed
rpc: Use CHECK_NONFATAL over Assert
1 parent 9b480f7 commit fa62707

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/rpc/blockchain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,14 +801,14 @@ std::optional<int> GetPruneHeight(const BlockManager& blockman, const CChain& ch
801801
// If the chain tip is pruned, everything is pruned.
802802
if (!((chain_tip->nStatus & BLOCK_HAVE_MASK) == BLOCK_HAVE_MASK)) return chain_tip->nHeight;
803803

804-
const auto& first_unpruned{*Assert(blockman.GetFirstBlock(*chain_tip, /*status_mask=*/BLOCK_HAVE_MASK, first_block))};
804+
const auto& first_unpruned{*CHECK_NONFATAL(blockman.GetFirstBlock(*chain_tip, /*status_mask=*/BLOCK_HAVE_MASK, first_block))};
805805
if (&first_unpruned == first_block) {
806806
// All blocks between first_block and chain_tip have data, so nothing is pruned.
807807
return std::nullopt;
808808
}
809809

810810
// Block before the first unpruned block is the last pruned block.
811-
return Assert(first_unpruned.pprev)->nHeight;
811+
return CHECK_NONFATAL(first_unpruned.pprev)->nHeight;
812812
}
813813

814814
static RPCHelpMan pruneblockchain()

test/lint/lint-assertions.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ def main():
2727
# checks should be used over assert. See: src/util/check.h
2828
# src/rpc/server.cpp is excluded from this check since it's mostly meta-code.
2929
exit_code = git_grep([
30-
"-nE",
31-
r"\<(A|a)ss(ume|ert) *\(.*\);",
30+
"--line-number",
31+
"--extended-regexp",
32+
r"\<(A|a)ss(ume|ert)\(",
3233
"--",
3334
"src/rpc/",
3435
"src/wallet/rpc*",
@@ -38,8 +39,9 @@ def main():
3839
# The `BOOST_ASSERT` macro requires to `#include boost/assert.hpp`,
3940
# which is an unnecessary Boost dependency.
4041
exit_code |= git_grep([
41-
"-E",
42-
r"BOOST_ASSERT *\(.*\);",
42+
"--line-number",
43+
"--extended-regexp",
44+
r"BOOST_ASSERT\(",
4345
"--",
4446
"*.cpp",
4547
"*.h",

0 commit comments

Comments
 (0)