@@ -93,7 +93,7 @@ export class PrivateMempool extends SequencerModule implements Mempool {
93
93
return result ?. result . afterNetworkState ;
94
94
}
95
95
96
- public async getTxs ( ) : Promise < PendingTransaction [ ] > {
96
+ public async getTxs ( limit ?: number ) : Promise < PendingTransaction [ ] > {
97
97
const txs = await this . transactionStorage . getPendingUserTransactions ( ) ;
98
98
const executionContext = container . resolve < RuntimeMethodExecutionContext > (
99
99
RuntimeMethodExecutionContext
@@ -108,7 +108,8 @@ export class PrivateMempool extends SequencerModule implements Mempool {
108
108
baseCachedStateService ,
109
109
this . protocol . stateServiceProvider ,
110
110
networkState ,
111
- executionContext
111
+ executionContext ,
112
+ limit
112
113
) ;
113
114
this . protocol . stateServiceProvider . popCurrentStateService ( ) ;
114
115
return sortedTxs ;
@@ -128,13 +129,17 @@ export class PrivateMempool extends SequencerModule implements Mempool {
128
129
baseService : CachedStateService ,
129
130
stateServiceProvider : StateServiceProvider ,
130
131
networkState : NetworkState ,
131
- executionContext : RuntimeMethodExecutionContext
132
+ executionContext : RuntimeMethodExecutionContext ,
133
+ limit ?: number
132
134
) : Promise < PendingTransaction [ ] > {
133
135
const skippedTransactions : Record < string , MempoolTransactionPaths > = { } ;
134
136
const sortedTransactions : PendingTransaction [ ] = [ ] ;
135
137
let queue : PendingTransaction [ ] = [ ...transactions ] ;
136
138
137
- while ( queue . length > 0 ) {
139
+ while (
140
+ queue . length > 0 &&
141
+ ( limit !== undefined ? sortedTransactions . length < limit : true )
142
+ ) {
138
143
const [ tx ] = queue . splice ( 0 , 1 ) ;
139
144
const txStateService = new CachedStateService ( baseService ) ;
140
145
stateServiceProvider . setCurrentStateService ( txStateService ) ;
0 commit comments