Skip to content

Commit 9d6c78a

Browse files
committed
fix: use a named deadline timer in CCC stage
1 parent b091e4f commit 9d6c78a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

rollup/pipeline/pipeline.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,20 @@ func (p *Pipeline) cccStage(candidates <-chan *BlockCandidate, deadline time.Tim
310310
var deadlineReached bool
311311

312312
go func() {
313+
deadlineTimer := time.NewTimer(time.Until(deadline))
313314
defer func() {
314315
close(resultCh)
316+
if !deadlineReached && !deadlineTimer.Stop() {
317+
<-deadlineTimer.C
318+
}
315319
lifetimeTimer.UpdateSince(p.start)
316320
}()
317321
for {
318322
idleStart := time.Now()
319323
select {
320-
case <-time.After(time.Until(deadline)):
324+
case <-deadlineTimer.C:
321325
cccIdleTimer.UpdateSince(idleStart)
326+
deadlineReached = true
322327
// note: currently we don't allow empty blocks, but if we ever do; make sure to CCC check it first
323328
if lastCandidate != nil {
324329
resultCh <- &Result{
@@ -327,9 +332,6 @@ func (p *Pipeline) cccStage(candidates <-chan *BlockCandidate, deadline time.Tim
327332
}
328333
return
329334
}
330-
deadlineReached = true
331-
// avoid deadline case being triggered again and again
332-
deadline = time.Now().Add(time.Hour)
333335
case candidate := <-candidates:
334336
cccIdleTimer.UpdateSince(idleStart)
335337
cccStart := time.Now()

0 commit comments

Comments
 (0)