Skip to content

Commit 423c41c

Browse files
authored
chore: switch if statement to be positive case in aggregator loop (#1636)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/ --> ## Overview <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. Ex: Closes #<issue number> --> Refactor discussed during onsite <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Improved the aggregation process by separating the handling of lazy and normal aggregation modes for enhanced clarity and maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 48f11d9 commit 423c41c

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

block/manager.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -335,21 +335,8 @@ func (m *Manager) AggregationLoop(ctx context.Context, lazy bool) {
335335
timer := time.NewTimer(0)
336336
defer timer.Stop()
337337

338-
if !lazy {
339-
for {
340-
select {
341-
case <-ctx.Done():
342-
return
343-
case <-timer.C:
344-
}
345-
start := time.Now()
346-
err := m.publishBlock(ctx)
347-
if err != nil && ctx.Err() == nil {
348-
m.logger.Error("error while publishing block", "error", err)
349-
}
350-
timer.Reset(m.getRemainingSleep(start))
351-
}
352-
} else {
338+
// Lazy Aggregator mode
339+
if lazy {
353340
for {
354341
select {
355342
case <-ctx.Done():
@@ -372,6 +359,21 @@ func (m *Manager) AggregationLoop(ctx context.Context, lazy bool) {
372359
}
373360
}
374361
}
362+
363+
// Normal Aggregator mode
364+
for {
365+
select {
366+
case <-ctx.Done():
367+
return
368+
case <-timer.C:
369+
}
370+
start := time.Now()
371+
err := m.publishBlock(ctx)
372+
if err != nil && ctx.Err() == nil {
373+
m.logger.Error("error while publishing block", "error", err)
374+
}
375+
timer.Reset(m.getRemainingSleep(start))
376+
}
375377
}
376378

377379
// BlockSubmissionLoop is responsible for submitting blocks to the DA layer.

0 commit comments

Comments
 (0)