@@ -36,6 +36,32 @@ type Submitter interface {
3636 Close () error
3737}
3838
39+ // TxQueueInterface defines the interface that transaction queue implementations must satisfy.
40+ // This allows switching between different queue implementations (e.g., TxQueue and TxQueueV2).
41+ type TxQueueInterface interface {
42+ // Enqueue adds a transaction to the queue
43+ Enqueue (tx * types.Transaction )
44+
45+ // Dequeue removes and returns a transaction from the queue
46+ // Returns (transaction, true) if successful, or (nil, false) if queue is closed
47+ Dequeue () (* types.Transaction , bool )
48+
49+ // IsPending checks if a transaction is currently in the queue or being processed
50+ IsPending (txHash common.Hash ) * types.Transaction
51+
52+ // Complete marks a transaction as completed
53+ Complete (hash common.Hash )
54+
55+ // Close signals shutdown of the queue
56+ Close ()
57+
58+ // Handle processes block notifications from the synchronizer
59+ Handle (ctx context.Context , block * domain.Block ) error
60+
61+ // Stats returns statistics about processed transactions (total, invalid)
62+ Stats () (total int , invalid int )
63+ }
64+
3965var logger = flogging .MustGetLogger ("gateway.core" )
4066
4167// Gateway is the component that bridges Fabric-x and the EVM. Its API is the
@@ -49,7 +75,7 @@ type Gateway struct {
4975 chainID * big.Int
5076 ChainConfig * params.ChainConfig
5177 Signer types.Signer
52- TxQueue * TxQueue
78+ TxQueue TxQueueInterface
5379 workerCount int
5480 wg sync.WaitGroup
5581 stopOnce sync.Once
@@ -84,7 +110,7 @@ func New(ec *EndorsementClient, submitter Submitter, store Store, chainID int64,
84110 chainID : cid ,
85111 ChainConfig : cmn .BuildChainConfig (chainID ),
86112 Signer : types .LatestSignerForChainID (cid ),
87- TxQueue : NewTxQueue (),
113+ TxQueue : NewTxQueueV2 (),
88114 workerCount : workerCount ,
89115 }, nil
90116}
@@ -346,7 +372,10 @@ func (g *Gateway) Stop() error {
346372 err = g .submitter .Close ()
347373 })
348374
349- fmt .Println ("gw stats:" , g .TxQueue .total , g .TxQueue .invalid , float64 (g .TxQueue .invalid )/ float64 (g .TxQueue .total ))
375+ total , invalid := g .TxQueue .Stats ()
376+ if total > 0 {
377+ fmt .Println ("gw stats:" , total , invalid , float64 (invalid )/ float64 (total ))
378+ }
350379
351380 return err
352381}
0 commit comments