From a3bf43343f0d88ec9ff847a55fd48745aeebb429 Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Wed, 19 Feb 2025 12:44:03 +0100 Subject: [PATCH] rpc: drop unneeded IsRPCRunning() guards This was preventing the (hidden) waitfornewblock, waitforblock and waitforblockheight methods from being used in the GUI. The check was added in d6a5dc4a2eaa0d7348804254ca09e75fc3a858ab when these RPC methods were first introduced. They could have been dropped when dca923150e3ac10a57c23a7e29e76516d32ec10d refactored these methods to use waitTipChanged(), which already checks for shutdown. Making this change now simplifies the next commit. --- src/rpc/blockchain.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index ac1ce6285f7..f7f082af39a 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -287,9 +287,7 @@ static RPCHelpMan waitfornewblock() Mining& miner = EnsureMining(node); auto block{CHECK_NONFATAL(miner.getTip()).value()}; - if (IsRPCRunning()) { - block = timeout ? miner.waitTipChanged(block.hash, std::chrono::milliseconds(timeout)) : miner.waitTipChanged(block.hash); - } + block = timeout ? miner.waitTipChanged(block.hash, std::chrono::milliseconds(timeout)) : miner.waitTipChanged(block.hash); UniValue ret(UniValue::VOBJ); ret.pushKV("hash", block.hash.GetHex()); @@ -334,7 +332,7 @@ static RPCHelpMan waitforblock() auto block{CHECK_NONFATAL(miner.getTip()).value()}; const auto deadline{std::chrono::steady_clock::now() + 1ms * timeout}; - while (IsRPCRunning() && block.hash != hash) { + while (block.hash != hash) { if (timeout) { auto now{std::chrono::steady_clock::now()}; if (now >= deadline) break; @@ -390,7 +388,7 @@ static RPCHelpMan waitforblockheight() auto block{CHECK_NONFATAL(miner.getTip()).value()}; const auto deadline{std::chrono::steady_clock::now() + 1ms * timeout}; - while (IsRPCRunning() && block.height < height) { + while (block.height < height) { if (timeout) { auto now{std::chrono::steady_clock::now()}; if (now >= deadline) break;