diff options
Diffstat (limited to 'src/swarm/links.rs')
| -rw-r--r-- | src/swarm/links.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/swarm/links.rs b/src/swarm/links.rs index 7f8f0b0..14c5cf6 100644 --- a/src/swarm/links.rs +++ b/src/swarm/links.rs @@ -17,7 +17,9 @@ //! renewing) or a LINKS with 0 ends it. //! //! A member the asker can't reach (on none of its transports: one on Tor alone, asked -//! from one on libp2p alone) is asked through a peer that can (`relay_for`): a LINKS +//! from one on libp2p alone; or one that doesn't answer it, as behind NAT: as choosing +//! neighbours judges it, `topology::reaches`) is asked through a peer that can +//! (`relay_for`): a LINKS //! naming the members (`of`) asks the receiver to ask them on the sender's behalf, and //! to pass their links on (`relayed`). The receiver asks each itself, or through a peer //! of its own while hops are left (`hops`), for as long as the sender asked, and holds @@ -362,7 +364,7 @@ async fn split( if member == state.local_id() || Some(member.as_str()) == exclude { continue; } - if state.transport.can_reach(&member) { + if topology::reaches(state, &member).await { direct.push(member); } else if let Some(relay) = relay_for(state, &member, exclude).await { through.entry(relay).or_default().push(member); @@ -372,7 +374,7 @@ async fn split( } /// The peer to ask `member` through, which we can't reach: an active member we reach -/// that, by the member list, is on a transport `member` is on; else one on a transport +/// (that answers us) that, by the member list, is on a transport `member` is on; else one on a transport /// we aren't on (it may know one that is). Of several, the one with the lowest pair score /// with `member` (`topology::pair_score`), so askers pick alike. Not `exclude`. async fn relay_for(state: &AppState, member: &str, exclude: Option<&str>) -> Option<String> { @@ -385,7 +387,8 @@ async fn relay_for(state: &AppState, member: &str, exclude: Option<&str>) -> Opt } { let peer_state = peer_state.lock().await; - if peer_state.liveness.is_dormant() + if peer_state.is_unreachable() + || peer_state.liveness.is_dormant() || !matches!(peer_state.standing, crate::state::Standing::Member { .. }) { continue; |
