From 5e45cfc80e610ae3dd9ad37b017379c1cf496d57 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 6 Sep 2018 21:36:41 +0200 Subject: [PATCH] Fixed sync stalling when import queue is full --- Cargo.lock | 6 +++--- substrate/network/src/sync.rs | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 593f424f912f7..dd2259a19008e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1835,7 +1835,7 @@ dependencies = [ [[package]] name = "polkadot" -version = "0.2.11" +version = "0.2.12" dependencies = [ "ctrlc 1.1.1 (git+https://github.com/paritytech/rust-ctrlc.git)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1880,7 +1880,7 @@ dependencies = [ "polkadot-service 0.2.2", "polkadot-transaction-pool 0.1.0", "slog 2.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-cli 0.2.11", + "substrate-cli 0.2.12", "substrate-client 0.1.0", "substrate-codec 0.1.0", "substrate-extrinsic-pool 0.1.0", @@ -2674,7 +2674,7 @@ dependencies = [ [[package]] name = "substrate-cli" -version = "0.2.11" +version = "0.2.12" dependencies = [ "ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/substrate/network/src/sync.rs b/substrate/network/src/sync.rs index 517683a720718..ca2a3e7ba0c9a 100644 --- a/substrate/network/src/sync.rs +++ b/substrate/network/src/sync.rs @@ -237,6 +237,14 @@ impl ChainSync { let is_best = new_blocks.first().and_then(|b| b.block.header.as_ref()).map(|h| best_seen.as_ref().map_or(false, |n| h.number() >= n)); let origin = if is_best.unwrap_or_default() { BlockOrigin::NetworkBroadcast } else { BlockOrigin::NetworkInitialSync }; let import_queue = self.import_queue.clone(); + if let Some((hash, number)) = new_blocks.last() + .and_then(|b| b.block.header.as_ref().map(|h|(b.block.hash.clone(), *h.number()))) + { + if number > self.best_queued_number { + self.best_queued_number = number; + self.best_queued_hash = hash; + } + } import_queue.import_blocks(self, protocol, (origin, new_blocks)); self.maintain_sync(protocol); }