Skip to content

Commit

Permalink
rpc: call IsInitialBlockDownload via miner interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjors committed Jun 18, 2024
1 parent dda0b08 commit a9716c5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/interfaces/mining.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class Mining
//! 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<uint256> getTipHash() = 0;

Expand Down
5 changes: 5 additions & 0 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,11 @@ class MinerImpl : public Mining
return chainman().GetParams().IsTestChain();
}

bool isInitialBlockDownload() override
{
return chainman().IsInitialBlockDownload();
}

std::optional<uint256> getTipHash() override
{
LOCK(::cs_main);
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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...");
}
}
Expand Down

0 comments on commit a9716c5

Please sign in to comment.