diff --git a/internal/rpcserver/rpcserver.go b/internal/rpcserver/rpcserver.go index 70f7abff6d..5d4c5e91c2 100644 --- a/internal/rpcserver/rpcserver.go +++ b/internal/rpcserver/rpcserver.go @@ -2035,10 +2035,10 @@ func handleGetBlockchainInfo(_ context.Context, s *Server, cmd interface{}) (int } // Estimate the verification progress of the node. - syncHeight := s.cfg.SyncMgr.SyncHeight() var verifyProgress float64 - if syncHeight > 0 { - verifyProgress = math.Min(float64(best.Height)/float64(syncHeight), 1.0) + if bestHeaderHeight > 0 { + progress := float64(best.Height) / float64(bestHeaderHeight) + verifyProgress = math.Min(progress, 1.0) } // Fetch the maximum allowed block size for all blocks other than the @@ -2101,7 +2101,7 @@ func handleGetBlockchainInfo(_ context.Context, s *Server, cmd interface{}) (int Chain: params.Name, Blocks: best.Height, Headers: bestHeaderHeight, - SyncHeight: syncHeight, + SyncHeight: s.cfg.SyncMgr.SyncHeight(), ChainWork: fmt.Sprintf("%064x", chainWork), InitialBlockDownload: !chain.IsCurrent(), VerificationProgress: verifyProgress, diff --git a/internal/rpcserver/rpcserverhandlers_test.go b/internal/rpcserver/rpcserverhandlers_test.go index 0ca81a350c..53267ad57c 100644 --- a/internal/rpcserver/rpcserverhandlers_test.go +++ b/internal/rpcserver/rpcserverhandlers_test.go @@ -3519,7 +3519,7 @@ func TestHandleGetBlockchainInfo(t *testing.T) { SyncHeight: int64(463074), ChainWork: "000000000000000000000000000000000000000000115d2833849090b0026506", InitialBlockDownload: true, - VerificationProgress: float64(0.9999978405179302), + VerificationProgress: float64(1), BestBlockHash: "00000000000000001e6ec1501c858506de1de4703d1be8bab4061126e8f61480", Difficulty: uint32(404696953), DifficultyRatio: float64(35256672611.3862),