Skip to content

Commit

Permalink
network-devp2p: handle UselessPeer disconnect (openethereum#8686)
Browse files Browse the repository at this point in the history
  • Loading branch information
andresilva authored and niklasad1 committed May 29, 2018
1 parent ec9c6e9 commit 68d16b7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions util/network-devp2p/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,14 +686,17 @@ impl Host {
Err(e) => {
let s = session.lock();
trace!(target: "network", "Session read error: {}:{:?} ({:?}) {:?}", token, s.id(), s.remote_addr(), e);
if let ErrorKind::Disconnect(DisconnectReason::IncompatibleProtocol) = *e.kind() {
if let Some(id) = s.id() {
if !self.reserved_nodes.read().contains(id) {
let mut nodes = self.nodes.write();
nodes.note_failure(&id);
nodes.mark_as_useless(id);
match *e.kind() {
ErrorKind::Disconnect(DisconnectReason::IncompatibleProtocol) | ErrorKind::Disconnect(DisconnectReason::UselessPeer) => {
if let Some(id) = s.id() {
if !self.reserved_nodes.read().contains(id) {
let mut nodes = self.nodes.write();
nodes.note_failure(&id);
nodes.mark_as_useless(id);
}
}
}
},
_ => {},
}
kill = true;
break;
Expand Down

0 comments on commit 68d16b7

Please sign in to comment.