From 280df57b4313d519fb551b917a161ec153aa3912 Mon Sep 17 00:00:00 2001 From: zhangsoledad <787953403@qq.com> Date: Mon, 19 Nov 2018 20:50:46 +0800 Subject: [PATCH] refactor: remove redundant alias --- chain/src/chain.rs | 38 +++++++++---------- chain/src/error.rs | 4 +- chain/src/lib.rs | 12 +++--- db/src/lib.rs | 2 +- db/src/memorydb.rs | 2 +- miner/src/lib.rs | 12 +++--- miner/src/miner.rs | 18 ++++----- network/src/ckb_protocol_handler.rs | 2 +- network/src/discovery_service.rs | 2 +- network/src/lib.rs | 2 +- network/src/network.rs | 2 +- network/src/network_service.rs | 2 +- network/src/peers_registry.rs | 2 +- network/src/timer_service.rs | 2 +- notify/src/lib.rs | 6 +-- pool/src/lib.rs | 6 +-- pool/src/tests/pool.rs | 14 +++---- pool/src/txs_pool/pool.rs | 10 ++--- pool/src/txs_pool/types.rs | 8 ++-- rpc/src/integration_test.rs | 16 ++++---- rpc/src/lib.rs | 24 ++++++------ rpc/src/server.rs | 16 ++++---- rpc/src/service.rs | 36 +++++++++--------- script/src/lib.rs | 6 +-- script/src/syscalls/builder.rs | 2 +- script/src/syscalls/debugger.rs | 2 +- script/src/syscalls/fetch_script_hash.rs | 4 +- script/src/syscalls/mmap_cell.rs | 8 ++-- script/src/syscalls/mmap_tx.rs | 4 +- script/src/syscalls/mod.rs | 14 +++---- script/src/verify.rs | 16 ++++---- shared/src/cachedb.rs | 6 +-- shared/src/config.rs | 4 +- shared/src/error.rs | 2 +- shared/src/index.rs | 16 ++++---- shared/src/lib.rs | 10 ++--- shared/src/shared.rs | 24 ++++++------ shared/src/store.rs | 22 +++++------ spec/src/consensus.rs | 8 ++-- spec/src/lib.rs | 10 ++--- src/cli/export.rs | 10 ++--- src/cli/import.rs | 12 +++--- src/cli/run_impl.rs | 30 +++++++-------- src/helper.rs | 2 +- src/main.rs | 22 +++++------ src/setup.rs | 12 +++--- sync/src/lib.rs | 17 ++++----- .../src/relayer/block_transactions_process.rs | 6 +-- sync/src/relayer/compact_block.rs | 6 +-- sync/src/relayer/compact_block_process.rs | 4 +- .../src/relayer/get_block_proposal_process.rs | 4 +- .../relayer/get_block_transactions_process.rs | 2 +- sync/src/relayer/mod.rs | 10 ++--- sync/src/relayer/transaction_process.rs | 4 +- sync/src/synchronizer/block_fetcher.rs | 6 +-- sync/src/synchronizer/block_pool.rs | 10 ++--- sync/src/synchronizer/block_process.rs | 4 +- sync/src/synchronizer/get_blocks_process.rs | 2 +- sync/src/synchronizer/get_headers_process.rs | 4 +- sync/src/synchronizer/header_view.rs | 2 +- sync/src/synchronizer/headers_process.rs | 4 +- sync/src/synchronizer/mod.rs | 30 +++++++-------- sync/src/synchronizer/peers.rs | 8 ++-- sync/src/tests/mod.rs | 2 +- sync/src/tests/relayer.rs | 12 +++--- sync/src/tests/synchronizer.rs | 10 ++--- util/avl/src/lib.rs | 4 +- util/avl/src/node.rs | 8 ++-- util/avl/src/tree.rs | 8 ++-- verification/src/block_verifier.rs | 8 ++-- verification/src/error.rs | 4 +- verification/src/header_verifier.rs | 6 +-- verification/src/lib.rs | 16 ++++---- verification/src/tests/block_verifier.rs | 6 +-- verification/src/tests/commit_verifier.rs | 22 +++++------ verification/src/tests/dummy.rs | 16 ++++---- .../src/tests/transaction_verifier.rs | 6 +-- verification/src/tests/uncle_verifier.rs | 18 +++++---- verification/src/transaction_verifier.rs | 6 +-- 79 files changed, 381 insertions(+), 378 deletions(-) diff --git a/chain/src/chain.rs b/chain/src/chain.rs index 9c37194ba6..2fe79d5b40 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -1,22 +1,22 @@ use bigint::{H256, U256}; -use chain_spec::consensus::Consensus; use channel::{self, Receiver, Sender}; +use ckb_chain_spec::consensus::Consensus; +use ckb_core::block::Block; +use ckb_core::extras::BlockExt; +use ckb_core::header::BlockNumber; +use ckb_core::service::{Request, DEFAULT_CHANNEL_SIZE}; +use ckb_db::batch::Batch; use ckb_notify::{ForkBlocks, NotifyController, NotifyService}; -use core::block::Block; -use core::extras::BlockExt; -use core::header::BlockNumber; -use core::service::{Request, DEFAULT_CHANNEL_SIZE}; -use db::batch::Batch; +use ckb_shared::error::SharedError; +use ckb_shared::index::ChainIndex; +use ckb_shared::shared::{ChainProvider, Shared, TipHeader}; +use ckb_time::now_ms; +use ckb_verification::{BlockVerifier, Verifier}; use error::ProcessBlockError; use log; -use shared::error::SharedError; -use shared::index::ChainIndex; -use shared::shared::{ChainProvider, Shared, TipHeader}; use std::cmp; use std::sync::Arc; use std::thread::{self, JoinHandle}; -use time::now_ms; -use verification::{BlockVerifier, Verifier}; pub struct ChainService { shared: Shared, @@ -380,16 +380,16 @@ impl ChainBuilder { pub mod test { use super::*; use bigint::U256; - use core::block::BlockBuilder; - use core::cell::CellProvider; - use core::header::{Header, HeaderBuilder}; - use core::transaction::{ + use ckb_core::block::BlockBuilder; + use ckb_core::cell::CellProvider; + use ckb_core::header::{Header, HeaderBuilder}; + use ckb_core::transaction::{ CellInput, CellOutput, OutPoint, ProposalShortId, Transaction, TransactionBuilder, }; - use core::uncle::UncleBlock; - use db::memorydb::MemoryKeyValueDB; - use shared::shared::SharedBuilder; - use shared::store::ChainKVStore; + use ckb_core::uncle::UncleBlock; + use ckb_db::memorydb::MemoryKeyValueDB; + use ckb_shared::shared::SharedBuilder; + use ckb_shared::store::ChainKVStore; fn start_chain( consensus: Option, diff --git a/chain/src/error.rs b/chain/src/error.rs index f8ad501df8..e80e6c2459 100644 --- a/chain/src/error.rs +++ b/chain/src/error.rs @@ -1,5 +1,5 @@ -use shared::error::SharedError; -use verification::Error as VerifyError; +use ckb_shared::error::SharedError; +use ckb_verification::Error as VerifyError; #[derive(Debug, PartialEq, Clone, Eq)] pub enum ProcessBlockError { diff --git a/chain/src/lib.rs b/chain/src/lib.rs index 643e7bba1f..8aa8496f90 100644 --- a/chain/src/lib.rs +++ b/chain/src/lib.rs @@ -8,13 +8,13 @@ //! implement `ChainProvider` extern crate bigint; -extern crate ckb_chain_spec as chain_spec; -extern crate ckb_core as core; -extern crate ckb_db as db; +extern crate ckb_chain_spec; +extern crate ckb_core; +extern crate ckb_db; extern crate ckb_notify; -extern crate ckb_shared as shared; -extern crate ckb_time as time; -extern crate ckb_verification as verification; +extern crate ckb_shared; +extern crate ckb_time; +extern crate ckb_verification; #[macro_use] extern crate log; #[macro_use] diff --git a/db/src/lib.rs b/db/src/lib.rs index ac50934abb..86d86f18cd 100644 --- a/db/src/lib.rs +++ b/db/src/lib.rs @@ -4,7 +4,7 @@ //! which provides key-value store interface extern crate bincode; -extern crate ckb_util as util; +extern crate ckb_util; extern crate fnv; extern crate rocksdb; diff --git a/db/src/memorydb.rs b/db/src/memorydb.rs index c0d4363ccc..15e885b792 100644 --- a/db/src/memorydb.rs +++ b/db/src/memorydb.rs @@ -1,8 +1,8 @@ use batch::{Batch, Col, Operation}; +use ckb_util::RwLock; use fnv::FnvHashMap; use kvdb::{ErrorKind, KeyValueDB, Result}; use std::ops::Range; -use util::RwLock; pub type MemoryKey = Vec; pub type MemoryValue = Vec; diff --git a/miner/src/lib.rs b/miner/src/lib.rs index 47a729fd0b..b41bb64e3a 100644 --- a/miner/src/lib.rs +++ b/miner/src/lib.rs @@ -1,16 +1,16 @@ extern crate bigint; -extern crate ckb_chain as chain; -extern crate ckb_core as core; -extern crate ckb_network as network; +extern crate ckb_chain; +extern crate ckb_core; +extern crate ckb_network; extern crate ckb_notify; extern crate ckb_protocol; -extern crate ckb_rpc as rpc; -extern crate ckb_shared as shared; +extern crate ckb_rpc; +extern crate ckb_shared; #[macro_use] extern crate crossbeam_channel as channel; #[macro_use] extern crate log; -extern crate ckb_sync as sync; +extern crate ckb_sync; extern crate flatbuffers; extern crate rand; #[macro_use] diff --git a/miner/src/miner.rs b/miner/src/miner.rs index 7b5836fdff..1ba39edf27 100644 --- a/miner/src/miner.rs +++ b/miner/src/miner.rs @@ -1,22 +1,22 @@ use super::Config; -use chain::chain::ChainController; use channel::Receiver; +use ckb_chain::chain::ChainController; +use ckb_core::block::{Block, BlockBuilder}; +use ckb_core::header::{RawHeader, Seal}; +use ckb_core::BlockNumber; +use ckb_network::NetworkService; use ckb_notify::{MsgNewTip, MsgNewTransaction, NotifyController, MINER_SUBSCRIBER}; use ckb_pow::PowEngine; use ckb_protocol::RelayMessage; -use core::block::{Block, BlockBuilder}; -use core::header::{RawHeader, Seal}; -use core::BlockNumber; +use ckb_rpc::{BlockTemplate, RpcController}; +use ckb_shared::index::ChainIndex; +use ckb_shared::shared::Shared; +use ckb_sync::RELAY_PROTOCOL_ID; use flatbuffers::FlatBufferBuilder; -use network::NetworkService; use rand::{thread_rng, Rng}; -use rpc::{BlockTemplate, RpcController}; -use shared::index::ChainIndex; -use shared::shared::Shared; use std::collections::HashSet; use std::sync::Arc; use std::thread::{self, JoinHandle}; -use sync::RELAY_PROTOCOL_ID; pub struct MinerService { config: Config, diff --git a/network/src/ckb_protocol_handler.rs b/network/src/ckb_protocol_handler.rs index 45a4e84f4d..c3e12c566f 100644 --- a/network/src/ckb_protocol_handler.rs +++ b/network/src/ckb_protocol_handler.rs @@ -1,9 +1,9 @@ use super::errors::{Error, ErrorKind}; use super::{Network, SessionInfo, Timer}; use super::{PeerIndex, ProtocolId, TimerToken}; +use ckb_util::Mutex; use std::sync::Arc; use std::time::Duration; -use util::Mutex; #[derive(Clone, Debug)] pub enum Severity<'a> { diff --git a/network/src/discovery_service.rs b/network/src/discovery_service.rs index fc7199c8b3..d03958f6ff 100644 --- a/network/src/discovery_service.rs +++ b/network/src/discovery_service.rs @@ -1,6 +1,7 @@ #![cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))] use super::Network; +use ckb_util::Mutex; use fnv::FnvHashMap; use futures::future::{self, Future}; use futures::Stream; @@ -24,7 +25,6 @@ use tokio::io::{AsyncRead, AsyncWrite}; use tokio::timer::Interval; use tokio::timer::Timeout; use transport::TransportOutput; -use util::Mutex; pub struct DiscoveryService { timeout: Duration, diff --git a/network/src/lib.rs b/network/src/lib.rs index 1be0a3163c..5c7b3f2109 100644 --- a/network/src/lib.rs +++ b/network/src/lib.rs @@ -11,7 +11,7 @@ extern crate log; extern crate fnv; #[macro_use] extern crate serde_derive; -extern crate ckb_util as util; +extern crate ckb_util; mod ckb_protocol; mod ckb_protocol_handler; diff --git a/network/src/network.rs b/network/src/network.rs index 731c223d96..a66f7f28c1 100644 --- a/network/src/network.rs +++ b/network/src/network.rs @@ -7,6 +7,7 @@ use ckb_protocol::{CKBProtocol, CKBProtocols}; use ckb_protocol_handler::CKBProtocolHandler; use ckb_protocol_handler::DefaultCKBProtocolContext; use ckb_service::CKBService; +use ckb_util::{Mutex, RwLock}; use discovery_service::DiscoveryService; use futures::future::{self, select_all, Future}; use futures::sync::mpsc::UnboundedSender; @@ -34,7 +35,6 @@ use std::usize; use timer_service::TimerService; use tokio::io::{AsyncRead, AsyncWrite}; use transport::{new_transport, TransportOutput}; -use util::{Mutex, RwLock}; const WAIT_LOCK_TIMEOUT: u64 = 3; const KBUCKETS_TIMEOUT: u64 = 600; diff --git a/network/src/network_service.rs b/network/src/network_service.rs index f66bd9383f..0b54f11b24 100644 --- a/network/src/network_service.rs +++ b/network/src/network_service.rs @@ -3,6 +3,7 @@ use super::{Error, ErrorKind, ProtocolId}; use ckb_protocol::CKBProtocol; use ckb_protocol_handler::CKBProtocolHandler; use ckb_protocol_handler::{CKBProtocolContext, DefaultCKBProtocolContext}; +use ckb_util::RwLock; use futures::future::Future; use futures::sync::oneshot; use libp2p::core::PeerId; @@ -14,7 +15,6 @@ use std::io::{Error as IoError, ErrorKind as IoErrorKind}; use std::sync::Arc; use std::thread; use tokio::runtime::current_thread; -use util::RwLock; pub struct NetworkService { network: Arc, diff --git a/network/src/peers_registry.rs b/network/src/peers_registry.rs index 597d38812c..d1f7f04ab3 100644 --- a/network/src/peers_registry.rs +++ b/network/src/peers_registry.rs @@ -1,5 +1,6 @@ use super::{Error, ErrorKind, PeerId, PeerIndex, ProtocolId}; use bytes::Bytes; +use ckb_util::{Mutex, RwLock}; use fnv::FnvHashMap; use futures::sync::mpsc::UnboundedSender; use libp2p::core::{Endpoint, Multiaddr, UniqueConnec}; @@ -9,7 +10,6 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use std::time::Duration; use std::time::Instant; -use util::{Mutex, RwLock}; struct PeerConnections { id_allocator: AtomicUsize, diff --git a/network/src/timer_service.rs b/network/src/timer_service.rs index b8e0d8eb0d..641c14f3d3 100644 --- a/network/src/timer_service.rs +++ b/network/src/timer_service.rs @@ -2,6 +2,7 @@ use super::Network; use super::PeerId; use super::{CKBProtocolHandler, ProtocolId, TimerToken}; use ckb_protocol_handler::DefaultCKBProtocolContext; +use ckb_util::Mutex; use futures::future::{self, Future}; use futures::stream::FuturesUnordered; use futures::Stream; @@ -17,7 +18,6 @@ use tokio; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::timer::Interval; use transport::TransportOutput; -use util::Mutex; pub(crate) type Timer = (Arc, ProtocolId, TimerToken, Duration); diff --git a/notify/src/lib.rs b/notify/src/lib.rs index b355792806..c6f6b737d2 100644 --- a/notify/src/lib.rs +++ b/notify/src/lib.rs @@ -1,6 +1,6 @@ #![cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))] -extern crate ckb_core as core; +extern crate ckb_core; #[macro_use] extern crate crossbeam_channel as channel; extern crate fnv; @@ -12,8 +12,8 @@ use std::thread; use std::thread::JoinHandle; use channel::{Receiver, Sender}; -use core::block::Block; -use core::service::Request; +use ckb_core::block::Block; +use ckb_core::service::Request; use fnv::FnvHashMap; pub const MINER_SUBSCRIBER: &str = "miner"; diff --git a/pool/src/lib.rs b/pool/src/lib.rs index 33a1549ac1..3adada101e 100644 --- a/pool/src/lib.rs +++ b/pool/src/lib.rs @@ -1,6 +1,6 @@ extern crate bigint; -extern crate ckb_chain_spec as chain_spec; -extern crate ckb_core as core; +extern crate ckb_chain_spec; +extern crate ckb_core; extern crate ckb_notify; extern crate ckb_shared; extern crate ckb_verification; @@ -19,7 +19,7 @@ extern crate ckb_chain; #[cfg(test)] extern crate ckb_db; #[cfg(test)] -extern crate ckb_time as time; +extern crate ckb_time; #[cfg(test)] extern crate hash; diff --git a/pool/src/tests/pool.rs b/pool/src/tests/pool.rs index 336bf23af1..f5630d9a64 100644 --- a/pool/src/tests/pool.rs +++ b/pool/src/tests/pool.rs @@ -1,22 +1,22 @@ use bigint::H256; -use chain_spec::consensus::Consensus; use channel::{self, Receiver}; use ckb_chain::chain::{ChainBuilder, ChainController}; +use ckb_chain_spec::consensus::Consensus; +use ckb_core::block::{Block, BlockBuilder}; +use ckb_core::cell::{CellProvider, CellStatus}; +use ckb_core::header::HeaderBuilder; +use ckb_core::script::Script; +use ckb_core::transaction::*; use ckb_db::memorydb::MemoryKeyValueDB; use ckb_notify::{ForkBlocks, MsgNewTip, MsgSwitchFork, NotifyService, TXS_POOL_SUBSCRIBER}; use ckb_shared::index::ChainIndex; use ckb_shared::shared::{ChainProvider, Shared, SharedBuilder}; use ckb_shared::store::ChainKVStore; -use core::block::{Block, BlockBuilder}; -use core::cell::{CellProvider, CellStatus}; -use core::header::HeaderBuilder; -use core::script::Script; -use core::transaction::*; +use ckb_time::now_ms; use std::fs::File; use std::io::Read; use std::sync::Arc; use std::time; -use time::now_ms; use txs_pool::pool::TransactionPoolService; use txs_pool::types::*; diff --git a/pool/src/txs_pool/pool.rs b/pool/src/txs_pool/pool.rs index 0b3b32ea9b..cd2c418dca 100644 --- a/pool/src/txs_pool/pool.rs +++ b/pool/src/txs_pool/pool.rs @@ -5,19 +5,19 @@ use super::types::{ }; use bigint::H256; use channel::{self, Receiver, Sender}; +use ckb_core::block::Block; +use ckb_core::cell::{CellProvider, CellStatus}; +use ckb_core::service::{Request, DEFAULT_CHANNEL_SIZE}; +use ckb_core::transaction::{OutPoint, ProposalShortId, Transaction}; use ckb_notify::{ForkBlocks, MsgNewTip, MsgSwitchFork, NotifyController, TXS_POOL_SUBSCRIBER}; use ckb_shared::index::ChainIndex; use ckb_shared::shared::{ChainProvider, Shared}; use ckb_verification::{TransactionError, TransactionVerifier}; -use core::block::Block; -use core::cell::{CellProvider, CellStatus}; -use core::service::{Request, DEFAULT_CHANNEL_SIZE}; -use core::transaction::{OutPoint, ProposalShortId, Transaction}; use lru_cache::LruCache; use std::thread::{self, JoinHandle}; #[cfg(test)] -use core::BlockNumber; +use ckb_core::BlockNumber; pub type TxsArgs = (usize, usize); pub type TxsReturn = (Vec, Vec); diff --git a/pool/src/txs_pool/types.rs b/pool/src/txs_pool/types.rs index ab12d5882f..89c474d7a2 100644 --- a/pool/src/txs_pool/types.rs +++ b/pool/src/txs_pool/types.rs @@ -1,10 +1,10 @@ //! The primary module containing the implementations of the transaction pool //! and its top-level members. -use chain_spec::consensus::{TRANSACTION_PROPAGATION_TIME, TRANSACTION_PROPAGATION_TIMEOUT}; +use ckb_chain_spec::consensus::{TRANSACTION_PROPAGATION_TIME, TRANSACTION_PROPAGATION_TIMEOUT}; +use ckb_core::transaction::{CellOutput, OutPoint, ProposalShortId, Transaction}; +use ckb_core::BlockNumber; use ckb_verification::TransactionError; -use core::transaction::{CellOutput, OutPoint, ProposalShortId, Transaction}; -use core::BlockNumber; use fnv::{FnvHashMap, FnvHashSet}; use linked_hash_map::LinkedHashMap; use std::collections::VecDeque; @@ -832,7 +832,7 @@ impl ProposedQueue { mod tests { use super::*; use bigint::H256; - use core::transaction::{CellInput, CellOutput, Transaction, TransactionBuilder}; + use ckb_core::transaction::{CellInput, CellOutput, Transaction, TransactionBuilder}; fn build_tx(inputs: Vec<(H256, u32)>, outputs_len: usize) -> Transaction { TransactionBuilder::default() diff --git a/rpc/src/integration_test.rs b/rpc/src/integration_test.rs index 4ca162f612..31eded0846 100644 --- a/rpc/src/integration_test.rs +++ b/rpc/src/integration_test.rs @@ -3,21 +3,21 @@ use super::{ TransactionWithHash, }; use bigint::H256; +use ckb_core::header::{BlockNumber, Header}; +use ckb_core::transaction::{OutPoint, Transaction}; +use ckb_network::NetworkService; +use ckb_pool::txs_pool::TransactionPoolController; use ckb_pow::Clicker; -use core::header::{BlockNumber, Header}; -use core::transaction::{OutPoint, Transaction}; +use ckb_protocol::RelayMessage; +use ckb_shared::index::ChainIndex; +use ckb_shared::shared::{ChainProvider, Shared}; +use ckb_sync::RELAY_PROTOCOL_ID; use flatbuffers::FlatBufferBuilder; use jsonrpc_core::{Error, IoHandler, Result}; use jsonrpc_http_server::ServerBuilder; use jsonrpc_server_utils::cors::AccessControlAllowOrigin; use jsonrpc_server_utils::hosts::DomainsValidation; -use network::NetworkService; -use pool::txs_pool::TransactionPoolController; -use protocol::RelayMessage; -use shared::index::ChainIndex; -use shared::shared::{ChainProvider, Shared}; use std::sync::Arc; -use sync::RELAY_PROTOCOL_ID; //TODO: build_rpc_trait! do not surppot trait bounds build_rpc_trait! { diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 2c1aefecd6..8c14964dac 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -7,18 +7,18 @@ extern crate jsonrpc_http_server; extern crate jsonrpc_server_utils; #[macro_use] extern crate log; -extern crate ckb_core as core; +extern crate ckb_core; #[cfg(test)] -extern crate ckb_db as db; -extern crate ckb_network as network; -extern crate ckb_notify as notify; -extern crate ckb_pool as pool; -extern crate ckb_protocol as protocol; -extern crate ckb_shared as shared; -extern crate ckb_sync as sync; +extern crate ckb_db; +extern crate ckb_network; +extern crate ckb_notify; +extern crate ckb_pool; +extern crate ckb_protocol; +extern crate ckb_shared; +extern crate ckb_sync; extern crate ckb_time; #[cfg(test)] -extern crate ckb_verification as verification; +extern crate ckb_verification; #[macro_use] extern crate serde_derive; #[cfg(feature = "integration_test")] @@ -28,9 +28,9 @@ extern crate crossbeam_channel as channel; extern crate fnv; use bigint::H256; -use core::block::Block; -use core::header::Header; -use core::transaction::{Capacity, OutPoint, Transaction}; +use ckb_core::block::Block; +use ckb_core::header::Header; +use ckb_core::transaction::{Capacity, OutPoint, Transaction}; mod service; diff --git a/rpc/src/server.rs b/rpc/src/server.rs index c081acb026..e1266ae41a 100644 --- a/rpc/src/server.rs +++ b/rpc/src/server.rs @@ -1,20 +1,20 @@ use super::service::{BlockTemplate, RpcController}; use super::{BlockWithHash, CellOutputWithOutPoint, Config, TransactionWithHash}; use bigint::H256; -use core::header::{BlockNumber, Header}; -use core::transaction::{OutPoint, Transaction}; +use ckb_core::header::{BlockNumber, Header}; +use ckb_core::transaction::{OutPoint, Transaction}; +use ckb_network::NetworkService; +use ckb_pool::txs_pool::TransactionPoolController; +use ckb_protocol::RelayMessage; +use ckb_shared::index::ChainIndex; +use ckb_shared::shared::{ChainProvider, Shared}; +use ckb_sync::RELAY_PROTOCOL_ID; use flatbuffers::FlatBufferBuilder; use jsonrpc_core::{Error, IoHandler, Result}; use jsonrpc_http_server::ServerBuilder; use jsonrpc_server_utils::cors::AccessControlAllowOrigin; use jsonrpc_server_utils::hosts::DomainsValidation; -use network::NetworkService; -use pool::txs_pool::TransactionPoolController; -use protocol::RelayMessage; -use shared::index::ChainIndex; -use shared::shared::{ChainProvider, Shared}; use std::sync::Arc; -use sync::RELAY_PROTOCOL_ID; build_rpc_trait! { pub trait Rpc { diff --git a/rpc/src/service.rs b/rpc/src/service.rs index 4f4f038c85..b2c1622d6d 100644 --- a/rpc/src/service.rs +++ b/rpc/src/service.rs @@ -1,17 +1,19 @@ use bigint::H256; use channel::{self, Receiver, Sender}; +use ckb_core::block::{Block, BlockBuilder}; +use ckb_core::header::{Header, HeaderBuilder, RawHeader}; +use ckb_core::service::{Request, DEFAULT_CHANNEL_SIZE}; +use ckb_core::transaction::{ + CellInput, CellOutput, ProposalShortId, Transaction, TransactionBuilder, +}; +use ckb_core::uncle::UncleBlock; +use ckb_notify::{NotifyController, RPC_SUBSCRIBER}; +use ckb_pool::txs_pool::TransactionPoolController; +use ckb_shared::error::SharedError; +use ckb_shared::index::ChainIndex; +use ckb_shared::shared::{ChainProvider, Shared}; use ckb_time::now_ms; -use core::block::{Block, BlockBuilder}; -use core::header::{Header, HeaderBuilder, RawHeader}; -use core::service::{Request, DEFAULT_CHANNEL_SIZE}; -use core::transaction::{CellInput, CellOutput, ProposalShortId, Transaction, TransactionBuilder}; -use core::uncle::UncleBlock; use fnv::{FnvHashMap, FnvHashSet}; -use notify::{NotifyController, RPC_SUBSCRIBER}; -use pool::txs_pool::TransactionPoolController; -use shared::error::SharedError; -use shared::index::ChainIndex; -use shared::shared::{ChainProvider, Shared}; use std::cmp; use std::sync::Arc; use std::thread::{self, JoinHandle}; @@ -293,13 +295,13 @@ impl RpcService { pub mod test { use super::*; use bigint::H256; - use core::block::BlockBuilder; - use db::memorydb::MemoryKeyValueDB; - use notify::NotifyService; - use pool::txs_pool::{PoolConfig, TransactionPoolController, TransactionPoolService}; - use shared::shared::SharedBuilder; - use shared::store::ChainKVStore; - use verification::{BlockVerifier, HeaderResolverWrapper, HeaderVerifier, Verifier}; + use ckb_core::block::BlockBuilder; + use ckb_db::memorydb::MemoryKeyValueDB; + use ckb_notify::NotifyService; + use ckb_pool::txs_pool::{PoolConfig, TransactionPoolController, TransactionPoolService}; + use ckb_shared::shared::SharedBuilder; + use ckb_shared::store::ChainKVStore; + use ckb_verification::{BlockVerifier, HeaderResolverWrapper, HeaderVerifier, Verifier}; #[test] fn test_block_template() { diff --git a/script/src/lib.rs b/script/src/lib.rs index 3422cab971..4a665baed6 100644 --- a/script/src/lib.rs +++ b/script/src/lib.rs @@ -1,7 +1,7 @@ extern crate bigint; -extern crate ckb_core as core; +extern crate ckb_core; extern crate ckb_protocol; -extern crate ckb_vm as vm; +extern crate ckb_vm; #[cfg(test)] extern crate crypto; #[cfg(test)] @@ -19,7 +19,7 @@ extern crate proptest; mod syscalls; mod verify; -use vm::Error as VMInternalError; +use ckb_vm::Error as VMInternalError; pub use verify::TransactionScriptsVerifier; diff --git a/script/src/syscalls/builder.rs b/script/src/syscalls/builder.rs index 2125ca4d12..7bb4d4b087 100644 --- a/script/src/syscalls/builder.rs +++ b/script/src/syscalls/builder.rs @@ -1,8 +1,8 @@ +use ckb_core::transaction::{CellInput, CellOutput, Transaction}; use ckb_protocol::{ Bytes as FbsBytes, CellInput as FbsCellInput, CellInputBuilder, CellOutput as FbsCellOutput, CellOutputBuilder, OutPoint as FbsOutPoint, Transaction as FbsTransaction, TransactionBuilder, }; -use core::transaction::{CellInput, CellOutput, Transaction}; use flatbuffers::{FlatBufferBuilder, WIPOffset}; pub fn build_tx<'b>( diff --git a/script/src/syscalls/debugger.rs b/script/src/syscalls/debugger.rs index 32b0ac795a..f8aa429bb9 100644 --- a/script/src/syscalls/debugger.rs +++ b/script/src/syscalls/debugger.rs @@ -1,5 +1,5 @@ +use ckb_vm::{CoreMachine, Error as VMError, Memory, Register, Syscalls, A0, A7}; use syscalls::DEBUG_PRINT_SYSCALL_NUMBER; -use vm::{CoreMachine, Error as VMError, Memory, Register, Syscalls, A0, A7}; pub struct Debugger<'a> { prefix: &'a str, diff --git a/script/src/syscalls/fetch_script_hash.rs b/script/src/syscalls/fetch_script_hash.rs index 77603736e8..c7e79f9b7e 100644 --- a/script/src/syscalls/fetch_script_hash.rs +++ b/script/src/syscalls/fetch_script_hash.rs @@ -1,9 +1,9 @@ use bigint::H256; -use core::transaction::{CellInput, CellOutput}; +use ckb_core::transaction::{CellInput, CellOutput}; +use ckb_vm::{CoreMachine, Error as VMError, Memory, Register, Syscalls, A0, A1, A2, A3, A4, A7}; use syscalls::{ Category, Source, FETCH_SCRIPT_HASH_SYSCALL_NUMBER, ITEM_MISSING, OVERRIDE_LEN, SUCCESS, }; -use vm::{CoreMachine, Error as VMError, Memory, Register, Syscalls, A0, A1, A2, A3, A4, A7}; #[derive(Debug)] pub struct FetchScriptHash<'a> { diff --git a/script/src/syscalls/mmap_cell.rs b/script/src/syscalls/mmap_cell.rs index 75b41bb1c3..f39cdc1cd9 100644 --- a/script/src/syscalls/mmap_cell.rs +++ b/script/src/syscalls/mmap_cell.rs @@ -1,9 +1,11 @@ -use core::transaction::CellOutput; +use ckb_core::transaction::CellOutput; +use ckb_vm::memory::PROT_READ; +use ckb_vm::{ + CoreMachine, Error as VMError, Memory, Register, Syscalls, A0, A1, A2, A3, A4, A5, A7, +}; use std::cmp; use std::rc::Rc; use syscalls::{Mode, Source, MMAP_CELL_SYSCALL_NUMBER, OVERRIDE_LEN, SUCCESS}; -use vm::memory::PROT_READ; -use vm::{CoreMachine, Error as VMError, Memory, Register, Syscalls, A0, A1, A2, A3, A4, A5, A7}; #[derive(Debug)] pub struct MmapCell<'a> { diff --git a/script/src/syscalls/mmap_tx.rs b/script/src/syscalls/mmap_tx.rs index 65f2b4872b..6ede61e624 100644 --- a/script/src/syscalls/mmap_tx.rs +++ b/script/src/syscalls/mmap_tx.rs @@ -1,8 +1,8 @@ +use ckb_vm::memory::PROT_READ; +use ckb_vm::{CoreMachine, Error as VMError, Memory, Register, Syscalls, A0, A1, A2, A3, A7}; use std::cmp; use std::rc::Rc; use syscalls::{Mode, MMAP_TX_SYSCALL_NUMBER, OVERRIDE_LEN, SUCCESS}; -use vm::memory::PROT_READ; -use vm::{CoreMachine, Error as VMError, Memory, Register, Syscalls, A0, A1, A2, A3, A7}; pub struct MmapTx<'a> { tx: &'a [u8], diff --git a/script/src/syscalls/mod.rs b/script/src/syscalls/mod.rs index 7ec8737cc6..6915894704 100644 --- a/script/src/syscalls/mod.rs +++ b/script/src/syscalls/mod.rs @@ -10,7 +10,7 @@ pub use self::fetch_script_hash::FetchScriptHash; pub use self::mmap_cell::MmapCell; pub use self::mmap_tx::MmapTx; -use vm::Error; +use ckb_vm::Error; pub const SUCCESS: u8 = 0; pub const OVERRIDE_LEN: u8 = 1; @@ -73,14 +73,14 @@ impl Source { mod tests { use super::*; use bigint::H256; - use core::script::Script; - use core::transaction::{CellInput, CellOutput, OutPoint}; - use proptest::collection::size_range; - use proptest::prelude::any_with; - use vm::machine::DefaultCoreMachine; - use vm::{ + use ckb_core::script::Script; + use ckb_core::transaction::{CellInput, CellOutput, OutPoint}; + use ckb_vm::machine::DefaultCoreMachine; + use ckb_vm::{ CoreMachine, Error as VMError, Memory, SparseMemory, Syscalls, A0, A1, A2, A3, A4, A5, A7, }; + use proptest::collection::size_range; + use proptest::prelude::any_with; fn _test_mmap_tx_all(tx: &Vec) { let mut machine = DefaultCoreMachine::::default(); diff --git a/script/src/verify.rs b/script/src/verify.rs index 404260cb09..9836a6bbf2 100644 --- a/script/src/verify.rs +++ b/script/src/verify.rs @@ -1,12 +1,12 @@ use super::ScriptError; use bigint::H256; -use core::cell::ResolvedTransaction; -use core::script::Script; -use core::transaction::{CellInput, CellOutput}; +use ckb_core::cell::ResolvedTransaction; +use ckb_core::script::Script; +use ckb_core::transaction::{CellInput, CellOutput}; +use ckb_vm::{DefaultMachine, SparseMemory}; use flatbuffers::FlatBufferBuilder; use fnv::FnvHashMap; use syscalls::{build_tx, Debugger, FetchScriptHash, MmapCell, MmapTx}; -use vm::{DefaultMachine, SparseMemory}; // This struct leverages CKB VM to verify transaction inputs. // FlatBufferBuilder owned Vec that grows as needed, in the @@ -134,10 +134,10 @@ impl<'a> TransactionScriptsVerifier<'a> { mod tests { use super::*; use bigint::H256; - use core::cell::CellStatus; - use core::script::Script; - use core::transaction::{CellInput, CellOutput, OutPoint, TransactionBuilder}; - use core::Capacity; + use ckb_core::cell::CellStatus; + use ckb_core::script::Script; + use ckb_core::transaction::{CellInput, CellOutput, OutPoint, TransactionBuilder}; + use ckb_core::Capacity; use crypto::secp::Generator; use faster_hex::hex_to; use fnv::FnvHashMap; diff --git a/shared/src/cachedb.rs b/shared/src/cachedb.rs index 39577b4676..64477f72b1 100644 --- a/shared/src/cachedb.rs +++ b/shared/src/cachedb.rs @@ -1,9 +1,9 @@ -use db::batch::{Batch, Col, Operation}; -use db::kvdb::{KeyValueDB, Result}; +use ckb_db::batch::{Batch, Col, Operation}; +use ckb_db::kvdb::{KeyValueDB, Result}; +use ckb_util::RwLock; use fnv::FnvHashMap; use lru_cache::LruCache; use std::ops::Range; -use util::RwLock; type CacheTable = FnvHashMap, Vec>>; pub type CacheCols = (u32, usize); diff --git a/shared/src/config.rs b/shared/src/config.rs index 2b86d522d4..65859fa92a 100644 --- a/shared/src/config.rs +++ b/shared/src/config.rs @@ -1,6 +1,6 @@ use bigint::{H256, U256}; -use core::block::Block; -use core::header::{BlockNumber, Header, RawHeader, Seal}; +use ckb_core::block::Block; +use ckb_core::header::{BlockNumber, Header, RawHeader, Seal}; #[derive(Clone, Debug, Deserialize)] pub struct Config { diff --git a/shared/src/error.rs b/shared/src/error.rs index 28f0bb9b1d..f304179c89 100644 --- a/shared/src/error.rs +++ b/shared/src/error.rs @@ -1,4 +1,4 @@ -use db::kvdb::Error as DBError; +use ckb_db::kvdb::Error as DBError; #[derive(Debug, PartialEq, Clone, Eq)] pub enum SharedError { diff --git a/shared/src/index.rs b/shared/src/index.rs index 72d3e8ae6b..d233a2971d 100644 --- a/shared/src/index.rs +++ b/shared/src/index.rs @@ -1,12 +1,12 @@ use super::flat_serializer::serialized_addresses; use bigint::H256; use bincode::{deserialize, serialize}; -use core::block::Block; -use core::extras::{BlockExt, TransactionAddress}; -use core::header::{BlockNumber, Header}; -use core::transaction::{Transaction, TransactionBuilder}; -use db::batch::Batch; -use db::kvdb::KeyValueDB; +use ckb_core::block::Block; +use ckb_core::extras::{BlockExt, TransactionAddress}; +use ckb_core::header::{BlockNumber, Header}; +use ckb_core::transaction::{Transaction, TransactionBuilder}; +use ckb_db::batch::Batch; +use ckb_db::kvdb::KeyValueDB; use error::SharedError; use store::{ChainKVStore, ChainStore}; use {COLUMN_BLOCK_BODY, COLUMN_INDEX, COLUMN_META, COLUMN_TRANSACTION_ADDR}; @@ -156,8 +156,8 @@ impl ChainIndex for ChainKVStore { mod tests { use super::super::COLUMNS; use super::*; - use chain_spec::consensus::Consensus; - use db::diskdb::RocksDB; + use ckb_chain_spec::consensus::Consensus; + use ckb_db::diskdb::RocksDB; use tempfile; #[test] diff --git a/shared/src/lib.rs b/shared/src/lib.rs index b8dce8d281..0c2f6592b6 100644 --- a/shared/src/lib.rs +++ b/shared/src/lib.rs @@ -10,10 +10,10 @@ extern crate avl_merkle as avl; extern crate bigint; extern crate bincode; -extern crate ckb_chain_spec as chain_spec; -extern crate ckb_core as core; -extern crate ckb_db as db; -extern crate ckb_util as util; +extern crate ckb_chain_spec; +extern crate ckb_core; +extern crate ckb_db; +extern crate ckb_util; extern crate fnv; extern crate lru_cache; extern crate serde; @@ -33,7 +33,7 @@ pub mod index; pub mod shared; pub mod store; -use db::batch::Col; +use ckb_db::batch::Col; // REMEMBER to update the const defined in util/avl/src/lib.rs as well pub const COLUMNS: u32 = 12; diff --git a/shared/src/shared.rs b/shared/src/shared.rs index 56752ba728..91d8bed750 100644 --- a/shared/src/shared.rs +++ b/shared/src/shared.rs @@ -1,24 +1,24 @@ use super::{COLUMNS, COLUMN_BLOCK_HEADER}; use bigint::{H256, U256}; use cachedb::CacheDB; -use chain_spec::consensus::Consensus; -use core::block::Block; -use core::cell::{CellProvider, CellStatus}; -use core::extras::BlockExt; -use core::header::{BlockNumber, Header}; -use core::transaction::{Capacity, OutPoint, ProposalShortId, Transaction}; -use core::transaction_meta::TransactionMeta; -use core::uncle::UncleBlock; -use db::diskdb::RocksDB; -use db::kvdb::KeyValueDB; -use db::memorydb::MemoryKeyValueDB; +use ckb_chain_spec::consensus::Consensus; +use ckb_core::block::Block; +use ckb_core::cell::{CellProvider, CellStatus}; +use ckb_core::extras::BlockExt; +use ckb_core::header::{BlockNumber, Header}; +use ckb_core::transaction::{Capacity, OutPoint, ProposalShortId, Transaction}; +use ckb_core::transaction_meta::TransactionMeta; +use ckb_core::uncle::UncleBlock; +use ckb_db::diskdb::RocksDB; +use ckb_db::kvdb::KeyValueDB; +use ckb_db::memorydb::MemoryKeyValueDB; +use ckb_util::RwLock; use error::SharedError; use fnv::FnvHashSet; use index::ChainIndex; use std::path::Path; use std::sync::Arc; use store::ChainKVStore; -use util::RwLock; #[derive(Default, Debug, PartialEq, Clone, Eq)] pub struct TipHeader { diff --git a/shared/src/store.rs b/shared/src/store.rs index 42691209a9..fb65303d37 100644 --- a/shared/src/store.rs +++ b/shared/src/store.rs @@ -3,18 +3,18 @@ use avl::node::search; use avl::tree::AvlTree; use bigint::H256; use bincode::{deserialize, serialize}; -use core::block::{Block, BlockBuilder}; -use core::extras::BlockExt; -use core::header::{Header, HeaderBuilder}; -use core::transaction::{OutPoint, ProposalShortId, Transaction, TransactionBuilder}; -use core::transaction_meta::TransactionMeta; -use core::uncle::UncleBlock; -use db::batch::{Batch, Col}; -use db::kvdb::KeyValueDB; +use ckb_core::block::{Block, BlockBuilder}; +use ckb_core::extras::BlockExt; +use ckb_core::header::{Header, HeaderBuilder}; +use ckb_core::transaction::{OutPoint, ProposalShortId, Transaction, TransactionBuilder}; +use ckb_core::transaction_meta::TransactionMeta; +use ckb_core::uncle::UncleBlock; +use ckb_db::batch::{Batch, Col}; +use ckb_db::kvdb::KeyValueDB; +use ckb_util::RwLock; use error::SharedError; use std::ops::Range; use std::sync::Arc; -use util::RwLock; use { COLUMN_BLOCK_BODY, COLUMN_BLOCK_HEADER, COLUMN_BLOCK_PROPOSAL_IDS, COLUMN_BLOCK_TRANSACTION_ADDRESSES, COLUMN_BLOCK_TRANSACTION_IDS, COLUMN_BLOCK_UNCLE, @@ -317,8 +317,8 @@ impl ChainStore for ChainKVStore { mod tests { use super::super::COLUMNS; use super::*; - use chain_spec::consensus::Consensus; - use db::diskdb::RocksDB; + use ckb_chain_spec::consensus::Consensus; + use ckb_db::diskdb::RocksDB; use tempfile; #[test] diff --git a/spec/src/consensus.rs b/spec/src/consensus.rs index 3300262f7c..12269f73de 100644 --- a/spec/src/consensus.rs +++ b/spec/src/consensus.rs @@ -1,9 +1,9 @@ use bigint::U256; +use ckb_core::block::{Block, BlockBuilder}; +use ckb_core::header::HeaderBuilder; +use ckb_core::transaction::Capacity; +use ckb_core::BlockNumber; use ckb_pow::{Pow, PowEngine}; -use core::block::{Block, BlockBuilder}; -use core::header::HeaderBuilder; -use core::transaction::Capacity; -use core::BlockNumber; use std::sync::Arc; pub const DEFAULT_BLOCK_REWARD: Capacity = 5_000; diff --git a/spec/src/lib.rs b/spec/src/lib.rs index c8f3b52b1d..9df5d72a3e 100644 --- a/spec/src/lib.rs +++ b/spec/src/lib.rs @@ -7,19 +7,19 @@ //! There are a few named presets that can be selected from or a custom yaml spec file can be supplied. extern crate bigint; -extern crate ckb_core as core; +extern crate ckb_core; extern crate serde_json; #[macro_use] extern crate serde_derive; extern crate ckb_pow; use bigint::{H256, U256}; +use ckb_core::block::BlockBuilder; +use ckb_core::header::HeaderBuilder; +use ckb_core::transaction::{CellOutput, Transaction, TransactionBuilder}; +use ckb_core::Capacity; use ckb_pow::{Pow, PowEngine}; use consensus::Consensus; -use core::block::BlockBuilder; -use core::header::HeaderBuilder; -use core::transaction::{CellOutput, Transaction, TransactionBuilder}; -use core::Capacity; use std::error::Error; use std::fs::File; use std::io::Read; diff --git a/src/cli/export.rs b/src/cli/export.rs index 3639decd6a..9a18ca2ca0 100644 --- a/src/cli/export.rs +++ b/src/cli/export.rs @@ -1,14 +1,14 @@ use super::super::setup::Configs; -use chain_spec::SpecType; +use ckb_chain_spec::SpecType; +use ckb_db::diskdb::RocksDB; use ckb_instrument::{Export, Format}; +use ckb_shared::cachedb::CacheDB; +use ckb_shared::shared::SharedBuilder; +use ckb_shared::store::ChainKVStore; use clap::ArgMatches; use config_tool::{Config as ConfigTool, File, FileFormat}; -use db::diskdb::RocksDB; use dir::default_base_path; use dir::Directories; -use shared::cachedb::CacheDB; -use shared::shared::SharedBuilder; -use shared::store::ChainKVStore; use {DEFAULT_CONFIG, DEFAULT_CONFIG_FILENAME}; pub fn export(matches: &ArgMatches) { diff --git a/src/cli/import.rs b/src/cli/import.rs index bdd1a07a3a..8821dbff75 100644 --- a/src/cli/import.rs +++ b/src/cli/import.rs @@ -1,15 +1,15 @@ use super::super::setup::Configs; -use chain::chain::{ChainBuilder, ChainController}; -use chain_spec::SpecType; +use ckb_chain::chain::{ChainBuilder, ChainController}; +use ckb_chain_spec::SpecType; +use ckb_db::diskdb::RocksDB; use ckb_instrument::{Format, Import}; +use ckb_shared::cachedb::CacheDB; +use ckb_shared::shared::SharedBuilder; +use ckb_shared::store::ChainKVStore; use clap::ArgMatches; use config_tool::{Config as ConfigTool, File, FileFormat}; -use db::diskdb::RocksDB; use dir::default_base_path; use dir::Directories; -use shared::cachedb::CacheDB; -use shared::shared::SharedBuilder; -use shared::store::ChainKVStore; use {DEFAULT_CONFIG, DEFAULT_CONFIG_FILENAME}; pub fn import(matches: &ArgMatches) { diff --git a/src/cli/run_impl.rs b/src/cli/run_impl.rs index 39fe80a3ad..d863da3277 100644 --- a/src/cli/run_impl.rs +++ b/src/cli/run_impl.rs @@ -1,32 +1,32 @@ use super::super::helper::wait_for_exit; use super::super::Setup; use bigint::H256; -use chain::chain::{ChainBuilder, ChainController}; +use ckb_chain::chain::{ChainBuilder, ChainController}; +use ckb_core::script::Script; +use ckb_core::transaction::{CellInput, OutPoint, Transaction, TransactionBuilder}; +use ckb_db::diskdb::RocksDB; +use ckb_miner::MinerService; +use ckb_network::CKBProtocol; +use ckb_network::NetworkConfig; +use ckb_network::NetworkService; use ckb_notify::NotifyService; +use ckb_pool::txs_pool::{TransactionPoolController, TransactionPoolService}; use ckb_pow::PowEngine; +use ckb_rpc::{RpcController, RpcServer, RpcService}; +use ckb_shared::cachedb::CacheDB; +use ckb_shared::index::ChainIndex; +use ckb_shared::shared::{ChainProvider, Shared, SharedBuilder}; +use ckb_shared::store::ChainKVStore; +use ckb_sync::{Relayer, Synchronizer, RELAY_PROTOCOL_ID, SYNC_PROTOCOL_ID}; use clap::ArgMatches; -use core::script::Script; -use core::transaction::{CellInput, OutPoint, Transaction, TransactionBuilder}; use crypto::secp::{Generator, Privkey}; -use db::diskdb::RocksDB; use faster_hex::{hex_string, hex_to}; use hash::sha3_256; use logger; -use miner::MinerService; -use network::CKBProtocol; -use network::NetworkConfig; -use network::NetworkService; -use pool::txs_pool::{TransactionPoolController, TransactionPoolService}; -use rpc::{RpcController, RpcServer, RpcService}; use serde_json; -use shared::cachedb::CacheDB; -use shared::index::ChainIndex; -use shared::shared::{ChainProvider, Shared, SharedBuilder}; -use shared::store::ChainKVStore; use std::io::Write; use std::sync::Arc; use std::thread; -use sync::{Relayer, Synchronizer, RELAY_PROTOCOL_ID, SYNC_PROTOCOL_ID}; pub fn run(setup: Setup) { logger::init(setup.configs.logger.clone()).expect("Init Logger"); diff --git a/src/helper.rs b/src/helper.rs index 7390957c01..cfdcb5bd63 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -1,6 +1,6 @@ +use ckb_util::{Condvar, Mutex}; use ctrlc; use std::sync::Arc; -use util::{Condvar, Mutex}; pub fn wait_for_exit() { let exit = Arc::new((Mutex::new(()), Condvar::new())); diff --git a/src/main.rs b/src/main.rs index 95f9a7449b..c8db763bf6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,18 +5,18 @@ extern crate dir; #[macro_use] extern crate log; extern crate bigint; -extern crate ckb_chain as chain; -extern crate ckb_chain_spec as chain_spec; -extern crate ckb_core as core; -extern crate ckb_db as db; -extern crate ckb_miner as miner; -extern crate ckb_network as network; +extern crate ckb_chain; +extern crate ckb_chain_spec; +extern crate ckb_core; +extern crate ckb_db; +extern crate ckb_miner; +extern crate ckb_network; extern crate ckb_notify; -extern crate ckb_pool as pool; -extern crate ckb_rpc as rpc; -extern crate ckb_shared as shared; -extern crate ckb_sync as sync; -extern crate ckb_util as util; +extern crate ckb_pool; +extern crate ckb_rpc; +extern crate ckb_shared; +extern crate ckb_sync; +extern crate ckb_util; extern crate hash; extern crate logger; #[macro_use] diff --git a/src/setup.rs b/src/setup.rs index da663ff330..c79742f68d 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -1,14 +1,14 @@ -use chain_spec::{ChainSpec, SpecType}; +use ckb_chain_spec::{ChainSpec, SpecType}; +use ckb_miner::Config as MinerConfig; +use ckb_network::Config as NetworkConfig; +use ckb_pool::txs_pool::PoolConfig; +use ckb_rpc::Config as RpcConfig; +use ckb_sync::Config as SyncConfig; use clap; use config_tool::{Config as ConfigTool, File, FileFormat}; use dir::{default_base_path, Directories}; use logger::Config as LogConfig; -use miner::Config as MinerConfig; -use network::Config as NetworkConfig; -use pool::txs_pool::PoolConfig; -use rpc::Config as RpcConfig; use std::error::Error; -use sync::Config as SyncConfig; use {DEFAULT_CONFIG, DEFAULT_CONFIG_FILENAME}; #[derive(Clone, Debug)] diff --git a/sync/src/lib.rs b/sync/src/lib.rs index cb8e138f8c..cff1d95757 100644 --- a/sync/src/lib.rs +++ b/sync/src/lib.rs @@ -8,29 +8,26 @@ extern crate fnv; #[macro_use] extern crate log; extern crate ckb_chain; -extern crate ckb_core as core; -extern crate ckb_network as network; -extern crate ckb_pool as pool; +extern crate ckb_core; +extern crate ckb_network; +extern crate ckb_pool; extern crate ckb_protocol; extern crate ckb_shared; extern crate ckb_time; extern crate flatbuffers; #[macro_use] -extern crate ckb_util as util; +extern crate ckb_util; extern crate ckb_verification; #[macro_use] extern crate bitflags; #[macro_use] extern crate serde_derive; -extern crate ckb_chain_spec as chain_spec; - +extern crate ckb_chain_spec; #[cfg(test)] -extern crate ckb_db as db; +extern crate ckb_db; #[cfg(test)] extern crate ckb_notify; #[cfg(test)] -extern crate ckb_pool; -#[cfg(test)] extern crate crossbeam_channel; mod config; @@ -44,7 +41,7 @@ pub use config::Config; pub use relayer::Relayer; pub use synchronizer::Synchronizer; -use network::ProtocolId; +use ckb_network::ProtocolId; pub const MAX_HEADERS_LEN: usize = 2_000; pub const MAX_INVENTORY_LEN: usize = 50_000; diff --git a/sync/src/relayer/block_transactions_process.rs b/sync/src/relayer/block_transactions_process.rs index eb56d0cc45..9316ce77f9 100644 --- a/sync/src/relayer/block_transactions_process.rs +++ b/sync/src/relayer/block_transactions_process.rs @@ -1,9 +1,9 @@ use bigint::H256; +use ckb_core::transaction::Transaction; +use ckb_network::CKBProtocolContext; +use ckb_network::PeerIndex; use ckb_protocol::{BlockTransactions, FlatbuffersVectorIterator}; use ckb_shared::index::ChainIndex; -use core::transaction::Transaction; -use network::CKBProtocolContext; -use network::PeerIndex; use relayer::Relayer; use std::sync::Arc; diff --git a/sync/src/relayer/compact_block.rs b/sync/src/relayer/compact_block.rs index d0b0b70b1c..a3a977cbe5 100644 --- a/sync/src/relayer/compact_block.rs +++ b/sync/src/relayer/compact_block.rs @@ -1,8 +1,8 @@ use bigint::H48; +use ckb_core::header::Header; +use ckb_core::transaction::{ProposalShortId, Transaction}; +use ckb_core::uncle::UncleBlock; use ckb_protocol::{self, FlatbuffersVectorIterator}; -use core::header::Header; -use core::transaction::{ProposalShortId, Transaction}; -use core::uncle::UncleBlock; pub type ShortTransactionID = H48; diff --git a/sync/src/relayer/compact_block_process.rs b/sync/src/relayer/compact_block_process.rs index b10a3cfdfd..fca1db4e7b 100644 --- a/sync/src/relayer/compact_block_process.rs +++ b/sync/src/relayer/compact_block_process.rs @@ -1,13 +1,13 @@ use super::compact_block::CompactBlock; +use ckb_network::{CKBProtocolContext, PeerIndex}; use ckb_protocol::{CompactBlock as FbsCompactBlock, RelayMessage}; use ckb_shared::index::ChainIndex; use ckb_shared::shared::ChainProvider; +use ckb_util::RwLockUpgradableReadGuard; use ckb_verification::{HeaderResolverWrapper, HeaderVerifier, Verifier}; use flatbuffers::FlatBufferBuilder; -use network::{CKBProtocolContext, PeerIndex}; use relayer::Relayer; use std::sync::Arc; -use util::RwLockUpgradableReadGuard; pub struct CompactBlockProcess<'a, CI: ChainIndex + 'a> { message: &'a FbsCompactBlock<'a>, diff --git a/sync/src/relayer/get_block_proposal_process.rs b/sync/src/relayer/get_block_proposal_process.rs index 3dc3e08358..d285829b2d 100644 --- a/sync/src/relayer/get_block_proposal_process.rs +++ b/sync/src/relayer/get_block_proposal_process.rs @@ -1,8 +1,8 @@ +use ckb_core::transaction::ProposalShortId; +use ckb_network::{CKBProtocolContext, PeerIndex}; use ckb_protocol::{FlatbuffersVectorIterator, GetBlockProposal, RelayMessage}; use ckb_shared::index::ChainIndex; -use core::transaction::ProposalShortId; use flatbuffers::FlatBufferBuilder; -use network::{CKBProtocolContext, PeerIndex}; use relayer::Relayer; pub struct GetBlockProposalProcess<'a, CI: ChainIndex + 'a> { diff --git a/sync/src/relayer/get_block_transactions_process.rs b/sync/src/relayer/get_block_transactions_process.rs index 38440cac2c..b028c16f51 100644 --- a/sync/src/relayer/get_block_transactions_process.rs +++ b/sync/src/relayer/get_block_transactions_process.rs @@ -1,8 +1,8 @@ use bigint::H256; +use ckb_network::{CKBProtocolContext, PeerIndex}; use ckb_protocol::{GetBlockTransactions, RelayMessage}; use ckb_shared::index::ChainIndex; use flatbuffers::FlatBufferBuilder; -use network::{CKBProtocolContext, PeerIndex}; use relayer::Relayer; pub struct GetBlockTransactionsProcess<'a, CI: ChainIndex + 'a> { diff --git a/sync/src/relayer/mod.rs b/sync/src/relayer/mod.rs index 5030a3cb19..d8865cc6de 100644 --- a/sync/src/relayer/mod.rs +++ b/sync/src/relayer/mod.rs @@ -17,19 +17,19 @@ use self::get_block_transactions_process::GetBlockTransactionsProcess; use self::transaction_process::TransactionProcess; use bigint::H256; use ckb_chain::chain::ChainController; +use ckb_core::block::{Block, BlockBuilder}; +use ckb_core::transaction::{ProposalShortId, Transaction}; +use ckb_network::{CKBProtocolContext, CKBProtocolHandler, PeerIndex, TimerToken}; +use ckb_pool::txs_pool::TransactionPoolController; use ckb_protocol::{short_transaction_id, short_transaction_id_keys, RelayMessage, RelayPayload}; use ckb_shared::index::ChainIndex; use ckb_shared::shared::{ChainProvider, Shared}; -use core::block::{Block, BlockBuilder}; -use core::transaction::{ProposalShortId, Transaction}; +use ckb_util::{Mutex, RwLock}; use flatbuffers::{get_root, FlatBufferBuilder}; use fnv::{FnvHashMap, FnvHashSet}; -use network::{CKBProtocolContext, CKBProtocolHandler, PeerIndex, TimerToken}; -use pool::txs_pool::TransactionPoolController; use std::collections::HashSet; use std::sync::Arc; use std::time::Duration; -use util::{Mutex, RwLock}; pub const TX_PROPOSAL_TOKEN: TimerToken = 0; diff --git a/sync/src/relayer/transaction_process.rs b/sync/src/relayer/transaction_process.rs index 5fbfefa777..c95415f350 100644 --- a/sync/src/relayer/transaction_process.rs +++ b/sync/src/relayer/transaction_process.rs @@ -1,8 +1,8 @@ +use ckb_core::transaction::Transaction; +use ckb_network::{CKBProtocolContext, PeerIndex}; use ckb_protocol::{RelayMessage, Transaction as FbsTransaction}; use ckb_shared::index::ChainIndex; -use core::transaction::Transaction; use flatbuffers::FlatBufferBuilder; -use network::{CKBProtocolContext, PeerIndex}; use relayer::Relayer; pub struct TransactionProcess<'a, CI: ChainIndex + 'a> { diff --git a/sync/src/synchronizer/block_fetcher.rs b/sync/src/synchronizer/block_fetcher.rs index c8aded5a88..3aeece9d00 100644 --- a/sync/src/synchronizer/block_fetcher.rs +++ b/sync/src/synchronizer/block_fetcher.rs @@ -1,13 +1,13 @@ use super::header_view::HeaderView; use bigint::H256; +use ckb_core::header::Header; +use ckb_network::PeerIndex; use ckb_shared::index::ChainIndex; use ckb_shared::shared::{ChainProvider, TipHeader}; use ckb_time::now_ms; -use core::header::Header; -use network::PeerIndex; +use ckb_util::RwLockUpgradableReadGuard; use std::cmp; use synchronizer::{BlockStatus, Synchronizer}; -use util::RwLockUpgradableReadGuard; use { BLOCK_DOWNLOAD_TIMEOUT, BLOCK_DOWNLOAD_WINDOW, MAX_BLOCKS_IN_TRANSIT_PER_PEER, PER_FETCH_BLOCK_LIMIT, diff --git a/sync/src/synchronizer/block_pool.rs b/sync/src/synchronizer/block_pool.rs index e78e074b68..bf7ecad1a5 100644 --- a/sync/src/synchronizer/block_pool.rs +++ b/sync/src/synchronizer/block_pool.rs @@ -1,9 +1,9 @@ use bigint::H256; -use core::block::Block; +use ckb_core::block::Block; +use ckb_util::RwLock; use fnv::{FnvHashMap, FnvHashSet}; use std::collections::hash_map::Entry; use std::collections::VecDeque; -use util::RwLock; pub type ParentHash = H256; @@ -59,10 +59,10 @@ impl OrphanBlockPool { #[cfg(test)] mod tests { use super::*; - use chain_spec::consensus::Consensus; + use ckb_chain_spec::consensus::Consensus; + use ckb_core::block::BlockBuilder; + use ckb_core::header::{Header, HeaderBuilder}; use ckb_time::now_ms; - use core::block::BlockBuilder; - use core::header::{Header, HeaderBuilder}; use std::collections::HashSet; use std::iter::FromIterator; diff --git a/sync/src/synchronizer/block_process.rs b/sync/src/synchronizer/block_process.rs index b3cffac23e..ce521fffc1 100644 --- a/sync/src/synchronizer/block_process.rs +++ b/sync/src/synchronizer/block_process.rs @@ -1,7 +1,7 @@ +use ckb_core::block::Block; +use ckb_network::{CKBProtocolContext, PeerIndex}; use ckb_protocol::Block as PBlock; use ckb_shared::index::ChainIndex; -use core::block::Block; -use network::{CKBProtocolContext, PeerIndex}; use synchronizer::Synchronizer; pub struct BlockProcess<'a, CI: ChainIndex + 'a> { diff --git a/sync/src/synchronizer/get_blocks_process.rs b/sync/src/synchronizer/get_blocks_process.rs index 8432044d7d..46ab263bbb 100644 --- a/sync/src/synchronizer/get_blocks_process.rs +++ b/sync/src/synchronizer/get_blocks_process.rs @@ -1,8 +1,8 @@ use bigint::H256; +use ckb_network::{CKBProtocolContext, PeerIndex}; use ckb_protocol::{FlatbuffersVectorIterator, GetBlocks, SyncMessage}; use ckb_shared::index::ChainIndex; use flatbuffers::FlatBufferBuilder; -use network::{CKBProtocolContext, PeerIndex}; use synchronizer::Synchronizer; pub struct GetBlocksProcess<'a, CI: ChainIndex + 'a> { diff --git a/sync/src/synchronizer/get_headers_process.rs b/sync/src/synchronizer/get_headers_process.rs index 0966d855fb..18ea4d74de 100644 --- a/sync/src/synchronizer/get_headers_process.rs +++ b/sync/src/synchronizer/get_headers_process.rs @@ -1,9 +1,9 @@ use bigint::H256; +use ckb_core::header::Header; +use ckb_network::{CKBProtocolContext, PeerIndex, Severity}; use ckb_protocol::{FlatbuffersVectorIterator, GetHeaders, SyncMessage}; use ckb_shared::index::ChainIndex; -use core::header::Header; use flatbuffers::FlatBufferBuilder; -use network::{CKBProtocolContext, PeerIndex, Severity}; use synchronizer::Synchronizer; use MAX_LOCATOR_SIZE; diff --git a/sync/src/synchronizer/header_view.rs b/sync/src/synchronizer/header_view.rs index 612cff06d6..44bd9682f3 100644 --- a/sync/src/synchronizer/header_view.rs +++ b/sync/src/synchronizer/header_view.rs @@ -1,5 +1,5 @@ use bigint::{H256, U256}; -use core::header::{BlockNumber, Header}; +use ckb_core::header::{BlockNumber, Header}; #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct HeaderView { diff --git a/sync/src/synchronizer/headers_process.rs b/sync/src/synchronizer/headers_process.rs index 0405c9f613..065977658d 100644 --- a/sync/src/synchronizer/headers_process.rs +++ b/sync/src/synchronizer/headers_process.rs @@ -1,11 +1,11 @@ use bigint::U256; +use ckb_core::header::Header; +use ckb_network::{CKBProtocolContext, PeerIndex}; use ckb_protocol::{FlatbuffersVectorIterator, Headers}; use ckb_shared::index::ChainIndex; use ckb_shared::shared::ChainProvider; use ckb_verification::{Error as VerifyError, HeaderResolver, HeaderVerifier, Verifier}; -use core::header::Header; use log; -use network::{CKBProtocolContext, PeerIndex}; use std::sync::Arc; use synchronizer::{BlockStatus, Synchronizer}; use MAX_HEADERS_LEN; diff --git a/sync/src/synchronizer/mod.rs b/sync/src/synchronizer/mod.rs index 6878db3843..4233ba89fb 100644 --- a/sync/src/synchronizer/mod.rs +++ b/sync/src/synchronizer/mod.rs @@ -16,25 +16,25 @@ use self::header_view::HeaderView; use self::headers_process::HeadersProcess; use self::peers::Peers; use bigint::H256; -use chain_spec::consensus::Consensus; use ckb_chain::chain::ChainController; use ckb_chain::error::ProcessBlockError; +use ckb_chain_spec::consensus::Consensus; +use ckb_core::block::Block; +use ckb_core::header::{BlockNumber, Header}; +use ckb_network::{CKBProtocolContext, CKBProtocolHandler, PeerIndex, Severity, TimerToken}; use ckb_protocol::{SyncMessage, SyncPayload}; use ckb_shared::index::ChainIndex; use ckb_shared::shared::{ChainProvider, Shared}; use ckb_time::now_ms; +use ckb_util::{RwLock, RwLockUpgradableReadGuard}; use config::Config; -use core::block::Block; -use core::header::{BlockNumber, Header}; use flatbuffers::{get_root, FlatBufferBuilder}; -use network::{CKBProtocolContext, CKBProtocolHandler, PeerIndex, Severity, TimerToken}; use std::cmp; use std::collections::HashMap; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; use std::sync::Arc; use std::time::Duration; -use util::{RwLock, RwLockUpgradableReadGuard}; use { CHAIN_SYNC_TIMEOUT, EVICTION_HEADERS_RESPONSE_TIME, HEADERS_DOWNLOAD_TIMEOUT_BASE, HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER, MAX_HEADERS_LEN, @@ -697,27 +697,27 @@ mod tests { use self::headers_process::HeadersProcess; use super::*; use bigint::U256; - use chain_spec::consensus::Consensus; use ckb_chain::chain::ChainBuilder; + use ckb_chain_spec::consensus::Consensus; + use ckb_core::block::BlockBuilder; + use ckb_core::header::{Header, HeaderBuilder}; + use ckb_core::transaction::{CellInput, CellOutput, Transaction, TransactionBuilder}; + use ckb_db::memorydb::MemoryKeyValueDB; + use ckb_network::{ + random_peer_id, CKBProtocolContext, Endpoint, Error as NetworkError, PeerIndex, PeerInfo, + ProtocolId, SessionInfo, Severity, TimerToken, + }; use ckb_notify::{NotifyController, NotifyService, MINER_SUBSCRIBER}; use ckb_protocol::{Block as FbsBlock, Headers as FbsHeaders}; use ckb_shared::index::ChainIndex; use ckb_shared::shared::SharedBuilder; use ckb_shared::store::ChainKVStore; use ckb_time::set_mock_timer; - use core::block::BlockBuilder; - use core::header::{Header, HeaderBuilder}; - use core::transaction::{CellInput, CellOutput, Transaction, TransactionBuilder}; - use db::memorydb::MemoryKeyValueDB; + use ckb_util::Mutex; use flatbuffers::FlatBufferBuilder; use fnv::{FnvHashMap, FnvHashSet}; - use network::{ - random_peer_id, CKBProtocolContext, Endpoint, Error as NetworkError, PeerIndex, PeerInfo, - ProtocolId, SessionInfo, Severity, TimerToken, - }; use std::ops::Deref; use std::time::Duration; - use util::Mutex; fn start_chain( consensus: Option, diff --git a/sync/src/synchronizer/peers.rs b/sync/src/synchronizer/peers.rs index 920c7a0cc0..0fd538f120 100644 --- a/sync/src/synchronizer/peers.rs +++ b/sync/src/synchronizer/peers.rs @@ -1,12 +1,12 @@ use super::header_view::HeaderView; use bigint::H256; +use ckb_core::block::Block; +use ckb_core::header::Header; +use ckb_network::PeerIndex; use ckb_shared::shared::TipHeader; use ckb_time::now_ms; -use core::block::Block; -use core::header::Header; +use ckb_util::RwLock; use fnv::{FnvHashMap, FnvHashSet}; -use network::PeerIndex; -use util::RwLock; // const BANSCORE: u32 = 100; diff --git a/sync/src/tests/mod.rs b/sync/src/tests/mod.rs index 24d17f1841..c4c9981788 100644 --- a/sync/src/tests/mod.rs +++ b/sync/src/tests/mod.rs @@ -1,4 +1,4 @@ -use network::{ +use ckb_network::{ CKBProtocolContext, CKBProtocolHandler, Error as NetworkError, PeerIndex, ProtocolId, SessionInfo, Severity, TimerToken, }; diff --git a/sync/src/tests/relayer.rs b/sync/src/tests/relayer.rs index 5a90a5fd3b..c07fb1f6e2 100644 --- a/sync/src/tests/relayer.rs +++ b/sync/src/tests/relayer.rs @@ -1,17 +1,17 @@ use bigint::{H256, U256}; -use chain_spec::consensus::Consensus; use ckb_chain::chain::{ChainBuilder, ChainController}; +use ckb_chain_spec::consensus::Consensus; +use ckb_core::block::BlockBuilder; +use ckb_core::header::HeaderBuilder; +use ckb_core::script::Script; +use ckb_core::transaction::{CellInput, CellOutput, OutPoint, TransactionBuilder}; +use ckb_db::memorydb::MemoryKeyValueDB; use ckb_notify::NotifyService; use ckb_pool::txs_pool::{PoolConfig, TransactionPoolController, TransactionPoolService}; use ckb_protocol::RelayMessage; use ckb_shared::shared::{ChainProvider, Shared, SharedBuilder}; use ckb_shared::store::ChainKVStore; use ckb_time::now_ms; -use core::block::BlockBuilder; -use core::header::HeaderBuilder; -use core::script::Script; -use core::transaction::{CellInput, CellOutput, OutPoint, TransactionBuilder}; -use db::memorydb::MemoryKeyValueDB; use flatbuffers::get_root; use flatbuffers::FlatBufferBuilder; use relayer::TX_PROPOSAL_TOKEN; diff --git a/sync/src/tests/synchronizer.rs b/sync/src/tests/synchronizer.rs index f426b86d63..62aeecffb2 100644 --- a/sync/src/tests/synchronizer.rs +++ b/sync/src/tests/synchronizer.rs @@ -1,15 +1,15 @@ use bigint::U256; -use chain_spec::consensus::Consensus; use ckb_chain::chain::{ChainBuilder, ChainController}; +use ckb_chain_spec::consensus::Consensus; +use ckb_core::block::BlockBuilder; +use ckb_core::header::HeaderBuilder; +use ckb_core::transaction::{CellInput, CellOutput, TransactionBuilder}; +use ckb_db::memorydb::MemoryKeyValueDB; use ckb_notify::NotifyService; use ckb_protocol::SyncMessage; use ckb_shared::shared::{ChainProvider, Shared, SharedBuilder}; use ckb_shared::store::ChainKVStore; use ckb_time::now_ms; -use core::block::BlockBuilder; -use core::header::HeaderBuilder; -use core::transaction::{CellInput, CellOutput, TransactionBuilder}; -use db::memorydb::MemoryKeyValueDB; use flatbuffers::get_root; use std::sync::mpsc::channel; use std::sync::Arc; diff --git a/util/avl/src/lib.rs b/util/avl/src/lib.rs index 87ecc7791a..bc4ac88d1b 100644 --- a/util/avl/src/lib.rs +++ b/util/avl/src/lib.rs @@ -3,8 +3,8 @@ extern crate serde_derive; extern crate bigint; extern crate bincode; -extern crate ckb_core as core; -extern crate ckb_db as db; +extern crate ckb_core; +extern crate ckb_db; extern crate hash; use bigint::H256; diff --git a/util/avl/src/node.rs b/util/avl/src/node.rs index 281534f1f2..f249932c79 100644 --- a/util/avl/src/node.rs +++ b/util/avl/src/node.rs @@ -1,9 +1,9 @@ use super::{AVLError, Result}; use bigint::H256; use bincode::{deserialize, serialize}; -use core::transaction_meta::TransactionMeta; -use db::batch::{Batch, Col}; -use db::kvdb::KeyValueDB; +use ckb_core::transaction_meta::TransactionMeta; +use ckb_db::batch::{Batch, Col}; +use ckb_db::kvdb::KeyValueDB; use hash::sha3_256; // DB node in the avl @@ -62,7 +62,7 @@ pub fn search( mod tests { const TEST_COL: Col = Some(0); use super::*; - use db::memorydb::MemoryKeyValueDB; + use ckb_db::memorydb::MemoryKeyValueDB; fn get_meta(node: &DBNode) -> Option { match node { diff --git a/util/avl/src/tree.rs b/util/avl/src/tree.rs index 275c67ab9c..a72c997e3c 100644 --- a/util/avl/src/tree.rs +++ b/util/avl/src/tree.rs @@ -1,10 +1,10 @@ use super::Result; use bigint::H256; -use core::transaction_meta::TransactionMeta; +use ckb_core::transaction_meta::TransactionMeta; use node::{get, insert, DBNode}; -use db::batch::{Batch, Col}; -use db::kvdb::KeyValueDB; +use ckb_db::batch::{Batch, Col}; +use ckb_db::kvdb::KeyValueDB; use std::sync::Arc; @@ -475,7 +475,7 @@ impl AvlTree { #[cfg(test)] mod tests { use super::*; - use db::memorydb::MemoryKeyValueDB; + use ckb_db::memorydb::MemoryKeyValueDB; const TEST_COL: Col = Some(0); diff --git a/verification/src/block_verifier.rs b/verification/src/block_verifier.rs index 72616d9bc8..6e7a486f2b 100644 --- a/verification/src/block_verifier.rs +++ b/verification/src/block_verifier.rs @@ -1,11 +1,11 @@ use super::header_verifier::HeaderResolver; use super::{TransactionVerifier, Verifier}; use bigint::{H256, U256}; +use ckb_core::block::Block; +use ckb_core::cell::{CellProvider, CellStatus}; +use ckb_core::header::Header; +use ckb_core::transaction::{Capacity, CellInput, OutPoint}; use ckb_shared::shared::ChainProvider; -use core::block::Block; -use core::cell::{CellProvider, CellStatus}; -use core::header::Header; -use core::transaction::{Capacity, CellInput, OutPoint}; use error::TransactionError; use error::{CellbaseError, CommitError, Error, UnclesError}; use fnv::{FnvHashMap, FnvHashSet}; diff --git a/verification/src/error.rs b/verification/src/error.rs index 8647285b3b..de7d6817bf 100644 --- a/verification/src/error.rs +++ b/verification/src/error.rs @@ -1,7 +1,7 @@ use bigint::{H256, U256}; +use ckb_core::BlockNumber; +use ckb_script::ScriptError; use ckb_shared::error::SharedError; -use core::BlockNumber; -use script::ScriptError; /// Block verification error #[derive(Debug, PartialEq, Clone, Eq)] diff --git a/verification/src/header_verifier.rs b/verification/src/header_verifier.rs index 2355798bad..3b9d07918f 100644 --- a/verification/src/header_verifier.rs +++ b/verification/src/header_verifier.rs @@ -1,12 +1,12 @@ use super::Verifier; use bigint::U256; -use core::header::Header; +use ckb_core::header::Header; +use ckb_pow::PowEngine; +use ckb_time::now_ms; use error::{DifficultyError, Error, NumberError, PowError, TimestampError}; -use pow::PowEngine; use shared::ALLOWED_FUTURE_BLOCKTIME; use std::marker::PhantomData; use std::sync::Arc; -use time::now_ms; pub trait HeaderResolver { fn header(&self) -> &Header; diff --git a/verification/src/lib.rs b/verification/src/lib.rs index 1b50926b34..24e314f539 100644 --- a/verification/src/lib.rs +++ b/verification/src/lib.rs @@ -1,21 +1,21 @@ extern crate bigint; -extern crate ckb_core as core; -extern crate ckb_pow as pow; -extern crate ckb_script as script; +extern crate ckb_core; +extern crate ckb_pow; +extern crate ckb_script; extern crate ckb_shared; -extern crate ckb_time as time; +extern crate ckb_time; extern crate fnv; extern crate merkle_root; extern crate rayon; #[cfg(test)] -extern crate ckb_chain as chain; +extern crate ckb_chain; #[cfg(test)] -extern crate ckb_chain_spec as chain_spec; +extern crate ckb_chain_spec; #[cfg(test)] -extern crate ckb_db as db; +extern crate ckb_db; #[cfg(test)] -extern crate ckb_notify as notify; +extern crate ckb_notify; #[cfg(test)] extern crate hash; diff --git a/verification/src/tests/block_verifier.rs b/verification/src/tests/block_verifier.rs index a390d907b8..56e5a69ffd 100644 --- a/verification/src/tests/block_verifier.rs +++ b/verification/src/tests/block_verifier.rs @@ -2,10 +2,10 @@ use super::super::block_verifier::{BlockVerifier, CellbaseVerifier, EmptyVerifie use super::super::error::{CellbaseError, Error as VerifyError}; use super::dummy::DummyChainProvider; use bigint::H256; +use ckb_core::block::BlockBuilder; +use ckb_core::transaction::{CellInput, CellOutput, OutPoint, Transaction, TransactionBuilder}; +use ckb_core::Capacity; use ckb_shared::error::SharedError; -use core::block::BlockBuilder; -use core::transaction::{CellInput, CellOutput, OutPoint, Transaction, TransactionBuilder}; -use core::Capacity; use std::collections::HashMap; use Verifier; diff --git a/verification/src/tests/commit_verifier.rs b/verification/src/tests/commit_verifier.rs index f396785828..f837b8d3a6 100644 --- a/verification/src/tests/commit_verifier.rs +++ b/verification/src/tests/commit_verifier.rs @@ -1,19 +1,19 @@ use super::super::block_verifier::CommitVerifier; use super::super::error::{CommitError, Error}; use bigint::{H256, U256}; -use chain::chain::{ChainBuilder, ChainController}; -use chain_spec::consensus::Consensus; -use ckb_shared::shared::{ChainProvider, Shared, SharedBuilder}; -use ckb_shared::store::ChainKVStore; -use core::block::{Block, BlockBuilder}; -use core::header::{Header, HeaderBuilder}; -use core::script::Script; -use core::transaction::{ +use ckb_chain::chain::{ChainBuilder, ChainController}; +use ckb_chain_spec::consensus::Consensus; +use ckb_core::block::{Block, BlockBuilder}; +use ckb_core::header::{Header, HeaderBuilder}; +use ckb_core::script::Script; +use ckb_core::transaction::{ CellInput, CellOutput, OutPoint, ProposalShortId, Transaction, TransactionBuilder, }; -use core::uncle::UncleBlock; -use core::BlockNumber; -use db::memorydb::MemoryKeyValueDB; +use ckb_core::uncle::UncleBlock; +use ckb_core::BlockNumber; +use ckb_db::memorydb::MemoryKeyValueDB; +use ckb_shared::shared::{ChainProvider, Shared, SharedBuilder}; +use ckb_shared::store::ChainKVStore; use fnv::FnvHashMap; use std::fs::File; use std::io::Read; diff --git a/verification/src/tests/dummy.rs b/verification/src/tests/dummy.rs index 05dc83c5fd..5ad1b3a0e6 100644 --- a/verification/src/tests/dummy.rs +++ b/verification/src/tests/dummy.rs @@ -1,14 +1,14 @@ use bigint::{H256, U256}; -use chain_spec::consensus::Consensus; +use ckb_chain_spec::consensus::Consensus; +use ckb_core::block::Block; +use ckb_core::cell::{CellProvider, CellStatus}; +use ckb_core::extras::BlockExt; +use ckb_core::header::{BlockNumber, Header}; +use ckb_core::transaction::{Capacity, OutPoint, ProposalShortId, Transaction}; +use ckb_core::transaction_meta::TransactionMeta; +use ckb_core::uncle::UncleBlock; use ckb_shared::error::SharedError; use ckb_shared::shared::ChainProvider; -use core::block::Block; -use core::cell::{CellProvider, CellStatus}; -use core::extras::BlockExt; -use core::header::{BlockNumber, Header}; -use core::transaction::{Capacity, OutPoint, ProposalShortId, Transaction}; -use core::transaction_meta::TransactionMeta; -use core::uncle::UncleBlock; use std::collections::HashMap; #[derive(Default, Clone)] diff --git a/verification/src/tests/transaction_verifier.rs b/verification/src/tests/transaction_verifier.rs index a05d6e619a..20e811fdab 100644 --- a/verification/src/tests/transaction_verifier.rs +++ b/verification/src/tests/transaction_verifier.rs @@ -2,9 +2,9 @@ use super::super::transaction_verifier::{ CapacityVerifier, DuplicateInputsVerifier, EmptyVerifier, NullVerifier, }; use bigint::H256; -use core::cell::CellStatus; -use core::cell::ResolvedTransaction; -use core::transaction::{CellInput, CellOutput, OutPoint, TransactionBuilder}; +use ckb_core::cell::CellStatus; +use ckb_core::cell::ResolvedTransaction; +use ckb_core::transaction::{CellInput, CellOutput, OutPoint, TransactionBuilder}; use error::TransactionError; #[test] diff --git a/verification/src/tests/uncle_verifier.rs b/verification/src/tests/uncle_verifier.rs index 6349502bce..6cdf0b486e 100644 --- a/verification/src/tests/uncle_verifier.rs +++ b/verification/src/tests/uncle_verifier.rs @@ -1,17 +1,19 @@ use super::super::block_verifier::UnclesVerifier; use super::super::error::{Error, UnclesError}; use bigint::{H256, U256}; -use chain::chain::{ChainBuilder, ChainController}; -use chain_spec::consensus::Consensus; +use ckb_chain::chain::{ChainBuilder, ChainController}; +use ckb_chain_spec::consensus::Consensus; +use ckb_core::block::{Block, BlockBuilder}; +use ckb_core::header::{Header, HeaderBuilder}; +use ckb_core::transaction::{ + CellInput, CellOutput, ProposalShortId, Transaction, TransactionBuilder, +}; +use ckb_core::BlockNumber; +use ckb_db::memorydb::MemoryKeyValueDB; use ckb_shared::shared::{ChainProvider, Shared, SharedBuilder}; use ckb_shared::store::ChainKVStore; -use core::block::{Block, BlockBuilder}; -use core::header::{Header, HeaderBuilder}; -use core::transaction::{CellInput, CellOutput, ProposalShortId, Transaction, TransactionBuilder}; -use core::BlockNumber; -use db::memorydb::MemoryKeyValueDB; +use ckb_time::set_mock_timer; use std::sync::Arc; -use time::set_mock_timer; fn gen_block(parent_header: Header, nonce: u64, difficulty: U256) -> Block { let now = 1 + parent_header.timestamp(); diff --git a/verification/src/transaction_verifier.rs b/verification/src/transaction_verifier.rs index 74eb823a3e..b39786af3b 100644 --- a/verification/src/transaction_verifier.rs +++ b/verification/src/transaction_verifier.rs @@ -1,7 +1,7 @@ -use core::cell::ResolvedTransaction; -use core::transaction::{Capacity, Transaction}; +use ckb_core::cell::ResolvedTransaction; +use ckb_core::transaction::{Capacity, Transaction}; +use ckb_script::TransactionScriptsVerifier; use error::TransactionError; -use script::TransactionScriptsVerifier; use std::collections::HashSet; pub struct TransactionVerifier<'a> {