Skip to content

Commit

Permalink
some docs updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Jan 31, 2024
1 parent e4e05bd commit 3126f41
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sync/sync_head.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import (
// Head returns the Network Head.
//
// Known subjective head is considered network head if it is recent enough(now-timestamp<=blocktime)
// Otherwise, head is requested from a trusted peer and
// Otherwise, we attempt to request recent network head from a trusted peer and
// set as the new subjective head, assuming that trusted peer is always fully synced.
//
// The request is limited with 2 seconds and otherwise potentially unrecent header is returned.
func (s *Syncer[H]) Head(ctx context.Context, _ ...header.HeadOption[H]) (H, error) {
sbjHead, err := s.subjectiveHead(ctx)
if err != nil {
Expand All @@ -39,7 +41,7 @@ func (s *Syncer[H]) Head(ctx context.Context, _ ...header.HeadOption[H]) (H, err
}
defer s.getter.Unlock()
// limit time to get a recent header
// if can't get it - give what we have
// if we can't get it - give what we have
reqCtx, cancel := context.WithTimeout(ctx, time.Second*2) // TODO(@vgonkivs): make timeout configurable
defer cancel()
netHead, err := s.getter.Head(reqCtx, header.WithTrustedHead[H](sbjHead))
Expand Down

0 comments on commit 3126f41

Please sign in to comment.