Skip to content

Commit 28033e8

Browse files
committed
Prevent multiple Start() calls across components
1 parent 8d68835 commit 28033e8

6 files changed

Lines changed: 15 additions & 8 deletions

File tree

block/internal/cache/manager.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,6 @@ func (m *implementation) CleanupOldTxs(olderThan time.Duration) int {
246246
return true
247247
})
248248

249-
if removed > 0 {
250-
m.logger.Debug().
251-
Int("removed", removed).
252-
Dur("older_than", olderThan).
253-
Msg("cleaned up old transaction hashes from cache")
254-
}
255-
256249
return removed
257250
}
258251

block/internal/executing/executor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ func (e *Executor) SetBlockProducer(bp BlockProducer) {
163163

164164
// Start begins the execution component
165165
func (e *Executor) Start(ctx context.Context) error {
166+
if e.cancel != nil {
167+
return errors.New("executor already started")
168+
}
166169
e.ctx, e.cancel = context.WithCancel(ctx)
167170

168171
// Initialize state

block/internal/pruner/pruner.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ func New(
5252

5353
// Start begins the pruning loop.
5454
func (p *Pruner) Start(ctx context.Context) error {
55+
if p.cancel != nil {
56+
return errors.New("pruner already started")
57+
}
5558
if !p.cfg.IsPruningEnabled() {
5659
p.logger.Info().Msg("pruning is disabled, not starting pruner")
5760
return nil

block/internal/reaping/reaper.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ func NewReaper(
6969

7070
// Start begins the execution component
7171
func (r *Reaper) Start(ctx context.Context) error {
72+
if r.cancel != nil {
73+
return errors.New("reaper already started")
74+
}
7275
r.ctx, r.cancel = context.WithCancel(ctx)
7376

74-
// Start reaper loop
7577
r.wg.Go(r.reaperLoop)
7678

7779
r.logger.Info().Dur("idle_interval", r.interval).Msg("reaper started")

block/internal/submitting/submitter.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ func NewSubmitter(
119119

120120
// Start begins the submitting component
121121
func (s *Submitter) Start(ctx context.Context) error {
122+
if s.cancel != nil {
123+
return errors.New("submitter already started")
124+
}
122125
s.ctx, s.cancel = context.WithCancel(ctx)
123126

124127
// Initialize DA included height

block/internal/syncing/syncer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ func (s *Syncer) SetBlockSyncer(bs BlockSyncer) {
163163

164164
// Start begins the syncing component
165165
func (s *Syncer) Start(ctx context.Context) (err error) {
166+
if s.cancel != nil {
167+
return errors.New("syncer already started")
168+
}
166169
ctx, cancel := context.WithCancel(ctx)
167170
s.ctx, s.cancel = ctx, cancel
168171

0 commit comments

Comments
 (0)