@@ -45,20 +45,35 @@ pub struct Config {
4545}
4646
4747impl Config {
48- pub fn miner_options ( & self ) -> MinerOptions {
49- MinerOptions {
48+ pub fn miner_options ( & self ) -> Result < MinerOptions , String > {
49+ let ( reseal_on_own_parcel, reseal_on_external_parcel) = match self . mining . reseal_on_txs . as_ref ( ) {
50+ "all" => ( true , true ) ,
51+ "own" => ( true , false ) ,
52+ "ext" => ( false , true ) ,
53+ "none" => ( false , false ) ,
54+ x => {
55+ return Err ( format ! (
56+ "{} isn't a valid value for reseal-on-txs. Possible values are all, own, ext, none" ,
57+ x
58+ ) )
59+ }
60+ } ;
61+
62+ Ok ( MinerOptions {
5063 mem_pool_size : self . mining . mem_pool_size ,
5164 mem_pool_memory_limit : match self . mining . mem_pool_mem_limit {
5265 0 => None ,
5366 mem_size => Some ( mem_size * 1024 * 1024 ) ,
5467 } ,
5568 new_work_notify : self . mining . notify_work . clone ( ) ,
5669 force_sealing : self . mining . force_sealing ,
70+ reseal_on_own_parcel,
71+ reseal_on_external_parcel,
5772 reseal_min_period : Duration :: from_millis ( self . mining . reseal_min_period ) ,
5873 reseal_max_period : Duration :: from_millis ( self . mining . reseal_max_period ) ,
5974 work_queue_size : self . mining . work_queue_size ,
6075 ..MinerOptions :: default ( )
61- }
76+ } )
6277 }
6378
6479 pub fn rpc_http_config ( & self ) -> RpcHttpConfig {
@@ -142,6 +157,7 @@ pub struct Mining {
142157 pub mem_pool_mem_limit : usize ,
143158 pub notify_work : Vec < String > ,
144159 pub force_sealing : bool ,
160+ pub reseal_on_txs : String ,
145161 pub reseal_min_period : u64 ,
146162 pub reseal_max_period : u64 ,
147163 pub work_queue_size : usize ,
@@ -255,6 +271,9 @@ impl Mining {
255271 if matches. is_present ( "force-sealing" ) {
256272 self . force_sealing = true ;
257273 }
274+ if let Some ( reseal_on_txs) = matches. value_of ( "reseal-on-txs" ) {
275+ self . reseal_on_txs = reseal_on_txs. to_string ( ) ;
276+ }
258277 if let Some ( reseal_min_period) = matches. value_of ( "reseal-min-period" ) {
259278 self . reseal_min_period = reseal_min_period. parse ( ) . map_err ( |_| "Invalid period" ) ?;
260279 }
0 commit comments