Skip to content

Commit

Permalink
add act try connect
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanKung committed May 8, 2023
1 parent 4f97735 commit e479fa6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions core/src/dht/chord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions core/src/message/handlers/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,9 @@ impl HandleMsg<JoinDHT> 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"))]
Expand Down
3 changes: 2 additions & 1 deletion core/src/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit e479fa6

Please sign in to comment.