From aff752bfc9f0a9682f39ca884736dd8294e7e74c Mon Sep 17 00:00:00 2001 From: arkpar Date: Mon, 31 Oct 2016 11:57:13 +0100 Subject: [PATCH] Restart sync if no more peers with snapshots --- sync/src/chain.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 7f48daa71f0..dc12fc926ea 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -1047,10 +1047,6 @@ impl ChainSync { /// Resume downloading fn continue_sync(&mut self, io: &mut SyncIo) { - if (self.state == SyncState::Blocks || self.state == SyncState::NewBlocks || self.state == SyncState::Idle) - && !self.peers.values().any(|p| p.asking != PeerAsking::Nothing && p.block_set != Some(BlockSet::OldBlocks) && p.can_sync()) { - self.complete_sync(io); - } let mut peers: Vec<(PeerId, U256, u8)> = self.peers.iter().filter_map(|(k, p)| if p.can_sync() { Some((*k, p.difficulty.unwrap_or_else(U256::zero), p.protocol_version)) } else { None }).collect(); thread_rng().shuffle(&mut peers); //TODO: sort by rating @@ -1062,6 +1058,11 @@ impl ChainSync { self.sync_peer(io, p, false); } } + if (self.state != SyncState::WaitingPeers && self.state != SyncState::SnapshotWaiting && self.state != SyncState::Waiting && self.state != SyncState::Idle) + && !self.peers.values().any(|p| p.asking != PeerAsking::Nothing && p.block_set != Some(BlockSet::OldBlocks) && p.can_sync()) { + + self.complete_sync(io); + } } /// Called after all blocks have been downloaded