Skip to content

Commit

Permalink
latestFinalizedSlot optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
billettc committed Jan 31, 2024
1 parent 1efaac8 commit 9eb03e4
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions block/fetcher/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,11 @@ func (f *RPCFetcher) Fetch(ctx context.Context, requestedSlot uint64) (out *pbbs
sleepDuration = f.latestBlockRetryInterval
}

sleepDuration = time.Duration(0)
for f.latestFinalizedSlot < requestedSlot {
time.Sleep(sleepDuration)
if f.latestFinalizedSlot < requestedSlot {
f.latestFinalizedSlot, err = f.rpcClient.GetSlot(ctx, rpc.CommitmentFinalized)
if err != nil {
return nil, false, fmt.Errorf("fetching latest finalized Slot block num: %w", err)
}

f.logger.Info("got latest finalized slot block", zap.Uint64("latest_finalized_slot", f.latestFinalizedSlot), zap.Uint64("request_block_num", requestedSlot))
//
if f.latestFinalizedSlot >= requestedSlot {
break
}
sleepDuration = f.latestBlockRetryInterval
}

blockResult, skip, err := f.fetch(ctx, requestedSlot)
Expand Down

0 comments on commit 9eb03e4

Please sign in to comment.