@@ -191,7 +191,7 @@ func (b *Builder) BuildOn(parentID flow.Identifier, setter func(*flow.HeaderBody
191191 // STEP 2: build a payload of valid transactions, while at the same
192192 // time figuring out the correct reference block ID for the collection.
193193 span , _ = b .tracer .StartSpanFromContext (ctx , trace .COLBuildOnCreatePayload )
194- payload , err := b .buildPayload (buildCtx )
194+ payload , priorityTransactionsCount , err := b .buildPayload (buildCtx )
195195 span .End ()
196196 if err != nil {
197197 return nil , fmt .Errorf ("could not build payload: %w" , err )
@@ -216,6 +216,8 @@ func (b *Builder) BuildOn(parentID flow.Identifier, setter func(*flow.HeaderBody
216216 return nil , fmt .Errorf ("could not build cluster block: %w" , err )
217217 }
218218
219+ b .metrics .ClusterBlockCreated (block , priorityTransactionsCount )
220+
219221 blockProposal , err := cluster .NewProposal (
220222 cluster.UntrustedProposal {
221223 Block : * block ,
@@ -403,8 +405,13 @@ func (b *Builder) populateFinalizedAncestryLookup(lctx lockctx.Proof, ctx *block
403405
404406// buildPayload constructs a valid payload based on transactions available in the mempool.
405407// If the mempool is empty, an empty payload will be returned.
408+ // Return values:
409+ // - *cluster.Payload: the payload that has been built.
410+ // - uint: number of prioritized transactions included in the payload.
411+ // - error: exception if failed to build the payload.
412+ //
406413// No errors are expected during normal operation.
407- func (b * Builder ) buildPayload (buildCtx * blockBuildContext ) (* cluster.Payload , error ) {
414+ func (b * Builder ) buildPayload (buildCtx * blockBuildContext ) (* cluster.Payload , uint , error ) {
408415 lookup := buildCtx .lookup
409416 limiter := buildCtx .limiter
410417 config := buildCtx .config
@@ -469,7 +476,7 @@ func (b *Builder) buildPayload(buildCtx *blockBuildContext) (*cluster.Payload, e
469476 continue // in case we are configured with liberal transaction ingest rules
470477 }
471478 if err != nil {
472- return nil , fmt .Errorf ("could not retrieve reference header: %w" , err )
479+ return nil , 0 , fmt .Errorf ("could not retrieve reference header: %w" , err )
473480 }
474481
475482 // disallow un-finalized reference blocks, and reference blocks beyond the cluster's operating epoch
@@ -480,7 +487,7 @@ func (b *Builder) buildPayload(buildCtx *blockBuildContext) (*cluster.Payload, e
480487 // make sure the reference block is finalized and not orphaned
481488 blockIDFinalizedAtRefHeight , err := b .mainHeaders .BlockIDByHeight (refHeader .Height )
482489 if err != nil {
483- return nil , fmt .Errorf ("could not check that reference block (id=%x) for transaction (id=%x) is finalized: %w" , tx .ReferenceBlockID , txID , err )
490+ return nil , 0 , fmt .Errorf ("could not check that reference block (id=%x) for transaction (id=%x) is finalized: %w" , tx .ReferenceBlockID , txID , err )
484491 }
485492 if blockIDFinalizedAtRefHeight != tx .ReferenceBlockID {
486493 // the transaction references an orphaned block - it will never be valid
@@ -544,7 +551,7 @@ func (b *Builder) buildPayload(buildCtx *blockBuildContext) (*cluster.Payload, e
544551 // build the payload from the transactions
545552 collection , err := flow .NewCollection (flow.UntrustedCollection {Transactions : transactions })
546553 if err != nil {
547- return nil , fmt .Errorf ("could not build the collection from the transactions: %w" , err )
554+ return nil , 0 , fmt .Errorf ("could not build the collection from the transactions: %w" , err )
548555 }
549556
550557 payload , err := cluster .NewPayload (
@@ -554,9 +561,9 @@ func (b *Builder) buildPayload(buildCtx *blockBuildContext) (*cluster.Payload, e
554561 },
555562 )
556563 if err != nil {
557- return nil , fmt .Errorf ("could not build a payload: %w" , err )
564+ return nil , 0 , fmt .Errorf ("could not build a payload: %w" , err )
558565 }
559- return payload , nil
566+ return payload , uint ( len ( priorityTransactions )), nil
560567}
561568
562569// buildHeader constructs the header for the cluster block being built.
0 commit comments