From 3392be80f9da72f2e502d2fa57d34d3e22bdf3c7 Mon Sep 17 00:00:00 2001 From: Matthieu Vachon Date: Mon, 3 Jun 2024 11:55:23 -0400 Subject: [PATCH] Print block fetching error in Solana each 30s --- block/fetcher/rpc.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/block/fetcher/rpc.go b/block/fetcher/rpc.go index ea884e1d..3a7e98b8 100644 --- a/block/fetcher/rpc.go +++ b/block/fetcher/rpc.go @@ -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) @@ -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