Sfoglia il codice sorgente

event_graph: use receive_with_timeout() instead of matchig timeout()

dasman 1 anno fa
parent
commit
86351d88fa
1 ha cambiato i file con 12 aggiunte e 15 eliminazioni
  1. 12 15
      src/event_graph/mod.rs

+ 12 - 15
src/event_graph/mod.rs

@@ -257,22 +257,19 @@ impl EventGraph {
                 continue
             };
 
-            let peer_tips = match timeout(
-                Duration::from_secs(self.p2p.settings().read().await.outbound_connect_timeout),
-                tip_rep_sub.receive(),
-            )
-            .await
-            {
-                Ok(peer_tips) => peer_tips?,
-                Err(_) => {
-                    error!(
-                        target: "event_graph::dag_sync()",
-                        "[EVENTGRAPH] Sync: Peer {} didn't reply with tips in time, skipping", url,
-                    );
-                    communicated_peers -= 1;
-                    continue
-                }
+            // Node waits for response
+            let Ok(peer_tips) = tip_rep_sub
+                .receive_with_timeout(self.p2p.settings().read().await.outbound_connect_timeout)
+                .await
+            else {
+                error!(
+                    target: "event_graph::dag_sync()",
+                    "[EVENTGRAPH] Sync: Peer {} didn't reply with tips in time, skipping", url,
+                );
+                communicated_peers -= 1;
+                continue
             };
+
             let peer_tips = &peer_tips.0;
 
             // Note down the seen tips