Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hansieodendaal committed May 10, 2024
1 parent 0b94bcb commit 9bdb87a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
5 changes: 1 addition & 4 deletions comms/core/src/connectivity/connection_pool.rs
Expand Up @@ -237,10 +237,7 @@ impl ConnectionPool {
}

pub fn count_disconnected(&self) -> usize {
self.count_filtered(|c| {
c.status() == ConnectionStatus::Disconnected(Minimized::Yes) ||
c.status() == ConnectionStatus::Disconnected(Minimized::No)
})
self.count_filtered(|c| matches!(c.status(), ConnectionStatus::Disconnected(_)))
}

pub fn count_entries(&self) -> usize {
Expand Down
7 changes: 4 additions & 3 deletions comms/core/src/connectivity/manager.rs
Expand Up @@ -501,9 +501,10 @@ impl ConnectivityManagerActor {

fn clean_connection_pool(&mut self) {
let cleared_states = self.pool.filter_drain(|state| {
state.status() == ConnectionStatus::Failed ||
state.status() == ConnectionStatus::Disconnected(Minimized::Yes) ||
state.status() == ConnectionStatus::Disconnected(Minimized::No)
matches!(
state.status(),
ConnectionStatus::Failed | ConnectionStatus::Disconnected(_)
)
});

if !cleared_states.is_empty() {
Expand Down
4 changes: 1 addition & 3 deletions comms/core/src/test_utils/mocks/connection_manager.rs
Expand Up @@ -131,9 +131,7 @@ impl ConnectionManagerMock {
self.state.inc_call_count();
self.state.add_call(format!("{:?}", req)).await;
match req {
DialPeer {
node_id, mut reply_tx, ..
} => {
DialPeer { node_id, mut reply_tx } => {
// Send Ok(&mut conn) if we have an active connection, otherwise Err(DialConnectFailedAllAddresses)
let result = self
.state
Expand Down
4 changes: 0 additions & 4 deletions comms/dht/src/store_forward/service.rs
Expand Up @@ -407,10 +407,6 @@ impl StoreAndForwardService {
})
.collect::<Vec<_>>();
active_connections_with_distance.sort_by(|a, b| a.1.cmp(&b.1));
// TODO: Hansie remove this assert!
for i in 1..active_connections_with_distance.len() - 1 {
assert!(active_connections_with_distance[i].1 >= active_connections_with_distance[i - 1].1);
}
let saf_ignore_distance = active_connections_with_distance
.get(threshold - 1)
.map(|(_, distance)| distance)
Expand Down

0 comments on commit 9bdb87a

Please sign in to comment.