diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index d53bcffdaa5..3130aa4655b 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -16,24 +16,24 @@ use std::cmp; use std::collections::{HashSet, BTreeMap, VecDeque}; -use std::io::{BufRead, BufReader}; -use std::str::{FromStr, from_utf8}; +use std::str::FromStr; +use std::str::from_utf8; use std::convert::TryFrom; -use std::sync::atomic::{AtomicI64, AtomicBool, Ordering as AtomicOrdering}; +use std::sync::atomic::{AtomicUsize, AtomicI64, AtomicBool, Ordering as AtomicOrdering}; use std::sync::{Arc, Weak}; -use std::time::{Instant, Duration}; +use std::io::{BufReader, BufRead}; +use std::time::{Duration, Instant}; use blockchain::{BlockReceipts, BlockChain, BlockChainDB, BlockProvider, TreeRoute, ImportRoute, TransactionAddress, ExtrasInsert, BlockNumberKey}; -use bytes::{Bytes, ToPretty}; -use call_contract::{CallContract, RegistryInfo}; -use ethcore_miner::pool::VerifiedTransaction; -use ethereum_types::{H256, H264, Address, U256}; -use evm::Schedule; +use bytes::Bytes; +use bytes::ToPretty; +use error::Error; +use ethereum_types::{Address, H256, H264, U256}; use hash::keccak; -use io::IoChannel; +use call_contract::CallContract; +use ethcore_miner::pool::VerifiedTransaction; use itertools::Itertools; -use journaldb; -use kvdb::{DBValue, KeyValueDB, DBTransaction}; +use kvdb::{DBTransaction, DBValue, KeyValueDB}; use parking_lot::{Mutex, RwLock}; use rand::OsRng; use rlp::PayloadInfo; @@ -46,8 +46,8 @@ use types::filter::Filter; use types::log_entry::LocalizedLogEntry; use types::receipt::{Receipt, LocalizedReceipt}; use types::{BlockNumber, header::{Header, ExtendedHeader}}; -use types::data_format::DataFormat; use vm::{EnvInfo, LastHashes}; +use types::data_format::DataFormat; use block::{LockedBlock, Drain, ClosedBlock, OpenBlock, enact_verified, SealedBlock}; use client::ancient_import::AncientVerifier; @@ -56,7 +56,7 @@ use client::{ ReopenBlock, PrepareOpenBlock, ScheduleInfo, ImportSealedBlock, BroadcastProposalBlock, ImportBlock, StateOrBlock, StateInfo, StateClient, Call, AccountData, BlockChain as BlockChainTrait, BlockProducer, SealedBlockImporter, - ClientIoMessage, BlockChainReset, ImportExportBlocks, + ClientIoMessage, BlockChainReset, ImportExportBlocks }; use client::{ BlockId, TransactionId, UncleId, TraceId, ClientConfig, BlockChainClient, @@ -85,7 +85,9 @@ use verification::queue::kind::blocks::Unverified; use verification::{PreverifiedBlock, Verifier, BlockQueue}; use verification; use ansi_term::Colour; - +use call_contract::RegistryInfo; +use io::IoChannel; +use vm::Schedule; // re-export pub use types::blockchain_info::BlockChainInfo; pub use types::block_status::BlockStatus; @@ -2579,6 +2581,7 @@ impl ProvingBlockChainClient for Client { impl SnapshotClient for Client {} + impl ImportExportBlocks for Client { fn export_blocks<'a>( &self, @@ -2634,9 +2637,9 @@ impl ImportExportBlocks for Client { let number = block.header.number(); while self.queue_info().is_full() { std::thread::sleep(Duration::from_secs(1)); } match self.import_block(block) { - Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain), _)) => { + Err(Error(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain), _)) => { trace!("Skipping block #{}: already in chain.", number); - }, + } Err(e) => { return Err(format!("Cannot import block #{}: {:?}", number, e)); }, diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index 0ba83491dab..8515cab0ad3 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -481,17 +481,17 @@ pub trait BlockChainReset { /// Provides a method for importing/exporting blocks pub trait ImportExportBlocks { - /// Export blocks to destination, with the given from, to and format argument. - /// destination could be a file or stdout. - /// If the format is hex, each block is written on a new line. - /// For binary exports, all block data is written to the same line. + /// Export blocks to destination, with the given from, to and format argument. + /// destination could be a file or stdout. + /// If the format is hex, each block is written on a new line. + /// For binary exports, all block data is written to the same line. fn export_blocks<'a>( - &self, - destination: Box, - from: BlockId, - to: BlockId, - format: Option - ) -> Result<(), String>; + &self, + destination: Box, + from: BlockId, + to: BlockId, + format: Option + ) -> Result<(), String>; /// Import blocks from destination, with the given format argument /// Source could be a file or stdout. diff --git a/ethcore/src/tests/client.rs b/ethcore/src/tests/client.rs index c369697bd09..1a836e42e7b 100644 --- a/ethcore/src/tests/client.rs +++ b/ethcore/src/tests/client.rs @@ -22,12 +22,21 @@ use ethkey::KeyPair; use hash::keccak; use io::IoChannel; use tempdir::TempDir; -use types::transaction::{PendingTransaction, Transaction, Action, Condition}; -use types::filter::Filter; -use types::view; -use types::views::BlockView; -use types::data_format::DataFormat; -use client::{BlockChainClient, BlockChainReset, Client, ClientConfig, BlockId, ChainInfo, BlockInfo, PrepareOpenBlock, ImportSealedBlock, ImportBlock, ImportExportBlocks}; +use types::{ + data_format::DataFormat, + ids::BlockId, + transaction::{PendingTransaction, Transaction, Action, Condition}, + filter::Filter, + view, + views::BlockView, +}; +use verification::queue::kind::blocks::Unverified; +use client::{Client, ClientConfig, PrepareOpenBlock, ImportSealedBlock}; +use client::traits::{ + BlockInfo, BlockChainClient, BlockChainReset, ChainInfo, + ImportExportBlocks, ImportBlock +}; +use spec; use ethereum; use executive::{Executive, TransactOptions}; use miner::{Miner, PendingOrdering, MinerService}; @@ -38,7 +47,6 @@ use test_helpers::{ generate_dummy_client, push_blocks_to_client, get_test_client_with_blocks, get_good_dummy_block_seq, generate_dummy_client_with_data, get_good_dummy_block, get_bad_state_dummy_block }; -use verification::queue::kind::blocks::Unverified; use rustc_hex::ToHex; #[test] diff --git a/parity/blockchain.rs b/parity/blockchain.rs index b9c0da421f6..6fdd92b0a8a 100644 --- a/parity/blockchain.rs +++ b/parity/blockchain.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use std::str::{FromStr, from_utf8}; +use std::str::from_utf8; use std::{io, fs}; use std::io::{BufReader, BufRead}; use std::time::{Instant, Duration}; @@ -29,6 +29,7 @@ use rlp::PayloadInfo; use ethcore::client::{ Mode, DatabaseCompactionProfile, VMType, Nonce, Balance, BlockChainClient, BlockId, BlockInfo, ImportBlock, BlockChainReset, ImportExportBlocks }; +use types::data_format::DataFormat; use ethcore::error::{ImportErrorKind, ErrorKind as EthcoreErrorKind, Error as EthcoreError}; use ethcore::miner::Miner; use ethcore::verification::queue::VerifierSettings; @@ -43,7 +44,6 @@ use user_defaults::UserDefaults; use ethcore_private_tx; use db; use ansi_term::Colour; -use types::data_format::DataFormat; #[derive(Debug, PartialEq)] pub enum BlockchainCmd {