@@ -23,42 +23,24 @@ import (
2323 "github.com/ava-labs/strevm/queue"
2424)
2525
26- // Enqueue pushes a new block to the FIFO queue. It is non-blocking unless the
27- // `synchronous` argument is true, in which case it returns when either the
28- // [context.Context] is cancelled or the block has been executed.
29- //
30- // The `synchronous` argument SHOULD be true i.f.f. the chain is bootstrapping.
31- func (e * Executor ) EnqueueAccepted (ctx context.Context , block * blocks.Block , synchronous bool ) error {
32- err := e .queue .UseThenSignal (ctx , func (q * queue.FIFO [* blocks.Block ]) error {
26+ // Enqueue pushes a new block to the FIFO queue.
27+ func (e * Executor ) EnqueueAccepted (ctx context.Context , block * blocks.Block ) error {
28+ return e .queue .UseThenSignal (ctx , func (q * queue.FIFO [* blocks.Block ]) error {
3329 q .Push (block )
34- e .queueCleared .Block ()
3530 return nil
3631 })
37- if err != nil || ! synchronous {
38- return err
39- }
40- return e .queueCleared .Wait (ctx )
4132}
4233
4334func (e * Executor ) processQueue () {
4435 ctx := e .quitCtx ()
4536
4637 for {
47- type pop struct {
48- block * blocks.Block
49- emptyAfter bool
50- }
51-
52- popped , err := sink .FromMonitor (ctx , e .queue ,
38+ block , err := sink .FromMonitor (ctx , e .queue ,
5339 func (q * queue.FIFO [* blocks.Block ]) bool {
5440 return q .Len () > 0
5541 },
56- func (q * queue.FIFO [* blocks.Block ]) (pop , error ) {
57- b := q .Pop ()
58- return pop {
59- block : b ,
60- emptyAfter : q .Len () == 0 ,
61- }, nil
42+ func (q * queue.FIFO [* blocks.Block ]) (* blocks.Block , error ) {
43+ return q .Pop (), nil
6244 },
6345 )
6446 if errors .Is (err , context .Canceled ) {
@@ -72,7 +54,6 @@ func (e *Executor) processQueue() {
7254 return
7355 }
7456
75- block := popped .block
7657 switch err := e .execute (ctx , block ); {
7758 case errors .Is (err , context .Canceled ):
7859 return
@@ -86,13 +67,6 @@ func (e *Executor) processQueue() {
8667 )
8768 return
8869 }
89-
90- // This may race with a concurrent call to [VM.AcceptBlock], but that is
91- // documented and also acceptable as we only ever Wait() inside
92- // [VM.AcceptBlock].
93- if popped .emptyAfter {
94- e .queueCleared .Open ()
95- }
9670 }
9771}
9872
0 commit comments