From e479fa697ba5516f07c2002c43cc28d1e7aa6b88 Mon Sep 17 00:00:00 2001 From: "Ryan.K" Date: Fri, 5 May 2023 16:15:24 +0800 Subject: [PATCH] add act try connect --- core/src/dht/chord.rs | 2 ++ core/src/message/handlers/connection.rs | 7 +++---- core/src/swarm.rs | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/src/dht/chord.rs b/core/src/dht/chord.rs index 77cace97f..31b970391 100644 --- a/core/src/dht/chord.rs +++ b/core/src/dht/chord.rs @@ -100,6 +100,8 @@ pub enum RemoteAction { QueryForSuccessorList, /// Fetch successor_list and pred from successor QueryForSuccessorListAndPred, + /// Try connect to a Node + TryConnect(Did) } /// Information about successor and predecessor diff --git a/core/src/message/handlers/connection.rs b/core/src/message/handlers/connection.rs index 00ca56356..33f2b1bee 100644 --- a/core/src/message/handlers/connection.rs +++ b/core/src/message/handlers/connection.rs @@ -168,10 +168,9 @@ impl HandleMsg for MessageHandler { // otherwise, it will be a `send` op #[cfg(feature = "experimental")] { - if let Some(l_node) = WrappedDid::new(&self.swarm, msg.did) { - let act = self.dht.join_then_sync(l_node).await?; - handle_join_dht(self, act, ctx).await?; - } + let w_did = WrappedDid::new(&self.swarm, msg.did); + let act = self.dht.join_then_sync(w_did).await?; + handle_join_dht(self, act, ctx).await?; Ok(()) } #[cfg(not(feature = "experimental"))] diff --git a/core/src/swarm.rs b/core/src/swarm.rs index c3eb0a507..a5ec0301c 100644 --- a/core/src/swarm.rs +++ b/core/src/swarm.rs @@ -85,7 +85,8 @@ impl LiveDid for WrappedDid { // If the weak reference can be upgraded to a strong reference, check if it's connected. transport.is_connected().await } else { - // If the weak reference cannot be upgraded, the Transport has been dropped, so return false. + // If the weak reference cannot be upgraded, + // the Transport has been dropped, so return false. false } }