From a9716c53f05082d6d89ebea51a46d4404efb12d7 Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Tue, 18 Jun 2024 21:07:51 +0200 Subject: [PATCH] rpc: call IsInitialBlockDownload via miner interface --- src/interfaces/mining.h | 3 +++ src/node/interfaces.cpp | 5 +++++ src/rpc/mining.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/interfaces/mining.h b/src/interfaces/mining.h index 6e47333fd5..b96881f67c 100644 --- a/src/interfaces/mining.h +++ b/src/interfaces/mining.h @@ -30,6 +30,9 @@ public: //! If this chain is exclusively used for testing virtual bool isTestChain() = 0; + //! Returns whether IBD is still in progress. + virtual bool isInitialBlockDownload() = 0; + //! Returns the hash for the tip of this chain virtual std::optional getTipHash() = 0; diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 68c1c598cd..e0bab6e22e 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -847,6 +847,11 @@ public: return chainman().GetParams().IsTestChain(); } + bool isInitialBlockDownload() override + { + return chainman().IsInitialBlockDownload(); + } + std::optional getTipHash() override { LOCK(::cs_main); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 9324ba4a1c..2b93c18965 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -735,7 +735,7 @@ static RPCHelpMan getblocktemplate() throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, PACKAGE_NAME " is not connected!"); } - if (chainman.IsInitialBlockDownload()) { + if (miner.isInitialBlockDownload()) { throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, PACKAGE_NAME " is in initial sync and waiting for blocks..."); } }