Skip to content

Commit

Permalink
merge if
Browse files Browse the repository at this point in the history
  • Loading branch information
oblique committed Oct 5, 2023
1 parent b8e3096 commit 32586c6
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions node/src/peer_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,11 @@ impl PeerTracker {
}
}

// This is needed to avoid downgrading `Identified` state to `Connected`
if !peer_info.is_connected() {
peer_info.state = PeerState::Connected;
}

peer_info.connections.push(connection_id);

// If this is the first connection from the peer
if peer_info.connections.len() == 1 {
// If peer was not already connected from before
if !peer_info.is_connected() {
peer_info.state = PeerState::Connected;
increment_connected_peers(&self.info_tx, peer_info.trusted);
}
}
Expand All @@ -158,14 +154,13 @@ impl PeerTracker {

// If this is the last connection from the peer
if peer_info.connections.is_empty() {
decrement_connected_peers(&self.info_tx, peer_info.trusted);

if peer_info.addrs.is_empty() {
peer_info.state = PeerState::Discovered;
} else {
peer_info.state = PeerState::AddressesFound;
}

decrement_connected_peers(&self.info_tx, peer_info.trusted);
true
} else {
false
Expand Down

0 comments on commit 32586c6

Please sign in to comment.