Skip to content

Commit

Permalink
feat(network): introduce relay reservation score
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin committed Jan 15, 2025
1 parent 4959a94 commit e66ada1
Show file tree
Hide file tree
Showing 2 changed files with 396 additions and 20 deletions.
13 changes: 13 additions & 0 deletions ant-networking/src/event/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,13 @@ impl SwarmDriver {
} => {
event_string = "incoming";
debug!("IncomingConnection ({connection_id:?}) with local_addr: {local_addr:?} send_back_addr: {send_back_addr:?}");
if let Some(relay_manager) = self.relay_manager.as_mut() {
relay_manager.on_incoming_connection(
&connection_id,
&local_addr,
&send_back_addr,
);
}
}
SwarmEvent::ConnectionEstablished {
peer_id,
Expand All @@ -378,6 +385,9 @@ impl SwarmDriver {
.on_established_incoming_connection(local_addr.clone());
}
}
if let Some(relay_manager) = self.relay_manager.as_mut() {
relay_manager.on_connection_established(&peer_id, &connection_id);
}

let _ = self.live_connected_peers.insert(
connection_id,
Expand Down Expand Up @@ -570,6 +580,9 @@ impl SwarmDriver {
external_addr_manager
.on_incoming_connection_error(local_addr.clone(), &mut self.swarm);
}
if let Some(relay_manager) = self.relay_manager.as_mut() {
relay_manager.on_incomming_connection_error(&send_back_addr, &connection_id);
}
let _ = self.live_connected_peers.remove(&connection_id);
self.record_connection_metrics();
}
Expand Down
Loading

0 comments on commit e66ada1

Please sign in to comment.