Skip to content

Commit 5d59427

Browse files
committed
comment improvements
1 parent df446ed commit 5d59427

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sync/sync_tail.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import (
1414
// * Flush
1515

1616
// subjectiveTail returns the current Tail header.
17-
// It ensures the Tail is actual and valid according to Parameters.
17+
// Lazily fetching it if it doesn't exist locally or moving it to a different height.
18+
// Moving is done if either parameters are changed or tail moved outside a pruning window.
1819
func (s *Syncer[H]) subjectiveTail(ctx context.Context, head H) (H, error) {
1920
tail, err := s.store.Tail(ctx)
2021
if err != nil && !errors.Is(err, header.ErrEmptyStore) {
@@ -32,7 +33,7 @@ func (s *Syncer[H]) subjectiveTail(ctx context.Context, head H) (H, error) {
3233
fetched = true
3334
}
3435
} else if tailHeight, outdated := s.isTailHeightOutdated(tail); outdated {
35-
// hack for the case with necessary tail in the future avoiding heightSub
36+
// hack for the case with tailHeight > store.Height avoiding heightSub
3637
storeCtx, cancel := context.WithTimeout(ctx, time.Second)
3738
tail, err = s.store.GetByHeight(storeCtx, tailHeight)
3839
cancel()
@@ -95,6 +96,9 @@ func (s *Syncer[H]) subjectiveTail(ctx context.Context, head H) (H, error) {
9596
return tail, nil
9697
}
9798

99+
// moveTail moves the Tail to be the given header.
100+
// It will prune the store if the new Tail is higher than the old one or
101+
// sync up if the new Tail is lower than the old one.
98102
func (s *Syncer[H]) moveTail(ctx context.Context, new H) error {
99103
old, err := s.store.Tail(ctx)
100104
if errors.Is(err, header.ErrEmptyStore) {

0 commit comments

Comments
 (0)