Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant field in service.rs #2298

Merged
merged 1 commit into from
May 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions src/network/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ pub struct ChainNetwork<TNow> {
/// [`ChainNetwork::num_pending_per_peer`].
pending_ids: slab::Slab<(PeerId, multiaddr::Multiaddr, TNow)>,

/// List of all open connections.
connections: hashbrown::HashSet<PeerId, SipHasherBuild>,

/// Identifier to assign to the next Kademlia operation that is started.
next_kademlia_operation_id: KademliaOperationId,

Expand Down Expand Up @@ -376,10 +373,6 @@ where
SipHasherBuild::new(randomness.gen()),
),
pending_ids: slab::Slab::with_capacity(config.peers_capacity),
connections: hashbrown::HashSet::with_capacity_and_hasher(
config.peers_capacity,
SipHasherBuild::new(randomness.gen()),
),
next_kademlia_operation_id: KademliaOperationId(0),
pending_kademlia_errors: VecDeque::with_capacity(4),
chains,
Expand Down Expand Up @@ -897,7 +890,7 @@ where
!= 1;

// If the peer is completely unreachable, unassign all of its slots.
if !has_any_attempt_left && !self.connections.contains(expected_peer_id) {
if !has_any_attempt_left && !self.inner.has_established_connection(expected_peer_id) {
let expected_peer_id = expected_peer_id.clone(); // Necessary for borrowck reasons.

for chain_index in 0..self.chains.len() {
Expand Down Expand Up @@ -970,9 +963,6 @@ where
num_peer_connections,
..
} if num_peer_connections.get() == 1 => {
let _was_inserted = self.connections.insert(peer_id.clone());
debug_assert!(_was_inserted);

break Some(Event::Connected(peer_id));
}
peers::Event::Connected { .. } => {
Expand All @@ -997,9 +987,6 @@ where
self.unassign_slot(*idx, &peer_id);
}

let _was_in = self.connections.remove(&peer_id);
debug_assert!(_was_in);

// Update the k-buckets.
// TODO: `Disconnected` is only generated for connections that weren't handshaking, so this is not correct
for chain in &mut self.chains {
Expand Down