Procházet zdrojové kódy

darkfid: fixed txs_batch_size arg parsing

skoupidi před 2 roky
rodič
revize
01caf27291
1 změnil soubory, kde provedl 15 přidání a 3 odebrání
  1. 15 3
      bin/darkfid/src/main.rs

+ 15 - 3
bin/darkfid/src/main.rs

@@ -160,9 +160,9 @@ pub struct BlockchainNetwork {
     /// Optional bootstrap timestamp
     /// Optional bootstrap timestamp
     pub bootstrap: Option<u64>,
     pub bootstrap: Option<u64>,
 
 
-    #[structopt(long, default_value = "50")]
+    #[structopt(long)]
     /// Garbage collection task transactions batch size
     /// Garbage collection task transactions batch size
-    pub txs_batch_size: usize,
+    pub txs_batch_size: Option<usize>,
 
 
     /// P2P network settings
     /// P2P network settings
     #[structopt(flatten)]
     #[structopt(flatten)]
@@ -298,13 +298,25 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
     } else {
     } else {
         None
         None
     };
     };
+    
+    // Grab blockchain network configured transactions batch size for garbage collection
+    let txs_batch_size = match blockchain_config.txs_batch_size {
+        Some(b) => {
+            if b > 0 {
+                b
+            } else {
+                50
+            }
+        },
+        None => 50,
+    };
 
 
     // Initialize node
     // Initialize node
     let darkfid = Darkfid::new(
     let darkfid = Darkfid::new(
         p2p.clone(),
         p2p.clone(),
         validator,
         validator,
         blockchain_config.miner,
         blockchain_config.miner,
-        blockchain_config.txs_batch_size,
+        txs_batch_size,
         subscribers,
         subscribers,
         rpc_client,
         rpc_client,
     )
     )