Selaa lähdekoodia

darkfid/task: generate an empty fork on consensus init, before any other task is triggered

skoupidi 2 vuotta sitten
vanhempi
sitoutus
c01d121a7a

+ 4 - 0
bin/darkfid/src/task/consensus.rs

@@ -41,6 +41,10 @@ pub async fn consensus_init_task(
     recipient: Option<String>,
     ex: Arc<smol::Executor<'static>>,
 ) -> Result<()> {
+    // Generate a new fork to be able to extend
+    info!(target: "darkfid::task::consensus_init_task", "Generating new empty fork...");
+    node.validator.consensus.generate_empty_fork().await?;
+
     // Sync blockchain
     let checkpoint = if !skip_sync {
         // Parse configured checkpoint

+ 0 - 4
bin/darkfid/src/task/miner.rs

@@ -84,10 +84,6 @@ pub async fn miner_task(
     info!(target: "darkfid::task::miner_task", "Generating signing key...");
     let mut secret = SecretKey::random(&mut OsRng);
 
-    // Generate a new fork to be able to extend
-    info!(target: "darkfid::task::miner_task", "Generating new empty fork...");
-    node.validator.consensus.generate_empty_fork().await?;
-
     // Grab blocks subscriber
     let block_sub = node.subscribers.get("blocks").unwrap();
 

+ 0 - 4
bin/darkfid/src/task/sync.rs

@@ -90,10 +90,6 @@ pub async fn sync_task(node: &Darkfid, checkpoint: Option<(u32, HeaderHash)>) ->
         }
     }
 
-    // Generate a new fork to be able to extend
-    info!(target: "darkfid::task::sync_task", "Generating new empty fork...");
-    node.validator.consensus.generate_empty_fork().await?;
-
     // Sync headers and blocks
     loop {
         // Retrieve all the headers backwards until our last known one and verify them.