From 304ae444ab993cbc5a37ec7b12161451fa140ec9 Mon Sep 17 00:00:00 2001 From: hashmap Date: Fri, 26 Apr 2019 20:22:07 +0200 Subject: [PATCH] Fix peer dropping (#2780) It turns out that we drop connection if we fail to process a message because of chain/store/internal error, eg we have a header already, so we refuse it and drop the peer. This pr doesn't forward this error to the peer error channel so the connection will not be dropped. --- p2p/src/conn.rs | 4 ++++ p2p/src/peer.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/p2p/src/conn.rs b/p2p/src/conn.rs index d6313929a2..f105c4db6e 100644 --- a/p2p/src/conn.rs +++ b/p2p/src/conn.rs @@ -51,6 +51,10 @@ macro_rules! try_break { match $inner { Ok(v) => Some(v), Err(Error::Connection(ref e)) if e.kind() == io::ErrorKind::WouldBlock => None, + Err(Error::Store(_)) + | Err(Error::Chain(_)) + | Err(Error::Internal) + | Err(Error::NoDandelionRelay) => None, Err(e) => { let _ = $chan.send(e); break; diff --git a/p2p/src/peer.rs b/p2p/src/peer.rs index 52eb672c7f..86b28591db 100644 --- a/p2p/src/peer.rs +++ b/p2p/src/peer.rs @@ -61,7 +61,7 @@ macro_rules! connection { ($holder:expr) => { match $holder.connection.as_ref() { Some(conn) => conn.lock(), - None => return Err(Error::Internal), + None => return Err(Error::ConnectionClose), } }; }