refactor: relay router and mut relay reserver#392
Conversation
| match err { | ||
| DialError::LocalPeerId { .. } => Self::LocalPeerId, | ||
| DialError::NoAddresses => Self::NoAddresses, | ||
| DialError::DialPeerConditionFalse(_) => Self::Skipped, |
There was a problem hiding this comment.
Will it be correctly handled in the on_dial_failure? It'll retry instead of skipping.
| }; | ||
| /// Builds circuit listen addresses for a relay from its transport | ||
| /// addresses: `/ip4/.../tcp/.../p2p/<relay-id>/p2p-circuit`. | ||
| fn circuit_addrs(relay_id: PeerId, addrs: &[Multiaddr]) -> Vec<Multiaddr> { |
There was a problem hiding this comment.
Would be good to have some unit test for this function
| /// Extracts the relay peer id from a circuit listen address of the form | ||
| /// `/.../p2p/<relay-id>/p2p-circuit`. Returns `None` if the address is not | ||
| /// a relay circuit address. | ||
| fn relay_id_from_circuit_addr(addr: &Multiaddr) -> Option<PeerId> { |
| /// Builds circuit dial addresses for reaching `target` through every | ||
| /// currently reserved relay: | ||
| /// `/.../p2p/<relay-id>/p2p-circuit/p2p/<target>`. | ||
| fn peer_circuit_addrs(&self, target: &PeerId) -> Vec<Multiaddr> { |
| listen_addr = %addr, | ||
| "Relay circuit listener expired; demoting to Established" | ||
| ); | ||
| self.set_relay_state(relay_id, RelayConnectionState::Established); |
There was a problem hiding this comment.
Do we need to update existing peer dial state?
There was a problem hiding this comment.
Yes, because our reservation is expired -> libp2p's relay will make a reservation -> we will handle this event properly in relay manager
| /// Applies a relay address update from a [`MutablePeer`]: refreshes | ||
| /// tracked addresses and, if this is the first time we've seen this | ||
| /// relay, kicks off a new dial campaign. | ||
| pub fn queue_relay_update(&mut self, relay: Peer) { |
There was a problem hiding this comment.
If a MutablePeer changes from one relay peer ID to another, the old relay can stay in the Reserved state and still be used for routing. Should we clear the old relay ID state when applying the update?
There was a problem hiding this comment.
This is matches charon implementation, we can keep old relays
No description provided.