From ce7b5b03adfade17ab1412ebf774651d15e933ad Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Thu, 4 Feb 2016 03:44:40 +0300 Subject: [PATCH] sync test temp fix --- ethcore/src/block_queue.rs | 4 +++- sync/src/chain.rs | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ethcore/src/block_queue.rs b/ethcore/src/block_queue.rs index 1fe31ba19..009ab6bf7 100644 --- a/ethcore/src/block_queue.rs +++ b/ethcore/src/block_queue.rs @@ -79,6 +79,8 @@ struct Verification { bad: HashSet, } +const MAX_UNVERIFIED_QUEUE_SIZE: usize = 50000; + impl BlockQueue { /// Creates a new queue instance. pub fn new(engine: Arc>, message_channel: IoChannel) -> BlockQueue { @@ -290,7 +292,7 @@ impl BlockQueue { pub fn queue_info(&self) -> BlockQueueInfo { let verification = self.verification.lock().unwrap(); BlockQueueInfo { - full: false, + full: verification.unverified.len() + verification.verifying.len() >= MAX_UNVERIFIED_QUEUE_SIZE, verified_queue_size: verification.verified.len(), unverified_queue_size: verification.unverified.len(), verifying_queue_size: verification.verifying.len(), diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 9752a5013..9ae00670f 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -292,7 +292,7 @@ impl ChainSync { trace!(target: "sync", "Ignored unexpected block headers"); return Ok(()); } - if self.state == SyncState::Waiting { + if io.chain().queue_info().full { trace!(target: "sync", "Ignored block headers while waiting"); return Ok(()); } @@ -376,7 +376,7 @@ impl ChainSync { trace!(target: "sync", "Ignored unexpected block bodies"); return Ok(()); } - if self.state == SyncState::Waiting { + if io.chain().queue_info().full { trace!(target: "sync", "Ignored block bodies while waiting"); return Ok(()); } @@ -532,7 +532,7 @@ impl ChainSync { /// Enter waiting state fn pause_sync(&mut self) { trace!(target: "sync", "Block queue full, pausing sync"); - self.state = SyncState::Waiting; + //self.state = SyncState::Waiting; } /// Find something to do for a peer. Called for a new peer or when a peer is done with it's task.