Skip to content

Commit

Permalink
protocols/request-response: handle address change on connection
Browse files Browse the repository at this point in the history
  • Loading branch information
elenaf9 committed Nov 21, 2021
1 parent 56f1ede commit bd6622a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions protocols/request-response/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,29 @@ where
addresses
}

fn inject_address_change(
&mut self,
peer: &PeerId,
conn: &ConnectionId,
_old: &ConnectedPoint,
new: &ConnectedPoint,
) {
let new_address = match new {
ConnectedPoint::Dialer { address } => Some(address.clone()),
ConnectedPoint::Listener { .. } => None,
};
let connections = self
.connected
.get_mut(peer)
.expect("Address change can only happen on an established connection.");

let connection = connections
.iter_mut()
.find(|c| &c.id == conn)
.expect("Address change can only happen on an established connection.");
connection.address = new_address;
}

fn inject_connected(&mut self, peer: &PeerId) {
if let Some(pending) = self.pending_outbound_requests.remove(peer) {
for request in pending {
Expand Down

0 comments on commit bd6622a

Please sign in to comment.