Skip to content

Commit a9716c5

Browse files
committed
rpc: call IsInitialBlockDownload via miner interface
1 parent dda0b08 commit a9716c5

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/interfaces/mining.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class Mining
3030
//! If this chain is exclusively used for testing
3131
virtual bool isTestChain() = 0;
3232

33+
//! Returns whether IBD is still in progress.
34+
virtual bool isInitialBlockDownload() = 0;
35+
3336
//! Returns the hash for the tip of this chain
3437
virtual std::optional<uint256> getTipHash() = 0;
3538

src/node/interfaces.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,11 @@ class MinerImpl : public Mining
847847
return chainman().GetParams().IsTestChain();
848848
}
849849

850+
bool isInitialBlockDownload() override
851+
{
852+
return chainman().IsInitialBlockDownload();
853+
}
854+
850855
std::optional<uint256> getTipHash() override
851856
{
852857
LOCK(::cs_main);

src/rpc/mining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ static RPCHelpMan getblocktemplate()
735735
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, PACKAGE_NAME " is not connected!");
736736
}
737737

738-
if (chainman.IsInitialBlockDownload()) {
738+
if (miner.isInitialBlockDownload()) {
739739
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, PACKAGE_NAME " is in initial sync and waiting for blocks...");
740740
}
741741
}

0 commit comments

Comments
 (0)