Syncing fix (#1320)

* Fixed aborting peer for expired session

* Don't ban for usesless
This commit is contained in:
Arkadiy Paronyan
2016-06-18 15:10:24 +02:00
committed by Gav Wood
parent 5e1e3ce857
commit ec654feaf8
3 changed files with 13 additions and 5 deletions

View File

@@ -139,6 +139,7 @@ impl<Socket: GenericSocket> GenericConnection<Socket> {
},
Ok(Some(size)) if (buf.position() as usize) == send_size => {
self.stats.inc_send(size);
trace!(target:"network", "{}: Wrote {} bytes", self.token, send_size);
Ok(WriteStatus::Complete)
},
Ok(Some(_)) => { panic!("Wrote past buffer");},

View File

@@ -250,7 +250,7 @@ impl<'s, Message> NetworkContext<'s, Message> where Message: Send + Sync + Clone
self.io.message(NetworkIoMessage::Disconnect(peer));
}
/// Sheck if the session is till active.
/// Check if the session is still active.
pub fn is_expired(&self) -> bool {
self.session.as_ref().map(|s| s.lock().unwrap().expired()).unwrap_or(false)
}
@@ -664,7 +664,6 @@ impl<Message> Host<Message> where Message: Send + Sync + Clone {
Err(e) => {
trace!(target: "network", "Session read error: {}:{:?} ({:?}) {:?}", token, s.id(), s.remote_addr(), e);
match e {
UtilError::Network(NetworkError::Disconnect(DisconnectReason::UselessPeer)) |
UtilError::Network(NetworkError::Disconnect(DisconnectReason::IncompatibleProtocol)) => {
if let Some(id) = s.id() {
self.nodes.write().unwrap().mark_as_useless(id);