@@ -38,7 +38,7 @@ type Engine struct {
3838 transactions storage.Transactions
3939
4040 notifier engine.Notifier
41- inbound * fifoqueue.FifoQueue
41+ queue * fifoqueue.FifoQueue
4242
4343 component.Component
4444 cm * component.ComponentManager
@@ -48,11 +48,26 @@ type Engine struct {
4848var _ network.Engine = (* Engine )(nil )
4949var _ component.Component = (* Engine )(nil )
5050
51- func New (log zerolog.Logger , net network.EngineRegistry , state protocol.State , engMetrics module.EngineMetrics , colMetrics module.CollectionMetrics , me module.Local , collections storage.Collections , transactions storage.Transactions ) (* Engine , error ) {
52- // TODO length observer metrics
53- inbound , err := fifoqueue .NewFifoQueue (1000 )
51+ // New creates a new pusher engine.
52+ func New (
53+ log zerolog.Logger ,
54+ net network.EngineRegistry ,
55+ state protocol.State ,
56+ engMetrics module.EngineMetrics ,
57+ mempoolMetrics module.MempoolMetrics ,
58+ colMetrics module.CollectionMetrics ,
59+ me module.Local ,
60+ collections storage.Collections ,
61+ transactions storage.Transactions ,
62+ ) (* Engine , error ) {
63+ queue , err := fifoqueue .NewFifoQueue (
64+ 1000 ,
65+ fifoqueue .WithLengthObserver (func (len int ) {
66+ mempoolMetrics .MempoolEntries (metrics .ResourceSubmitCollectionGuaranteesQueue , uint (len ))
67+ }),
68+ )
5469 if err != nil {
55- return nil , fmt .Errorf ("could not create inbound fifoqueue: %w" , err )
70+ return nil , fmt .Errorf ("could not create fifoqueue: %w" , err )
5671 }
5772
5873 notifier := engine .NewNotifier ()
@@ -67,7 +82,7 @@ func New(log zerolog.Logger, net network.EngineRegistry, state protocol.State, e
6782 transactions : transactions ,
6883
6984 notifier : notifier ,
70- inbound : inbound ,
85+ queue : queue ,
7186 }
7287
7388 conduit , err := net .Register (channels .PushGuarantees , e )
@@ -107,7 +122,7 @@ func (e *Engine) outboundQueueWorker(ctx irrecoverable.SignalerContext, ready co
107122// Only returns when the queue is empty (or the engine is terminated).
108123func (e * Engine ) processOutboundMessages (ctx context.Context ) error {
109124 for {
110- nextMessage , ok := e .inbound .Pop ()
125+ nextMessage , ok := e .queue .Pop ()
111126 if ! ok {
112127 return nil
113128 }
@@ -167,9 +182,9 @@ func (e *Engine) Process(channel channels.Channel, originID flow.Identifier, mes
167182// SubmitCollectionGuarantee adds a collection guarantee to the engine's queue
168183// to later be published to consensus nodes.
169184func (e * Engine ) SubmitCollectionGuarantee (msg * messages.SubmitCollectionGuarantee ) {
170- ok := e .inbound .Push (msg )
185+ ok := e .queue .Push (msg )
171186 if ! ok {
172- e .log . Err ( fmt .Errorf ("failed to store collection guarantee in queue" ))
187+ engine . LogError ( e .log , fmt .Errorf ("failed to store collection guarantee in queue" ))
173188 return
174189 }
175190 e .notifier .Notify ()
0 commit comments