Fixed loosing peers on incoming connections. (#1293)

* Deactivate peer if it has no new data

* Fixed node table timer registration

* Fixed handshake timeout expiration

* Extra trace

* Fixed session count calculation

* Only deactivate incapable peers in ChainHead state

* Timer registration is not needed
This commit is contained in:
Arkadiy Paronyan
2016-06-15 19:01:58 +02:00
committed by Gav Wood
parent 549647b6f2
commit 7284df9bf5
3 changed files with 15 additions and 5 deletions

View File

@@ -405,6 +405,7 @@ impl ChainSync {
}
if item_count == 0 && (self.state == SyncState::Blocks || self.state == SyncState::NewBlocks) {
self.deactivate_peer(io, peer_id); //TODO: is this too harsh?
self.continue_sync(io);
return Ok(());
}
@@ -452,7 +453,12 @@ impl ChainSync {
// Disable the peer for this syncing round if it gives invalid chain
if !valid_response {
trace!(target: "sync", "{} Disabled for invalid headers response", peer_id);
trace!(target: "sync", "{} Deactivated for invalid headers response", peer_id);
self.deactivate_peer(io, peer_id);
}
if headers.is_empty() && self.state == SyncState::ChainHead {
// Peer does not have any new subchain heads, deactivate it nd try with another
trace!(target: "sync", "{} Deactivated for no data", peer_id);
self.deactivate_peer(io, peer_id);
}
match self.state {