Skip to content

Commit

Permalink
Listen to the blockchain state event which fires when syncing also, s…
Browse files Browse the repository at this point in the history
…o that we show healthy when syncing
  • Loading branch information
cmmarslender committed Jun 4, 2023
1 parent 9509131 commit 6cd5a78
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down

0 comments on commit 6cd5a78

Please sign in to comment.