@@ -48,6 +48,17 @@ pub enum PendingSet {
48
48
SealingOrElseQueue ,
49
49
}
50
50
51
+ /// Type of the gas limit to apply to the transaction queue.
52
+ #[ derive( Debug , PartialEq ) ]
53
+ pub enum GasLimit {
54
+ /// Depends on the block gas limit and is updated with every block.
55
+ Auto ,
56
+ /// No limit.
57
+ None ,
58
+ /// Set to a fixed gas value.
59
+ Fixed ( U256 ) ,
60
+ }
61
+
51
62
/// Configures the behaviour of the miner.
52
63
#[ derive( Debug , PartialEq ) ]
53
64
pub struct MinerOptions {
@@ -73,6 +84,8 @@ pub struct MinerOptions {
73
84
pub work_queue_size : usize ,
74
85
/// Can we submit two different solutions for the same block and expect both to result in an import?
75
86
pub enable_resubmission : bool ,
87
+ /// Global gas limit for all transaction in the queue except for local and retracted.
88
+ pub tx_queue_gas_limit : GasLimit ,
76
89
}
77
90
78
91
impl Default for MinerOptions {
@@ -89,6 +102,7 @@ impl Default for MinerOptions {
89
102
reseal_min_period : Duration :: from_secs ( 2 ) ,
90
103
work_queue_size : 20 ,
91
104
enable_resubmission : true ,
105
+ tx_queue_gas_limit : GasLimit :: Auto ,
92
106
}
93
107
}
94
108
}
@@ -210,8 +224,12 @@ impl Miner {
210
224
/// Creates new instance of miner
211
225
pub fn new ( options : MinerOptions , gas_pricer : GasPricer , spec : & Spec , accounts : Option < Arc < AccountProvider > > ) -> Arc < Miner > {
212
226
let work_poster = if !options. new_work_notify . is_empty ( ) { Some ( WorkPoster :: new ( & options. new_work_notify ) ) } else { None } ;
227
+ let gas_limit = match options. tx_queue_gas_limit {
228
+ GasLimit :: Fixed ( ref limit) => * limit,
229
+ _ => !U256 :: zero ( ) ,
230
+ } ;
213
231
let txq = Arc :: new ( Mutex :: new ( TransactionQueue :: with_limits (
214
- options. tx_queue_strategy , options. tx_queue_size , ! U256 :: zero ( ) , options. tx_gas_limit
232
+ options. tx_queue_strategy , options. tx_queue_size , gas_limit , options. tx_gas_limit
215
233
) ) ) ;
216
234
Arc :: new ( Miner {
217
235
transaction_queue : txq,
@@ -402,8 +420,10 @@ impl Miner {
402
420
let gas_limit = HeaderView :: new ( & chain. best_block_header ( ) ) . gas_limit ( ) ;
403
421
let mut queue = self . transaction_queue . lock ( ) ;
404
422
queue. set_gas_limit ( gas_limit) ;
405
- // Set total qx queue gas limit to be 2x the block gas limit.
406
- queue. set_total_gas_limit ( gas_limit << 1 ) ;
423
+ if let GasLimit :: Auto = self . options . tx_queue_gas_limit {
424
+ // Set total tx queue gas limit to be 2x the block gas limit.
425
+ queue. set_total_gas_limit ( gas_limit << 1 ) ;
426
+ }
407
427
}
408
428
409
429
/// Returns true if we had to prepare new pending block
@@ -1023,6 +1043,7 @@ mod tests {
1023
1043
tx_gas_limit : !U256 :: zero ( ) ,
1024
1044
tx_queue_size : 1024 ,
1025
1045
tx_queue_strategy : PrioritizationStrategy :: GasFactorAndGasPrice ,
1046
+ tx_queue_gas_limit : GasLimit :: None ,
1026
1047
pending_set : PendingSet :: AlwaysSealing ,
1027
1048
work_queue_size : 5 ,
1028
1049
enable_resubmission : true ,
0 commit comments