Explorar o código

darkfid/faucetd/fud: wait for p2p outbound connections

aggstam %!s(int64=4) %!d(string=hai) anos
pai
achega
5616afaf00

+ 6 - 0
bin/darkfid/src/main.rs

@@ -405,6 +405,9 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
     })
     .detach();
 
+    info!("Waiting for sync P2P outbound connections");
+    sync_p2p.clone().unwrap().wait_for_outbound().await?;
+
     match block_sync_task(sync_p2p.clone().unwrap(), state.clone()).await {
         Ok(()) => *darkfid.synced.lock().await = true,
         Err(e) => error!("Failed syncing blockchain: {}", e),
@@ -423,6 +426,9 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
         })
         .detach();
 
+        info!("Waiting for consensus P2P outbound connections");
+        consensus_p2p.clone().unwrap().wait_for_outbound().await?;
+
         info!("Starting consensus protocol task");
         ex.spawn(proposal_task(consensus_p2p.unwrap(), sync_p2p.unwrap(), state)).detach();
     } else {

+ 4 - 1
bin/faucetd/src/main.rs

@@ -409,7 +409,10 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
     })
     .detach();
 
-    match block_sync_task(sync_p2p.clone(), state.clone()).await {
+    info!("Waiting for sync P2P outbound connections");
+    sync_p2p.clone().wait_for_outbound().await?;
+
+    match block_sync_task(sync_p2p, state.clone()).await {
         Ok(()) => *faucetd.synced.lock().await = true,
         Err(e) => error!("Failed syncing blockchain: {}", e),
     }

+ 2 - 2
contrib/localnet/darkfid0.toml

@@ -34,7 +34,7 @@ consensus_p2p_external = ["tls://127.0.0.1:8341"]
 #consensus_slots = 8
 
 # Connection slots for the consensus protocol
-consensus_p2p_seed = ["tls://127.0.0.1:33033"]
+consensus_p2p_seed = ["tcp://127.0.0.1:33033"]
 
 # Peers to connect to for the consensus protocol
 #consensus_p2p_peer = []
@@ -49,7 +49,7 @@ sync_p2p_external = ["tls://127.0.0.1:8342"]
 #sync_slots = 8
 
 # Seed nodes to connect to for the syncing protocol
-sync_p2p_seed = ["tls://127.0.0.1:33032"]
+sync_p2p_seed = ["tcp://127.0.0.1:33032"]
 
 # Peers to connect to for the syncing protocol
 #sync_p2p_peer = []

+ 2 - 2
contrib/localnet/darkfid1.toml

@@ -34,7 +34,7 @@ consensus_p2p_external = ["tls://127.0.0.1:8441"]
 #consensus_slots = 8
 
 # Connection slots for the consensus protocol
-consensus_p2p_seed = ["tls://127.0.0.1:33033"]
+consensus_p2p_seed = ["tcp://127.0.0.1:33033"]
 
 # Seed nodes JSON-RPC listen URL for clock synchronization
 consensus_seed_rpc = ["tcp://127.0.0.1:8340"]
@@ -55,7 +55,7 @@ sync_p2p_external = ["tls://127.0.0.1:8442"]
 #sync_slots = 8
 
 # Seed nodes to connect to for the syncing protocol
-sync_p2p_seed = ["tls://127.0.0.1:33032"]
+sync_p2p_seed = ["tcp://127.0.0.1:33032"]
 
 # Peers to connect to for the syncing protocol
 #sync_p2p_peer = []

+ 1 - 1
contrib/localnet/darkfid2.toml

@@ -49,7 +49,7 @@ sync_p2p_external = ["tls://127.0.0.1:8542"]
 #sync_slots = 8
 
 # Seed nodes to connect to for the syncing protocol
-sync_p2p_seed = ["tls://127.0.0.1:33032"]
+sync_p2p_seed = ["tcp://127.0.0.1:33032"]
 
 # Peers to connect to for the syncing protocol
 #sync_p2p_peer = []

+ 1 - 1
contrib/localnet/faucetd.toml

@@ -31,7 +31,7 @@ sync_p2p_external = ["tls://127.0.0.1:8642"]
 #sync_slots = 8
 
 # Seed nodes to connect to for the syncing protocol
-sync_p2p_seed = ["tls://127.0.0.1:33032"]
+sync_p2p_seed = ["tcp://127.0.0.1:33032"]
 
 # Peers to connect to for the syncing protocol
 #sync_p2p_peer = []

+ 1 - 1
contrib/localnet/lilith_config.toml

@@ -7,7 +7,7 @@
 ## uncommenting, or by using the command-line.
 
 # Daemon published urls, common for all enabled networks
-urls = ["tls://127.0.0.1"]
+urls = ["tcp://127.0.0.1"]
 
 ## Per-network settings
 [network."darkfid_sync"]

+ 6 - 5
script/research/fud/fud/src/main.rs

@@ -102,12 +102,12 @@ impl Fud {
         let entries = fs::read_dir(&self.folder).unwrap();
         {
             let mut lock = self.dht.write().await;
-            
+
             // Sync lookup map with network
             if let Err(e) = lock.sync_lookup_map().await {
                 error!("Failed to sync lookup map: {}", e);
             }
-            
+
             for entry in entries {
                 let e = entry.unwrap();
                 let name = String::from(e.file_name().to_str().unwrap());
@@ -201,7 +201,7 @@ impl Fud {
             let mut lock = self.dht.write().await;
             let records = lock.map.clone();
             let mut entries_hashes = HashSet::new();
-            
+
             // We iterate files for new records
             for entry in entries {
                 let e = entry.unwrap();
@@ -321,7 +321,7 @@ impl Fud {
             }
         }
     }
-    
+
     // RPCAPI:
     // Replies to a ping method.
     // --> {"jsonrpc": "2.0", "method": "ping", "params": [], "id": 42}
@@ -405,7 +405,8 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
         }
     })
     .detach();
-    
+
+    info!("Waiting for P2P outbound connections");
     p2p.wait_for_outbound().await?;
 
     fud.init().await?;