From 284211c18fa1ffb28aadb46ed7d92d225699149a Mon Sep 17 00:00:00 2001 From: Xiliang Chen Date: Thu, 6 Dec 2018 23:21:17 +1300 Subject: [PATCH] Fix incorrectly report bad peer issue A block request can result an empty response if the requested hight is too high, which shouldn't resulting the peer get banned just becuase it is behind --- core/network/src/sync.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/network/src/sync.rs b/core/network/src/sync.rs index 1287beffe95bd..8fbf052420ad5 100644 --- a/core/network/src/sync.rs +++ b/core/network/src/sync.rs @@ -239,6 +239,13 @@ impl ChainSync { } }, None => { + if n > As::sa(0) { + trace!(target:"sync", "Ancestry block not found for peer {}: block #{}", who, n); + let n = n - As::sa(1); + peer.state = PeerSyncState::AncestorSearch(n); + Self::request_ancestry(protocol, who, n); + return None; + } trace!(target:"sync", "Invalid response when searching for ancestor from {}", who); protocol.report_peer(who, Severity::Bad("Invalid response when searching for ancestor")); return None;