Skip to content

Commit

Permalink
refactor(sync): Add header.WithSubjectiveInit option to sync subjecti…
Browse files Browse the repository at this point in the history
…ve head request
  • Loading branch information
renaynay committed Jun 30, 2023
1 parent 780a407 commit 3e41201
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sync/sync_head.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (s *Syncer[H]) Head(ctx context.Context, _ ...header.RequestOption) (H, err
if isRecent(sbjHead, s.Params.blockTime) {
return sbjHead, nil
}
// otherwise, request head from a trusted peer, as we assume it is fully synced
// otherwise, request head from the network
//
// TODO(@Wondertan): Here is another potential networking optimization:
// * From sbjHead's timestamp and current time predict the time to the next header(TNH)
Expand Down Expand Up @@ -66,9 +66,9 @@ func (s *Syncer[H]) subjectiveHead(ctx context.Context) (H, error) {
if !isExpired(storeHead, s.Params.TrustingPeriod) {
return storeHead, nil
}
// otherwise, request head from a trusted peer
// otherwise, request head from a trusted peer via subjective initialization
log.Infow("stored head header expired", "height", storeHead.Height())
trustHead, err := s.getter.Head(ctx)
trustHead, err := s.getter.Head(ctx, header.WithSubjectiveInit)
if err != nil {
return trustHead, err
}
Expand Down

0 comments on commit 3e41201

Please sign in to comment.