From 6cd5a787d95aa696c91254aeae31b50dbc535427 Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Sat, 3 Jun 2023 20:29:28 -0500 Subject: [PATCH] Listen to the blockchain state event which fires when syncing also, so that we show healthy when syncing --- internal/healthcheck/healthcheck.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/healthcheck/healthcheck.go b/internal/healthcheck/healthcheck.go index 821d887..2a5485f 100644 --- a/internal/healthcheck/healthcheck.go +++ b/internal/healthcheck/healthcheck.go @@ -99,23 +99,26 @@ func (h *Healthcheck) websocketReceive(resp *types.WebsocketResponse, err error) } func (h *Healthcheck) fullNodeReceive(resp *types.WebsocketResponse) { - if resp.Command != "block" { + var blockHeight uint32 + + if resp.Command != "get_blockchain_state" { return } - block := &types.BlockEvent{} + block := &types.WebsocketBlockchainState{} err := json.Unmarshal(resp.Data, block) if err != nil { log.Errorf("Error unmarshalling: %s\n", err.Error()) return } + blockHeight = block.BlockchainState.Peak.OrEmpty().Height // Edge case, but we should be sure block height is increasing - if block.Height <= h.lastHeight { + if blockHeight <= h.lastHeight { return } - h.lastHeight = block.Height + h.lastHeight = blockHeight h.lastHeightTime = time.Now() }