From fa62c8e9df3a0e758470f4de077b879adfc1618c Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Wed, 17 Oct 2018 16:09:05 -0700 Subject: [PATCH] start import queue in chain_ops as well --- substrate/core/network/src/import_queue.rs | 10 +++++----- substrate/core/service/src/chain_ops.rs | 12 ++++++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/substrate/core/network/src/import_queue.rs b/substrate/core/network/src/import_queue.rs index 79cf19ecc0..328dc478dc 100644 --- a/substrate/core/network/src/import_queue.rs +++ b/substrate/core/network/src/import_queue.rs @@ -251,15 +251,15 @@ pub trait Link: Send { /// Get chain reference. fn chain(&self) -> &Client; /// Block imported. - fn block_imported(&self, hash: &B::Hash, number: NumberFor); + fn block_imported(&self, _hash: &B::Hash, _number: NumberFor) { } /// Maintain sync. - fn maintain_sync(&self); + fn maintain_sync(&self) { } /// Disconnect from peer. - fn useless_peer(&self, who: NodeIndex, reason: &str); + fn useless_peer(&self, _who: NodeIndex, _reason: &str) { } /// Disconnect from peer and restart sync. - fn note_useless_and_restart_sync(&self, who: NodeIndex, reason: &str); + fn note_useless_and_restart_sync(&self, _who: NodeIndex, _reason: &str) { } /// Restart sync. - fn restart(&self); + fn restart(&self) { } } /// A link implementation that connects to the network. diff --git a/substrate/core/service/src/chain_ops.rs b/substrate/core/service/src/chain_ops.rs index 38aabe7d68..a3cd5bb770 100644 --- a/substrate/core/service/src/chain_ops.rs +++ b/substrate/core/service/src/chain_ops.rs @@ -23,7 +23,7 @@ use serde_json; use client::BlockOrigin; use runtime_primitives::generic::{SignedBlock, BlockId}; use runtime_primitives::traits::{As, Block, Header}; -use network::import_queue::{ImportQueue, BlockData}; +use network::import_queue::{ImportQueue, Link, BlockData}; use network::message; use components::{self, Components, ServiceFactory, FactoryFullConfiguration, FactoryBlockNumber, RuntimeGenesis}; use new_client; @@ -87,8 +87,16 @@ pub fn export_blocks(config: FactoryFullConfiguration, exit: E, mut pub fn import_blocks(config: FactoryFullConfiguration, exit: E, mut input: R) -> error::Result<()> where F: ServiceFactory, E: Future + Send + 'static, R: Read, { + use network::ClientHandle; + + struct DummyLink(::std::sync::Arc); + impl> Link for DummyLink { + fn chain(&self) -> &ClientHandle { &*self.0 } + } + let client = new_client::(&config)?; let queue = components::FullComponents::::build_import_queue(&config, client.clone())?; + queue.start(DummyLink(client.clone()))?; let (exit_send, exit_recv) = std::sync::mpsc::channel(); ::std::thread::spawn(move || { @@ -98,7 +106,7 @@ pub fn import_blocks(config: FactoryFullConfiguration, exit: E, mut let count: u32 = Decode::decode(&mut input).ok_or("Error reading file")?; info!("Importing {} blocks", count); - let mut block_count = 0; + let mut block_count = 0; for b in 0 .. count { if exit_recv.try_recv().is_ok() { break;