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

&mut self -> &mut Self #1073

Merged
merged 2 commits into from
Apr 23, 2019
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
12 changes: 7 additions & 5 deletions core/src/swarm/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,16 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
///
/// Any incoming connection and any dialing attempt will immediately be rejected.
/// This function has no effect is the peer is already banned.
pub fn ban_peer_id(&mut self, peer_id: PeerId) {
self.banned_peers.insert(peer_id.clone());
self.raw_swarm.peer(peer_id).into_connected().map(|c| c.close());
pub fn ban_peer_id(me: &mut Self, peer_id: PeerId) {
me.banned_peers.insert(peer_id.clone());
if let Some(c) = me.raw_swarm.peer(peer_id).into_connected() {
c.close();
}
}

/// Unbans a peer.
pub fn unban_peer_id(&mut self, peer_id: PeerId) {
self.banned_peers.remove(&peer_id);
pub fn unban_peer_id(me: &mut Self, peer_id: PeerId) {
me.banned_peers.remove(&peer_id);
}
}

Expand Down