Skip to content

Commit

Permalink
Merge pull request #4 from Chia-Network/fix-when-syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
cmmarslender authored Jun 4, 2023
2 parents 9509131 + 6cd5a78 commit 4ac8f10
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 4ac8f10

Please sign in to comment.