Skip to content

Commit

Permalink
Print block fetching error in Solana each 30s
Browse files Browse the repository at this point in the history
  • Loading branch information
maoueh committed Jun 3, 2024
1 parent 1fe0413 commit 3392be8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion block/fetcher/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ func (f *RPCFetcher) fetch(ctx context.Context, requestedSlot uint64) (*rpc.GetB
currentSlot := requestedSlot
var out *rpc.GetBlockResult
skipped := false
//f.logger.Info("getting block", zap.Uint64("block_num", currentSlot))

var lastErrorPrintedAt time.Time

err := derr.Retry(math.MaxUint64, func(ctx context.Context) error {
var innerErr error
out, innerErr = f.rpcClient.GetBlockWithOpts(ctx, requestedSlot, GetBlockOpts)
Expand All @@ -137,6 +139,12 @@ func (f *RPCFetcher) fetch(ctx context.Context, requestedSlot uint64) (*rpc.GetB
return nil
}
}

if lastErrorPrintedAt.IsZero() || time.Since(lastErrorPrintedAt) > 30*time.Second {
f.logger.Warn("error getting block", zap.Uint64("block_num", currentSlot), zap.Error(innerErr))
lastErrorPrintedAt = time.Now()
}

return fmt.Errorf("getting block %d from rpcClient: %w", requestedSlot, innerErr)
}
return nil
Expand Down

0 comments on commit 3392be8

Please sign in to comment.