@@ -63,7 +63,7 @@ func (s *Syncer[H]) subjectiveTail(ctx context.Context, head H) (H, error) {
63
63
return tail , nil
64
64
}
65
65
66
- toDeleteEstimate := uint64 (diff / s .Params .blockTime )
66
+ toDeleteEstimate := uint64 (diff / s .Params .blockTime ) //nolint:gosec
67
67
estimatedNewTail := tail .Height () + toDeleteEstimate
68
68
69
69
for {
@@ -97,8 +97,8 @@ func (s *Syncer[H]) subjectiveTail(ctx context.Context, head H) (H, error) {
97
97
// moveTail moves the Tail to be the given header.
98
98
// It will prune the store if the new Tail is higher than the old one or
99
99
// sync up if the new Tail is lower than the old one.
100
- func (s * Syncer [H ]) moveTail (ctx context.Context , new H ) error {
101
- old , err := s .store .Tail (ctx )
100
+ func (s * Syncer [H ]) moveTail (ctx context.Context , to H ) error {
101
+ from , err := s .store .Tail (ctx )
102
102
if errors .Is (err , header .ErrEmptyStore ) {
103
103
return nil
104
104
}
@@ -107,25 +107,25 @@ func (s *Syncer[H]) moveTail(ctx context.Context, new H) error {
107
107
}
108
108
109
109
switch {
110
- case old .Height () < new .Height ():
111
- log .Infof ("move tail up from %d to %d, pruning the diff..." , old .Height (), new .Height ())
112
- err := s .store .DeleteTo (ctx , new .Height ())
110
+ case from .Height () < to .Height ():
111
+ log .Infof ("move tail up from %d to %d, pruning the diff..." , from .Height (), to .Height ())
112
+ err := s .store .DeleteTo (ctx , to .Height ())
113
113
if err != nil {
114
114
return fmt .Errorf (
115
- "deleting headers up to newly configured Tail (%d): %w" ,
116
- new .Height (),
115
+ "deleting headers up to newly configured tail (%d): %w" ,
116
+ to .Height (),
117
117
err ,
118
118
)
119
119
}
120
- case old .Height () > new .Height ():
121
- log .Infof ("move tail down from %d to %d, syncing the diff..." , old .Height (), new .Height ())
120
+ case from .Height () > to .Height ():
121
+ log .Infof ("move tail down from %d to %d, syncing the diff..." , from .Height (), to .Height ())
122
122
123
123
// TODO(@Wondertan): This works but it assumes this code is only run before syncing routine starts.
124
124
// If run after, it may race with other in prog syncs.
125
125
// To be reworked by bsync.
126
- err := s .doSync (ctx , new , old )
126
+ err := s .doSync (ctx , to , from )
127
127
if err != nil {
128
- return fmt .Errorf ("syncing the diff between old and new Tail : %w" , err )
128
+ return fmt .Errorf ("syncing the diff between from and new tail : %w" , err )
129
129
}
130
130
}
131
131
0 commit comments