From 376c99c247003748af78aea650d6f3c411b10ce0 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Thu, 4 Feb 2016 04:28:16 +0300 Subject: [PATCH] moving to mainaint_sync --- sync/src/chain.rs | 14 ++++++-------- sync/src/lib.rs | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 7a3f5ee97..8b0b52080 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -985,14 +985,8 @@ impl ChainSync { } /// Handle peer timeouts - pub fn maintain_peers(&mut self, io: &mut SyncIo) { + pub fn maintain_peers(&self, io: &mut SyncIo) { let tick = time::precise_time_s(); - - if !io.chain().queue_info().full && self.state == SyncState::Waiting { - self.state = SyncState::Idle; - self.continue_sync(io); - } - for (peer_id, peer) in &self.peers { if peer.asking != PeerAsking::Nothing && (tick - peer.ask_time) > CONNECTION_TIMEOUT_SEC { io.disconnect_peer(*peer_id); @@ -1001,7 +995,11 @@ impl ChainSync { } /// Maintain other peers. Send out any new blocks and transactions - pub fn _maintain_sync(&mut self, _io: &mut SyncIo) { + pub fn maintain_sync(&mut self, io: &mut SyncIo) { + if !io.chain().queue_info().full && self.state == SyncState::Waiting { + self.state = SyncState::Idle; + self.continue_sync(io); + } } } diff --git a/sync/src/lib.rs b/sync/src/lib.rs index 40b67dc5b..f3b43396c 100644 --- a/sync/src/lib.rs +++ b/sync/src/lib.rs @@ -107,6 +107,7 @@ impl NetworkProtocolHandler for EthSync { fn timeout(&self, io: &NetworkContext, _timer: TimerToken) { self.sync.write().unwrap().maintain_peers(&mut NetSyncIo::new(io, self.chain.deref())); + self.sync.write().unwrap().maintain_sync(&mut NetSyncIo::new(io, self.chain.deref())); } }