Skip to content

Commit

Permalink
fix: another panic when monitor points to a chain with no blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
praetoriansentry committed Aug 9, 2023
1 parent d7325ae commit fcca917
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ func prependLatestBlocks(ctx context.Context, ms *monitorStatus, rpc *ethrpc.Cli
}

func appendOlderBlocks(ctx context.Context, ms *monitorStatus, rpc *ethrpc.Client) {
if ms.MinBlockRetrieved == nil {
log.Warn().Msg("Nil min block")
return
}
to := new(big.Int).Sub(ms.MinBlockRetrieved, one)
from := new(big.Int).Sub(to, big.NewInt(int64(batchSize-1)))
if from.Cmp(zero) < 0 {
Expand Down Expand Up @@ -157,6 +161,8 @@ func fetchBlocks(ctx context.Context, ec *ethclient.Client, ms *monitorStatus, r
return err
}

log.Debug().Uint64("PeerCount", cs.PeerCount).Uint64("ChainID", cs.ChainID.Uint64()).Uint64("HeadBlock", cs.HeadBlock).Uint64("GasPrice", cs.GasPrice.Uint64()).Msg("fetching blocks")

if isUiRendered && batchSize < 0 {
_, termHeight := ui.TerminalDimensions()
batchSize = termHeight/2 - 4
Expand Down

0 comments on commit fcca917

Please sign in to comment.