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.
This commit is contained in:
Sjors Provoost 2025-02-19 12:44:03 +01:00
parent f9cf8bd0ab
commit a3bf43343f
No known key found for this signature in database
GPG Key ID: 57FF9BDBCC301009

View File

@ -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;