Skip to content

Commit

Permalink
Merge pull request #6270 from filecoin-project/feat/prefactor-drand
Browse files Browse the repository at this point in the history
feat: drand: refactor round verification
  • Loading branch information
LinZexiao authored Jan 31, 2024
2 parents cfc4cab + abf13fb commit 870614d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/beacon/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,17 @@ func BeaconEntriesForBlock(ctx context.Context, bSchedule Schedule, nv network.V
prev.Round = maxRound - 1
}

cur := maxRound
var out []types.BeaconEntry
for cur > prev.Round {
rch := beacon.Entry(ctx, cur)
for currEpoch := epoch; currEpoch > parentEpoch; currEpoch-- {
currRound := beacon.MaxBeaconRoundForEpoch(nv, currEpoch)
rch := beacon.Entry(ctx, currRound)
select {
case resp := <-rch:
if resp.Err != nil {
return nil, fmt.Errorf("beacon entry request returned error: %w", resp.Err)
}

out = append(out, resp.Entry)
cur = resp.Entry.Round - 1
case <-ctx.Done():
return nil, fmt.Errorf("context timed out waiting on beacon entry to come back for epoch %d: %w", epoch, ctx.Err())
}
Expand Down

0 comments on commit 870614d

Please sign in to comment.