Skip to content

Commit

Permalink
do 1 more fetch before subscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Jan 23, 2025
1 parent 06e73c1 commit b506084
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ func (s *Store[H]) GetByHeight(ctx context.Context, height uint64) (H, error) {
return zero, errors.New("header/store: height must be bigger than zero")
}

if h, err := s.getByHeight(ctx, height); err == nil || ctx.Err() != nil {
return h, err
}

// if the requested 'height' was not yet published
// we subscribe to it
if head := s.contiguousHead.Load(); head == nil || height > (*head).Height() {
Expand Down

0 comments on commit b506084

Please sign in to comment.