From baf5ab4b4bef057d793dc6d67170d2078761793f Mon Sep 17 00:00:00 2001 From: Panayiotis Savva Date: Mon, 18 Mar 2024 17:13:53 +0200 Subject: [PATCH] Update InitialBlockDownloadState.cs --- src/Blockcore/Base/InitialBlockDownloadState.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Blockcore/Base/InitialBlockDownloadState.cs b/src/Blockcore/Base/InitialBlockDownloadState.cs index 7a54f6aaa..6f7c0a6e2 100644 --- a/src/Blockcore/Base/InitialBlockDownloadState.cs +++ b/src/Blockcore/Base/InitialBlockDownloadState.cs @@ -55,6 +55,13 @@ public InitialBlockDownloadState(IChainState chainState, Network network, Consen /// public bool IsInitialBlockDownload() { + // The HTTP server starts up before the blockchain database is loaded, this means ConsensusTip can at startup be null. Simply + // return IBD as true if ConsensusTip is null. + if (this.chainState.ConsensusTip == null) + { + return true; + } + if (this.lastCheckpointHeight > this.chainState.ConsensusTip.Height) return true; @@ -67,4 +74,4 @@ public bool IsInitialBlockDownload() return false; } } -} \ No newline at end of file +}