Skip to content

Commit eb96e98

Browse files
committed
lint
1 parent cb71de0 commit eb96e98

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

sync/sync_tail.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (s *Syncer[H]) subjectiveTail(ctx context.Context, head H) (H, error) {
6363
return tail, nil
6464
}
6565

66-
toDeleteEstimate := uint64(diff / s.Params.blockTime)
66+
toDeleteEstimate := uint64(diff / s.Params.blockTime) //nolint:gosec
6767
estimatedNewTail := tail.Height() + toDeleteEstimate
6868

6969
for {
@@ -97,8 +97,8 @@ func (s *Syncer[H]) subjectiveTail(ctx context.Context, head H) (H, error) {
9797
// moveTail moves the Tail to be the given header.
9898
// It will prune the store if the new Tail is higher than the old one or
9999
// 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)
102102
if errors.Is(err, header.ErrEmptyStore) {
103103
return nil
104104
}
@@ -107,25 +107,25 @@ func (s *Syncer[H]) moveTail(ctx context.Context, new H) error {
107107
}
108108

109109
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())
113113
if err != nil {
114114
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(),
117117
err,
118118
)
119119
}
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())
122122

123123
// TODO(@Wondertan): This works but it assumes this code is only run before syncing routine starts.
124124
// If run after, it may race with other in prog syncs.
125125
// To be reworked by bsync.
126-
err := s.doSync(ctx, new, old)
126+
err := s.doSync(ctx, to, from)
127127
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)
129129
}
130130
}
131131

sync/sync_tail_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func TestSyncer_TailReconfiguration(t *testing.T) {
4141
err = syncer.Start(ctx)
4242
require.NoError(t, err)
4343
time.Sleep(time.Millisecond * 10)
44-
syncer.SyncWait(ctx)
45-
44+
err = syncer.SyncWait(ctx)
45+
require.NoError(t, err)
4646
err = syncer.Stop(ctx)
4747
require.NoError(t, err)
4848
time.Sleep(time.Millisecond * 10)

0 commit comments

Comments
 (0)