Skip to content

Commit 31b52b3

Browse files
committed
Linter
1 parent 6024d39 commit 31b52b3

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

block/components.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (bc *Components) Stop() error {
114114
}
115115
}
116116
if bc.Syncer != nil {
117-
if err := bc.Syncer.Stop(); err != nil {
117+
if err := bc.Syncer.Stop(context.Background()); err != nil {
118118
errs = errors.Join(errs, fmt.Errorf("failed to stop syncer: %w", err))
119119
}
120120
}

block/internal/syncing/syncer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ func (s *Syncer) Start(ctx context.Context) (err error) {
165165
ctx, cancel := context.WithCancel(ctx)
166166
s.ctx, s.cancel = ctx, cancel
167167

168-
defer func() {
168+
defer func() { //nolint: contextcheck // use new context as parent can be cancelled already
169169
if err != nil {
170-
_ = s.Stop()
170+
_ = s.Stop(context.Background())
171171
}
172172
}()
173173

@@ -226,7 +226,7 @@ func (s *Syncer) Start(ctx context.Context) (err error) {
226226
}
227227

228228
// Stop shuts down the syncing component
229-
func (s *Syncer) Stop() error {
229+
func (s *Syncer) Stop(ctx context.Context) error {
230230
if s.cancel == nil {
231231
return nil
232232
}
@@ -244,7 +244,7 @@ func (s *Syncer) Stop() error {
244244
// Skip draining if we're shutting down due to a critical error (e.g. execution
245245
// client unavailable).
246246
if !s.hasCriticalError.Load() {
247-
drainCtx, drainCancel := context.WithTimeout(context.Background(), 5*time.Second)
247+
drainCtx, drainCancel := context.WithTimeout(ctx, 5*time.Second)
248248
defer drainCancel()
249249

250250
drained := 0

block/internal/syncing/syncer_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ func TestSyncer_Stop_SkipsDrainOnCriticalError(t *testing.T) {
11561156
// Stop must complete quickly — no drain, no ExecuteTxs calls
11571157
done := make(chan struct{})
11581158
go func() {
1159-
_ = s.Stop()
1159+
_ = s.Stop(t.Context())
11601160
close(done)
11611161
}()
11621162

@@ -1225,7 +1225,7 @@ func TestSyncer_Stop_DrainWorksWithoutCriticalError(t *testing.T) {
12251225
// hasCriticalError is false (default) — drain should process events including ExecuteTxs
12261226
s.wg.Go(func() {})
12271227

1228-
_ = s.Stop()
1228+
_ = s.Stop(t.Context())
12291229

12301230
// Verify ExecuteTxs was actually called during drain
12311231
mockExec.AssertExpectations(t)

node/failover.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ func (f *failoverState) runCatchupPhase(ctx context.Context) error {
255255
if err := f.bc.Syncer.Start(ctx); err != nil {
256256
return fmt.Errorf("catchup syncer start: %w", err)
257257
}
258-
defer f.bc.Syncer.Stop() // nolint:errcheck // not critical
258+
defer f.bc.Syncer.Stop(context.Background()) // nolint:errcheck,contextcheck // not critical
259259

260260
caughtUp, err := f.waitForCatchup(ctx)
261261
if err != nil {

0 commit comments

Comments
 (0)