From bf6d02d102aa36ff5ae81a198dede45ac5923dbe Mon Sep 17 00:00:00 2001 From: zhangsoledad <787953403@qq.com> Date: Tue, 13 Mar 2018 17:36:17 +0800 Subject: [PATCH 01/14] feat: update rust-toolchain nightly-2018-03-07 --- .travis.yml | 10 +++++----- README.md | 6 +++--- chain/src/chain.rs | 4 ++-- core/src/block.rs | 14 +++++++------- core/src/lib.rs | 8 ++++---- rust-toolchain | 2 +- rustfmt.toml | 1 + src/adapter.rs | 4 ++-- src/cli/run_impl.rs | 4 ++-- src/main.rs | 2 +- util/crypto/src/bech32/error.rs | 21 ++++++++++++++------- util/crypto/src/secp/error.rs | 18 ++++++++++++------ util/crypto/src/secp/mod.rs | 4 ++-- util/kvdb-rocksdb/src/lib.rs | 8 ++++---- util/kvdb/src/lib.rs | 9 +++------ util/logger/src/lib.rs | 2 +- 16 files changed, 64 insertions(+), 53 deletions(-) diff --git a/.travis.yml b/.travis.yml index a80c573b42..f1a4079a9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,23 +4,23 @@ cache: cargo env: global: - - CLIPPY_VERSION=0.0.181 + - CLIPPY_VERSION=0.0.187 matrix: include: - os: osx - rust: nightly-2018-01-23 + rust: nightly-2018-03-07 before_script: - - rustup component add rustfmt-preview --toolchain=nightly-2018-01-23 + - rustup component add rustfmt-preview --toolchain=nightly-2018-03-07 - bash -c 'if [[ ! -e $HOME/.cargo/bin/cargo-clippy ]]; then cargo install clippy --vers $CLIPPY_VERSION --force; fi' - - rust: nightly-2018-01-23 + - rust: nightly-2018-03-07 before_install: - sudo apt-get -qq update - sudo apt-get install -y git autoconf flex bison texinfo libtool before_script: - - rustup component add rustfmt-preview --toolchain=nightly-2018-01-23 + - rustup component add rustfmt-preview --toolchain=nightly-2018-03-07 - bash -c 'if [[ ! -e $HOME/.cargo/bin/cargo-clippy ]]; then cargo install clippy --vers $CLIPPY_VERSION --force; fi' diff --git a/README.md b/README.md index 13b631e0f5..c7b4dc54aa 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,14 @@ Nervos project defines a suite of scalable and interoperable blockchain protocol ## Build dependencies -**Rust Nightly is required**. Nervos is currently tested mainly with `nightly-2018-01-23`. +**Rust Nightly is required**. Nervos is currently tested mainly with `nightly-2018-03-07`. We recommend installing Rust through [rustup](https://www.rustup.rs/) ```bash # Get rustup from rustup.rs, then in your `nervos` folder: -rustup override set nightly-2018-01-23 -rustup component add rustfmt-preview --toolchain=nightly-2018-01-23 +rustup override set nightly-2018-03-07 +rustup component add rustfmt-preview --toolchain=nightly-2018-03-07 ``` we would like to track `nightly`, report new breakage is welcome. diff --git a/chain/src/chain.rs b/chain/src/chain.rs index a50ac981fd..5fc61d9e5e 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -38,8 +38,8 @@ impl Chain { } }; Ok(Chain { - store: store, - adapter: adapter, + store, + adapter, head_header: RwLock::new(head_header), lock: Mutex::new(()), }) diff --git a/core/src/block.rs b/core/src/block.rs index 2494d0c445..01fb931abd 100644 --- a/core/src/block.rs +++ b/core/src/block.rs @@ -65,10 +65,10 @@ impl Header { pub fn new(raw: RawHeader, total_difficulty: U256, sig: Option) -> Header { let hash = raw.cal_hash(); Header { - raw: raw, + raw, + hash, + total_difficulty, signature: sig.unwrap_or_default(), - total_difficulty: total_difficulty, - hash: hash, } } @@ -186,13 +186,13 @@ impl Block { let txs_hash: Vec = txs.iter().map(|t| t.hash()).collect(); let txs_root = merkle_root(txs_hash.as_slice()); let raw = RawHeader { + timestamp, + difficulty, + challenge, + proof, pre_hash: pre_header.hash(), - timestamp: timestamp, height: pre_header.height + 1, transactions_root: txs_root, - difficulty: difficulty, - challenge: challenge, - proof: proof, }; Block { diff --git a/core/src/lib.rs b/core/src/lib.rs index 318a3a7523..487b440bde 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -10,14 +10,14 @@ extern crate serde_derive; extern crate bincode; extern crate serde; -pub mod transaction; +pub mod adapter; pub mod block; -pub mod proof; pub mod difficulty; -pub mod global; -pub mod adapter; pub mod error; +pub mod global; pub mod keygroup; +pub mod proof; +pub mod transaction; pub use error::Error; diff --git a/rust-toolchain b/rust-toolchain index f43b1220a0..fb16736ca6 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2018-01-23 +nightly-2018-03-07 diff --git a/rustfmt.toml b/rustfmt.toml index 6f2d8f309b..3428b85bd0 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -5,4 +5,5 @@ reorder_imported_names = true reorder_imports_in_group = true reorder_extern_crates = true reorder_extern_crates_in_group = true +reorder_modules = true use_try_shorthand = true diff --git a/src/adapter.rs b/src/adapter.rs index 5ebfce1d58..60830b3442 100644 --- a/src/adapter.rs +++ b/src/adapter.rs @@ -45,7 +45,7 @@ impl ChainAdapter for ChainToNetAndPoolAdapter { impl ChainToNetAndPoolAdapter { pub fn new(tx_pool: Arc) -> Self { ChainToNetAndPoolAdapter { - tx_pool: tx_pool, + tx_pool, network: RwLock::new(None), } } @@ -89,10 +89,10 @@ impl NetToChainAndPoolAdapter { tx_pool: Arc, ) -> Arc { let adapter = Arc::new(NetToChainAndPoolAdapter { + tx_pool, key_group: kg, orphan_pool: Arc::new(OrphanBlockPool::default()), pending_pool: Arc::new(PendingBlockPool::default()), - tx_pool: tx_pool, chain: Arc::downgrade(chain), }); diff --git a/src/cli/run_impl.rs b/src/cli/run_impl.rs index 3bb6200a6c..2a011743fd 100644 --- a/src/cli/run_impl.rs +++ b/src/cli/run_impl.rs @@ -40,8 +40,8 @@ pub fn run(config_path: &str) { chain_adapter.init(&network); let miner = Miner { - chain: chain, - tx_pool: tx_pool, + chain, + tx_pool, miner_key: config.miner_private_key, signer_key: bigint::H256::from(&config.signer_private_key[..]), }; diff --git a/src/main.rs b/src/main.rs index a51b97cb72..8db85708b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,9 +18,9 @@ extern crate serde; extern crate serde_derive; extern crate toml; -mod config; mod adapter; mod cli; +mod config; fn main() { // Always print backtrace on panic. diff --git a/util/crypto/src/bech32/error.rs b/util/crypto/src/bech32/error.rs index 2ba094d88d..77b359a7c4 100644 --- a/util/crypto/src/bech32/error.rs +++ b/util/crypto/src/bech32/error.rs @@ -3,13 +3,20 @@ use std::string::FromUtf8Error; /// Error types for Bech32 encoding / decoding #[derive(Debug, PartialEq, Eq, Fail)] pub enum Error { - #[fail(display = "missing human-readable separator")] MissingSeparator, - #[fail(display = "invalid checksum")] InvalidChecksum, - #[fail(display = "invalid length")] InvalidLength, - #[fail(display = "invalid character (code={})", _0)] InvalidChar(u8), - #[fail(display = "invalid data point ({})", _0)] InvalidData(u8), - #[fail(display = "mixed-case strings not allowed")] MixedCase, - #[fail(display = "{}", _0)] Utf8Error(String), + #[fail(display = "missing human-readable separator")] + MissingSeparator, + #[fail(display = "invalid checksum")] + InvalidChecksum, + #[fail(display = "invalid length")] + InvalidLength, + #[fail(display = "invalid character (code={})", _0)] + InvalidChar(u8), + #[fail(display = "invalid data point ({})", _0)] + InvalidData(u8), + #[fail(display = "mixed-case strings not allowed")] + MixedCase, + #[fail(display = "{}", _0)] + Utf8Error(String), } impl From for Error { diff --git a/util/crypto/src/secp/error.rs b/util/crypto/src/secp/error.rs index 0959e39c28..074eda0126 100644 --- a/util/crypto/src/secp/error.rs +++ b/util/crypto/src/secp/error.rs @@ -2,12 +2,18 @@ use super::secp256k1::Error as SecpError; #[derive(Debug, PartialEq, Eq, Fail)] pub enum Error { - #[fail(display = "invalid privkey")] InvalidPrivKey, - #[fail(display = "invalid pubkey")] InvalidPubKey, - #[fail(display = "invalid signature")] InvalidSignature, - #[fail(display = "invalid message")] InvalidMessage, - #[fail(display = "invalid recovery_id")] InvalidRecoveryId, - #[fail(display = "{}", _0)] Other(String), + #[fail(display = "invalid privkey")] + InvalidPrivKey, + #[fail(display = "invalid pubkey")] + InvalidPubKey, + #[fail(display = "invalid signature")] + InvalidSignature, + #[fail(display = "invalid message")] + InvalidMessage, + #[fail(display = "invalid recovery_id")] + InvalidRecoveryId, + #[fail(display = "{}", _0)] + Other(String), } impl From for Error { diff --git a/util/crypto/src/secp/mod.rs b/util/crypto/src/secp/mod.rs index ee1e1c3a8d..311cf69c5c 100644 --- a/util/crypto/src/secp/mod.rs +++ b/util/crypto/src/secp/mod.rs @@ -10,11 +10,11 @@ lazy_static! { pub static ref SECP256K1: secp256k1::Secp256k1 = secp256k1::Secp256k1::new(); } +mod error; +mod generator; mod privkey; mod pubkey; mod signature; -mod generator; -mod error; pub use self::error::Error; pub use self::generator::Generator; diff --git a/util/kvdb-rocksdb/src/lib.rs b/util/kvdb-rocksdb/src/lib.rs index 171280c2bf..69661cbb5f 100644 --- a/util/kvdb-rocksdb/src/lib.rs +++ b/util/kvdb-rocksdb/src/lib.rs @@ -400,15 +400,15 @@ impl Database { }; let num_cols = cfs.len(); Ok(Database { - db: RwLock::new(Some(DBAndColumns { db: db, cfs: cfs })), + read_opts, + block_opts, + write_opts, + db: RwLock::new(Some(DBAndColumns { db, cfs })), config: config.clone(), - write_opts: write_opts, overlay: RwLock::new((0..(num_cols + 1)).map(|_| HashMap::new()).collect()), flushing: RwLock::new((0..(num_cols + 1)).map(|_| HashMap::new()).collect()), flushing_lock: Mutex::new(false), path: path.to_owned(), - read_opts: read_opts, - block_opts: block_opts, }) } diff --git a/util/kvdb/src/lib.rs b/util/kvdb/src/lib.rs index 4230c84fc8..0f91af651e 100644 --- a/util/kvdb/src/lib.rs +++ b/util/kvdb/src/lib.rs @@ -80,7 +80,7 @@ impl DBTransaction { let mut ekey = ElasticArray32::new(); ekey.append_slice(key); self.ops.push(DBOp::Insert { - col: col, + col, key: ekey, value: DBValue::from_slice(value), }); @@ -91,7 +91,7 @@ impl DBTransaction { let mut ekey = ElasticArray32::new(); ekey.append_slice(key); self.ops.push(DBOp::Insert { - col: col, + col, key: ekey, value: DBValue::from_vec(value), }); @@ -101,10 +101,7 @@ impl DBTransaction { pub fn delete(&mut self, col: Option, key: &[u8]) { let mut ekey = ElasticArray32::new(); ekey.append_slice(key); - self.ops.push(DBOp::Delete { - col: col, - key: ekey, - }); + self.ops.push(DBOp::Delete { col, key: ekey }); } } diff --git a/util/logger/src/lib.rs b/util/logger/src/lib.rs index 401fd51f24..bd3c00ae92 100644 --- a/util/logger/src/lib.rs +++ b/util/logger/src/lib.rs @@ -85,7 +85,7 @@ impl Logger { .unwrap(); Logger { - sender: sender, + sender, handle: Mutex::new(Some(tb)), filter: builder.build(), } From 85134b5893d9cbedb0b7b520dd588a19962e5cbf Mon Sep 17 00:00:00 2001 From: quake wang Date: Wed, 14 Mar 2018 15:43:54 +0900 Subject: [PATCH 02/14] feat: Use rocksdb to persist data --- .gitignore | 3 + Cargo.lock | 308 ++++++++---- Cargo.toml | 1 - chain/src/chain.rs | 19 +- chain/src/lib.rs | 3 - chain/src/store.rs | 87 ---- core/Cargo.toml | 2 - db/Cargo.toml | 7 +- db/src/batch.rs | 62 +++ db/src/cachedb.rs | 128 +++++ db/src/diskdb.rs | 174 +++++++ db/src/kvdb.rs | 82 +--- db/src/lib.rs | 12 +- db/src/memorydb.rs | 84 ++++ db/src/store.rs | 146 ++++++ default.toml | 1 + miner/Cargo.toml | 1 + miner/src/lib.rs | 1 + miner/src/miner.rs | 2 +- src/adapter.rs | 7 +- src/cli/run_impl.rs | 8 +- src/config.rs | 2 + util/kvdb-rocksdb/Cargo.toml | 18 - util/kvdb-rocksdb/src/lib.rs | 923 ----------------------------------- util/kvdb/Cargo.toml | 8 - util/kvdb/src/lib.rs | 164 ------- 26 files changed, 851 insertions(+), 1402 deletions(-) delete mode 100644 chain/src/store.rs create mode 100644 db/src/batch.rs create mode 100644 db/src/cachedb.rs create mode 100644 db/src/diskdb.rs create mode 100644 db/src/memorydb.rs create mode 100644 db/src/store.rs delete mode 100644 util/kvdb-rocksdb/Cargo.toml delete mode 100644 util/kvdb-rocksdb/src/lib.rs delete mode 100644 util/kvdb/Cargo.toml delete mode 100644 util/kvdb/src/lib.rs diff --git a/.gitignore b/.gitignore index 5e716188a5..00298f41ce 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ admintool/example/ # vagrant file .vagrant + +# nervos runtime folder +.nervos diff --git a/Cargo.lock b/Cargo.lock index 271344a48c..3aea386bba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,6 +32,14 @@ dependencies = [ "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "aster" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "atty" version = "0.2.6" @@ -127,11 +135,36 @@ dependencies = [ "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "bindgen" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cexpr 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "clang-sys 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi_codegen 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bitflags" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "bitflags" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "bitflags" version = "0.9.1" @@ -197,6 +230,14 @@ dependencies = [ "rayon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cexpr" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cfg-if" version = "0.1.2" @@ -230,6 +271,16 @@ dependencies = [ "multihash 0.7.0 (git+https://github.com/tomaka/rust-multihash?branch=emscripten-hack)", ] +[[package]] +name = "clang-sys" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "libloading 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "clap" version = "2.31.1" @@ -394,14 +445,6 @@ name = "either" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "elastic-array" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "env_logger" version = "0.4.3" @@ -523,9 +566,6 @@ dependencies = [ name = "gcc" version = "0.3.54" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "generic-array" @@ -536,8 +576,8 @@ dependencies = [ ] [[package]] -name = "getopts" -version = "0.2.17" +name = "glob" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -610,11 +650,6 @@ name = "integer-encoding" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "interleaved-ordered" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "iovec" version = "0.1.2" @@ -638,30 +673,6 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "kvdb" -version = "0.1.0" -dependencies = [ - "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "kvdb-rocksdb" -version = "0.1.0" -dependencies = [ - "bigint 0.2.3", - "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb 0.1.0", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)", - "tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "language-tags" version = "0.2.2" @@ -687,6 +698,16 @@ name = "libc" version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "libloading" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "libp2p-peerstore" version = "0.1.0" @@ -776,15 +797,21 @@ dependencies = [ ] [[package]] -name = "local-encoding" -version = "0.2.0" +name = "librocksdb-sys" +version = "5.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "skeptic 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "bindgen 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "make-cmd 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "linked-hash-map" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "log" version = "0.3.9" @@ -817,6 +844,19 @@ dependencies = [ "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lru-cache" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "make-cmd" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "matches" version = "0.1.6" @@ -851,6 +891,14 @@ dependencies = [ "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "memchr" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "memchr" version = "2.0.1" @@ -1039,8 +1087,6 @@ dependencies = [ "bls 0.1.0 (git+https://github.com/NervosFoundation/bls-rs.git)", "crypto 0.1.0", "hash 0.1.0", - "kvdb 0.1.0", - "kvdb-rocksdb 0.1.0", "merkle-root 0.1.0", "nervos-time 0.1.0", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1051,10 +1097,15 @@ dependencies = [ name = "nervos-db" version = "0.1.0" dependencies = [ + "bigint 0.2.3", "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nervos-core 0.1.0", "nervos-util 0.1.0", + "rocksdb 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1065,6 +1116,7 @@ dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "nervos-chain 0.1.0", "nervos-core 0.1.0", + "nervos-db 0.1.0", "nervos-pool 0.1.0", "nervos-time 0.1.0", ] @@ -1160,6 +1212,14 @@ name = "nodrop" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "nom" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "num" version = "0.1.42" @@ -1294,6 +1354,11 @@ dependencies = [ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "percent-encoding" version = "1.0.1" @@ -1310,11 +1375,23 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "pulldown-cmark" -version = "0.0.3" +name = "quasi" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quasi_codegen" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1347,14 +1424,6 @@ dependencies = [ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rayon" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rayon" version = "0.9.0" @@ -1429,23 +1498,11 @@ dependencies = [ [[package]] name = "rocksdb" -version = "0.4.5" -source = "git+https://github.com/paritytech/rust-rocksdb#ecf06adf3148ab10f6f7686b724498382ff4f36e" -dependencies = [ - "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "local-encoding 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rocksdb-sys 0.3.0 (git+https://github.com/paritytech/rust-rocksdb)", -] - -[[package]] -name = "rocksdb-sys" -version = "0.3.0" -source = "git+https://github.com/paritytech/rust-rocksdb#ecf06adf3148ab10f6f7686b724498382ff4f36e" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "local-encoding 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "snappy-sys 0.1.0 (git+https://github.com/paritytech/rust-snappy)", + "librocksdb-sys 5.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1616,15 +1673,6 @@ dependencies = [ "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "skeptic" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "pulldown-cmark 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "slab" version = "0.3.0" @@ -1645,15 +1693,6 @@ name = "smallvec" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "snappy-sys" -version = "0.1.0" -source = "git+https://github.com/paritytech/rust-snappy#858eac97192ea25d18d3f3626a8cc13ca0b175bb" -dependencies = [ - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "stable_deref_trait" version = "1.0.0" @@ -1696,6 +1735,48 @@ dependencies = [ "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syntex" +version = "0.58.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syntex_errors" +version = "0.58.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syntex_pos" +version = "0.58.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syntex_syntax" +version = "0.58.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tempdir" version = "0.3.6" @@ -1717,6 +1798,15 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "term" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "termcolor" version = "0.3.5" @@ -2015,6 +2105,7 @@ dependencies = [ "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum arrayref 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0fd1479b7c29641adbd35ff3b5c293922d696a92f25c8c975da3e0acbc87258f" "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" +"checksum aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfdf7355d9db158df68f976ed030ab0f6578af811f5a7bb6dcf221ec24e0e0" "checksum atty 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8352656fd42c30a0c3c89d26dea01e3b77c0ab2af18230835c15e2e13cd51859" "checksum backtrace 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbbf59b1c43eefa8c3ede390fcc36820b4999f7914104015be25025e0d62af2" "checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661" @@ -2024,7 +2115,9 @@ dependencies = [ "checksum base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96434f987501f0ed4eb336a411e0631ecd1afa11574fe148587adc4ff96143c9" "checksum base64 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5032d51da2741729bfdaeb2664d9b8c6d9fd1e2b90715c660b6def36628499c2" "checksum bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bda13183df33055cbb84b847becce220d392df502ebe7a4a78d7021771ed94d0" +"checksum bindgen 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ba610cba0c1727ed837316540068b51349b8268c073906067b7c3948598929bd" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" +"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" "checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab" @@ -2035,10 +2128,12 @@ dependencies = [ "checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23" "checksum bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1b7db437d718977f6dc9b2e3fd6fc343c02ac6b899b73fdd2179163447bd9ce9" "checksum cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "deaf9ec656256bb25b404c51ef50097207b9cbb29c933d31f92cae5a8a0ffee0" +"checksum cexpr 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42aac45e9567d97474a834efdee3081b3c942b2205be932092f53354ce503d6c" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" "checksum chashmap 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "47e651a8c1eb0cbbaa730f705e2531e75276c6f2bbe2eb12662cfd305213dff8" "checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9" "checksum cid 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d85ee025368e69063c420cbb2ed9f852cb03a5e69b73be021e65726ce03585b6" +"checksum clang-sys 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e414af9726e1d11660801e73ccc7fb81803fb5f49e5903a25b348b2b3b480d2e" "checksum clap 2.31.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dc18f6f4005132120d9711636b32c46a233fad94df6217fa1d81c5e97a9f200" "checksum core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25bfd746d203017f7d5cbd31ee5d8e17f94b6521c7af77ece6c9e4b2d4b16c67" "checksum core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "065a5d7ffdcbc8fa145d6f0746f3555025b9097a9e9cda59f7467abae670c78d" @@ -2055,7 +2150,6 @@ dependencies = [ "checksum dns-parser 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7020f6760aea312d43d23cb83bf6c0c49f162541db8b02bf95209ac51dc253d" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" "checksum either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "740178ddf48b1a9e878e6d6509a1442a2d42fd2928aae8e7a6f8a36fb01981b3" -"checksum elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "258ff6a9a94f648d0379dbd79110e057edbb53eb85cc237e33eadf8e5a30df85" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum env_logger 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f3cc21490995c841d68e00276eba02071ebb269ec24011d5728bd00eabd39e31" "checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" @@ -2072,7 +2166,7 @@ dependencies = [ "checksum futures-mutex 0.2.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" -"checksum getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "b900c08c1939860ce8b54dc6a89e26e00c04c380fd0e09796799bd7f12861e05" +"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2f407128745b78abc95c0ffbe4e5d37427fdc0d45470710cfef8c44522a2e37" "checksum humantime 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369e01a05e3404c421b5d6dcfea6ecf7d5e65eba8a275948151358cd8282042" @@ -2080,7 +2174,6 @@ dependencies = [ "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum ifaces 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa5cce6b4cae6792378aefb34152be19600949dde0041e7910430022f94b81f1" "checksum integer-encoding 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26746cbc2e680af687e88d717f20ff90079bd10fc984ad57d277cd0e37309fa5" -"checksum interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141340095b15ed7491bd3d4ced9d20cebfb826174b6bb03386381f62b01e3d77" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" @@ -2089,18 +2182,23 @@ dependencies = [ "checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" "checksum lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef" "checksum libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "1e5d97d6708edaa407429faa671b942dc0f2727222fb6b6539bf1db936e4b121" +"checksum libloading 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fd38073de8f7965d0c17d30546d4bb6da311ab428d1c7a3fc71dff7f9d4979b9" "checksum libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" "checksum libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" "checksum libp2p-secio 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" "checksum libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" "checksum libp2p-tcp-transport 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" "checksum libp2p-websocket 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" -"checksum local-encoding 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1ceb20f39ff7ae42f3ff9795f3986b1daad821caaa1e1732a0944103a5a1a66" +"checksum librocksdb-sys 5.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24a1a39da9ee5980093768bf21e1f5872673eb1db4e91de719a64a0c237e8e92" +"checksum linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7860ec297f7008ff7a1e3382d7f7e1dcd69efc94751a2284bafc3d013c2aa939" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" +"checksum lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4d06ff7ff06f729ce5f4e227876cb88d10bc59cd4ae1e09fbb2bde15c850dc21" +"checksum make-cmd 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8ca8afbe8af1785e09636acb5a41e08a765f5f0340568716c18a8700ba3c0d3" "checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376" "checksum mdns-discover 0.2.0 (git+https://github.com/NervosFoundation/rust-mdns-discover)" = "" "checksum mdns-responder 0.2.0 (git+https://github.com/NervosFoundation/rust-mdns-responder)" = "" +"checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum memoffset 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e163e5baece1a039e71e75b074de17a9b4114982aa109921fc20253bdf91a53c" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" @@ -2118,6 +2216,7 @@ dependencies = [ "checksum nix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "47e49f6982987135c5e9620ab317623e723bd06738fd85377e8d55f57c8b6487" "checksum nix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2c5afeb0198ec7be8569d666644b574345aad2e95a53baf3a532da3e0f3fb32" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" +"checksum nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05aec50c70fd288702bcd93284a8444607f3292dbdf2a30de5ea5dcdbe72287b" "checksum num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e" "checksum num-bigint 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "81b483ea42927c463e191802e7334556b48e7875297564c0e9951bd3a0ae53e3" "checksum num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f8d26da319fb45674985c78f1d1caf99aa4941f785d384a2ae36d0740bc3e2fe" @@ -2133,15 +2232,16 @@ dependencies = [ "checksum parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "149d8f5b97f3c1133e3cfcd8886449959e856b557ff281e292b733d7c69e005e" "checksum parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9fd9d732f2de194336fb02fe11f9eed13d9e76f13f4315b4d88a14ca411750cd" "checksum parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "538ef00b7317875071d5e00f603f24d16f0b474c1a5fc0ccb8b454ca72eafa79" +"checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" "checksum protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bec26e67194b7d991908145fdf21b7cae8b08423d96dcb9e860cd31f854b9506" -"checksum pulldown-cmark 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8361e81576d2e02643b04950e487ec172b687180da65c731c03cf336784e6c07" +"checksum quasi 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18c45c4854d6d1cf5d531db97c75880feb91c958b0720f4ec1057135fec358b3" +"checksum quasi_codegen 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9e25fa23c044c1803f43ca59c98dac608976dd04ce799411edd58ece776d4" "checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" -"checksum rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b614fe08b6665cb9a231d07ac1364b0ef3cb3698f1239ee0c4c3a88a524f54c8" "checksum rayon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed02d09394c94ffbdfdc755ad62a132e94c3224a8354e78a1200ced34df12edf" "checksum rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d24ad214285a7729b174ed6d3bcfcb80177807f959d95fafd5bfc5c4f201ac8" "checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd" @@ -2150,8 +2250,7 @@ dependencies = [ "checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e" "checksum remove_dir_all 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b5d2f806b0fcdabd98acd380dc8daef485e22bcb7cddc811d1337967f2528cf5" "checksum ring 0.12.1 (git+https://github.com/briansmith/ring?rev=3a14ef619559f7d4b69e2286d49c833409eef34a)" = "" -"checksum rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)" = "" -"checksum rocksdb-sys 0.3.0 (git+https://github.com/paritytech/rust-rocksdb)" = "" +"checksum rocksdb 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41eb461abed4e4f2b3f9a852b38f9cb2ef25ae866a3e8fa827fbe4a7d8dc42c3" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" "checksum rustc-demangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11fb43a206a04116ffd7cfcf9bcb941f8eb6cc7ff667272246b0a1c74259a3cb" "checksum rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ceb8ce7a5e520de349e1fa172baeba4a9e8d5ef06c47471863530bc4972ee1e" @@ -2174,20 +2273,23 @@ dependencies = [ "checksum sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc30b1e1e8c40c121ca33b86c23308a090d19974ef001b4bf6e61fd1a0fb095c" "checksum sha1 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "171698ce4ec7cbb93babeb3190021b4d72e96ccb98e33d277ae4ea959d6f2d9e" "checksum sha2 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7daca11f2fdb8559c4f6c588386bed5e2ad4b6605c1442935a7f08144a918688" -"checksum skeptic 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24ebf8a06f5f8bae61ae5bbc7af7aac4ef6907ae975130faba1199e5fe82256a" "checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" "checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d" "checksum smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "872c0ff227000041c520cca51e883b858d388ab0ecf646bab76f065cebaec025" "checksum smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44db0ecb22921ef790d17ae13a3f6d15784183ff5f2a01aa32098c7498d2b4b9" -"checksum snappy-sys 0.1.0 (git+https://github.com/paritytech/rust-snappy)" = "" "checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b" "checksum stdweb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef5430c8e36b713e13b48a9f709cc21e046723fe44ce34587b73a830203b533e" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" +"checksum syntex 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a8f5e3aaa79319573d19938ea38d068056b826db9883a5d47f86c1cecc688f0e" +"checksum syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "867cc5c2d7140ae7eaad2ae9e8bf39cb18a67ca651b7834f88d46ca98faadb9c" +"checksum syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13ad4762fe52abc9f4008e85c4fb1b1fe3aa91ccb99ff4826a439c7c598e1047" +"checksum syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6e0e4dbae163dd98989464c23dd503161b338790640e11537686f2ef0f25c791" "checksum tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f73eebdb68c14bcb24aef74ea96079830e7fa7b31a6106e42ea7ee887c1e134e" "checksum tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11ce2fe9db64b842314052e2421ac61a73ce41b898dc8e3750398b219c5fc1e0" +"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" "checksum termcolor 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "56c456352e44f9f91f774ddeeed27c1ec60a2455ed66d692059acfb1d731bda1" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693" diff --git a/Cargo.toml b/Cargo.toml index 70e60ef1a4..d789a6e815 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,6 @@ ctrlc = { version = "3.1", features = ["termination"] } members = [ "util/logger", "util/hash", - "util/kvdb-rocksdb", "util/merkle-root", "util/crypto", "network", diff --git a/chain/src/chain.rs b/chain/src/chain.rs index 5fc61d9e5e..d479430fd9 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -3,9 +3,9 @@ use core::adapter::ChainAdapter; use core::block::{Block, Header}; use core::difficulty::calculate_difficulty; use core::global::{EPOCH_LEN, HEIGHT_SHIFT, MIN_DIFFICULTY, TIME_STEP}; +use db::store::ChainStore; use rand::{thread_rng, Rng}; use std::sync::Arc; -use store::ChainStore; use util::{Mutex, RwLock}; #[derive(Debug)] @@ -53,7 +53,7 @@ impl Chain { Ok(()) } - pub fn check_block(&self, h: &Header) -> Result<(), Error> { + fn check_block(&self, h: &Header) -> Result<(), Error> { if self.block_header(&h.hash()).is_some() { return Err(Error::Duplicate); } @@ -83,8 +83,7 @@ impl Chain { Ok(()) } - pub fn insert_block(&self, b: &Block) { - self.store.save_header(&b.header); + fn insert_block(&self, b: &Block) { self.store.save_block(b); let head_header = self.head_header(); @@ -101,7 +100,7 @@ impl Chain { } } - pub fn update_main_chain(&self, header: &Header) { + fn update_main_chain(&self, header: &Header) { self.store.save_block_hash(header.height, &header.hash()); let mut height = header.height - 1; let mut hash = header.pre_hash; @@ -120,7 +119,7 @@ impl Chain { self.print_chain(header.height, 10); } - pub fn save_head_header(&self, h: &Header) { + fn save_head_header(&self, h: &Header) { let mut head_header = self.head_header.write(); *head_header = h.clone(); self.store.save_head_header(h); @@ -139,11 +138,11 @@ impl Chain { } } - pub fn block_hash(&self, height: u64) -> Option { + fn block_hash(&self, height: u64) -> Option { self.store.get_block_hash(height) } - pub fn ancestor_hash(&self, height: u64, header: &Header) -> Option { + fn ancestor_hash(&self, height: u64, header: &Header) -> Option { if header.height < height { return None; } @@ -167,7 +166,7 @@ impl Chain { Some(current_hash) } - pub fn ancestor_header(&self, height: u64, header: &Header) -> Option
{ + fn ancestor_header(&self, height: u64, header: &Header) -> Option
{ self.ancestor_hash(height, header) .and_then(|v| self.block_header(&v)) } @@ -196,7 +195,7 @@ impl Chain { calculate_difficulty(pre_header, current_time) } - pub fn print_chain(&self, tip: u64, len: u64) { + fn print_chain(&self, tip: u64, len: u64) { info!(target: "chain", "Chain {{"); let limit = if tip > len { len } else { tip } + 1; diff --git a/chain/src/lib.rs b/chain/src/lib.rs index 02e28a6335..bf521faa8f 100644 --- a/chain/src/lib.rs +++ b/chain/src/lib.rs @@ -7,9 +7,6 @@ extern crate nervos_db as db; extern crate nervos_util as util; extern crate rand; extern crate serde; -#[macro_use] -extern crate serde_derive; pub mod chain; pub mod genesis; -pub mod store; diff --git a/chain/src/store.rs b/chain/src/store.rs deleted file mode 100644 index 79bd71f62a..0000000000 --- a/chain/src/store.rs +++ /dev/null @@ -1,87 +0,0 @@ -use bigint::H256; -use core::block::{Block, Header}; -use db::kvdb::KeyValueDB; - -#[derive(Serialize, Deserialize, PartialEq, Debug)] -pub enum Key { - BlockHash(u64), - BlockHeader(H256), - Block(H256), - Transaction(H256), - HeadHeader, -} - -pub trait ChainStore: Sync + Send { - fn get_block(&self, h: &H256) -> Option; - fn save_block(&self, b: &Block); - fn get_header(&self, h: &H256) -> Option
; - fn save_header(&self, h: &Header); - fn get_block_hash(&self, height: u64) -> Option; - fn save_block_hash(&self, height: u64, hash: &H256); - fn head_header(&self) -> Option
; - fn save_head_header(&self, h: &Header); - fn init(&self, genesis: &Block) -> (); -} - -pub struct ChainKVStore { - pub db: Box, -} - -impl ChainStore for ChainKVStore { - // TODO error log - fn get_block(&self, h: &H256) -> Option { - self.db.read(&Key::Block(*h)).ok().unwrap() - } - - fn save_block(&self, b: &Block) { - self.db.write(&Key::Block(b.hash()), b).unwrap(); - } - - fn get_header(&self, h: &H256) -> Option
{ - self.db.read(&Key::BlockHeader(*h)).ok().unwrap() - } - - fn save_header(&self, h: &Header) { - self.db.write(&Key::BlockHeader(h.hash()), h).unwrap(); - } - - fn save_block_hash(&self, height: u64, hash: &H256) { - self.db.write(&Key::BlockHash(height), hash).unwrap(); - } - - fn get_block_hash(&self, height: u64) -> Option { - self.db.read(&Key::BlockHash(height)).unwrap() - } - - fn head_header(&self) -> Option
{ - self.db.read(&Key::HeadHeader).ok().unwrap() - } - - fn save_head_header(&self, h: &Header) { - self.db.write(&Key::HeadHeader, h).unwrap(); - } - - fn init(&self, genesis: &Block) { - self.save_block(genesis); - self.save_header(&genesis.header); - self.save_head_header(&genesis.header); - self.save_block_hash(genesis.header.height, &genesis.hash()); - } -} - -#[cfg(test)] -mod tests { - use super::*; - use db::kvdb::MemoryKeyValueDB; - use genesis::genesis_dev; - - #[test] - fn save_and_get_block() { - let db = MemoryKeyValueDB::default(); - let store = ChainKVStore { db: Box::new(db) }; - let block = genesis_dev(); - let hash = block.hash(); - store.save_block(&block); - assert_eq!(block, store.get_block(&hash).unwrap()); - } -} diff --git a/core/Cargo.toml b/core/Cargo.toml index 587383a1df..77155bb6b9 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -10,8 +10,6 @@ bincode = "1.0" bigint = { path = "../util/bigint" } bls = { git = "https://github.com/NervosFoundation/bls-rs.git" } hash = {path = "../util/hash"} -kvdb = {path = "../util/kvdb"} crypto = {path = "../util/crypto"} merkle-root = {path = "../util/merkle-root"} -kvdb-rocksdb = { path = "../util/kvdb-rocksdb" } nervos-time = { path = "../util/time" } diff --git a/db/Cargo.toml b/db/Cargo.toml index 31eb730bfc..88c106ac2b 100644 --- a/db/Cargo.toml +++ b/db/Cargo.toml @@ -7,6 +7,11 @@ authors = ["Nervos Core Dev "] serde = "1.0" bincode = "1.0" nervos-util = { path = "../util" } +nervos-core = { path = "../core" } +bigint = { path = "../util/bigint" } +serde_derive = "1.0" +rocksdb = "0.9.1" +lru-cache = "0.1.1" [dev-dependencies] -serde_derive = "1.0" +tempdir = "0.3" diff --git a/db/src/batch.rs b/db/src/batch.rs new file mode 100644 index 0000000000..17a73af26c --- /dev/null +++ b/db/src/batch.rs @@ -0,0 +1,62 @@ +use bigint::H256; +use core::{block, transaction}; + +#[derive(Debug)] +pub enum Operation { + Insert(KeyValue), + Delete(Key), +} + +#[derive(Debug)] +pub enum KeyValue { + BlockHash(u64, H256), + BlockHeader(H256, Box), + BlockTransactions(H256, Vec), + Meta(&'static str, Vec), + Transaction(H256, Box), +} + +#[derive(Debug, PartialEq)] +pub enum Key { + BlockHash(u64), + BlockHeader(H256), + BlockTransactions(H256), + Meta(&'static str), + Transaction(H256), +} + +#[derive(Debug, PartialEq)] +pub enum Value { + BlockHash(H256), + BlockHeader(Box), + BlockTransactions(Vec), + Meta(Vec), + Transaction(Box), +} + +#[derive(Debug)] +pub struct Batch { + pub operations: Vec, +} + +impl Default for Batch { + fn default() -> Self { + Batch { + operations: Vec::with_capacity(32), + } + } +} + +impl Batch { + pub fn new() -> Self { + Batch::default() + } + + pub fn insert(&mut self, insert: KeyValue) { + self.operations.push(Operation::Insert(insert)); + } + + pub fn delete(&mut self, delete: Key) { + self.operations.push(Operation::Delete(delete)); + } +} diff --git a/db/src/cachedb.rs b/db/src/cachedb.rs new file mode 100644 index 0000000000..244705783e --- /dev/null +++ b/db/src/cachedb.rs @@ -0,0 +1,128 @@ +use batch::{Batch, Key, KeyValue, Operation, Value}; +use bigint::H256; +use core::block::Header; +use kvdb::{KeyValueDB, Result}; +use lru_cache::LruCache; +use util::Mutex; + +pub struct CacheKeyValueDB +where + T: KeyValueDB, +{ + db: T, + block_header: Mutex>, + block_hash: Mutex>, +} + +impl CacheKeyValueDB +where + T: KeyValueDB, +{ + pub fn new(db: T) -> Self { + CacheKeyValueDB { + db, + block_header: Mutex::new(LruCache::new(4096)), + block_hash: Mutex::new(LruCache::new(4096)), + } + } +} + +impl KeyValueDB for CacheKeyValueDB +where + T: KeyValueDB, +{ + fn write(&self, batch: Batch) -> Result<()> { + for op in &batch.operations { + match *op { + Operation::Insert(KeyValue::BlockHeader(hash, ref header)) => { + self.block_header.lock().insert(hash, *header.clone()); + } + Operation::Insert(KeyValue::BlockHash(height, hash)) => { + self.block_hash.lock().insert(height, hash); + } + Operation::Delete(Key::BlockHeader(hash)) => { + self.block_header.lock().remove(&hash); + } + Operation::Delete(Key::BlockHash(height)) => { + self.block_hash.lock().remove(&height); + } + _ => (), + } + } + self.db.write(batch) + } + + fn read(&self, key: &Key) -> Result> { + match *key { + Key::BlockHeader(hash) => if let Some(header) = self.block_header.lock().get_mut(&hash) + { + return Ok(Some(Value::BlockHeader(Box::new(header.clone())))); + }, + Key::BlockHash(height) => if let Some(hash) = self.block_hash.lock().get_mut(&height) { + return Ok(Some(Value::BlockHash(*hash))); + }, + _ => return self.db.read(key), + } + self.db.read(key) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use bigint::{H520, U256}; + use core::block::RawHeader; + use core::proof::Proof; + + struct DummyDB {} + + impl KeyValueDB for DummyDB { + fn write(&self, _batch: Batch) -> Result<()> { + Ok(()) + } + + fn read(&self, _key: &Key) -> Result> { + Ok(None) + } + } + + #[test] + fn write_and_read() { + let db = CacheKeyValueDB::new(DummyDB {}); + + let header = Header::new( + RawHeader { + pre_hash: H256::from(0), + timestamp: 0, + transactions_root: H256::from(0), + difficulty: U256::from(0), + challenge: H256::from(0), + proof: Proof::default(), + height: 0, + }, + U256::from(0), + Some(H520::from(0)), + ); + + let mut batch = Batch::default(); + batch.insert(KeyValue::BlockHeader( + header.hash(), + Box::new(header.clone()), + )); + db.write(batch).expect("db operation should be fine"); + + assert_eq!( + Value::BlockHeader(Box::new(header.clone())), + db.read(&Key::BlockHeader(header.hash())).unwrap().unwrap() + ); + + let mut batch = Batch::default(); + batch.insert(KeyValue::BlockHash(1, H256::from(1))); + db.write(batch).expect("db operation should be fine"); + + assert_eq!( + Value::BlockHash(H256::from(1)), + db.read(&Key::BlockHash(1)).unwrap().unwrap() + ); + } +} diff --git a/db/src/diskdb.rs b/db/src/diskdb.rs new file mode 100644 index 0000000000..1a92cc8977 --- /dev/null +++ b/db/src/diskdb.rs @@ -0,0 +1,174 @@ +use batch::{Batch, Key, KeyValue, Operation, Value}; +use bincode::{deserialize, serialize}; +use kvdb::{KeyValueDB, Result}; +use rocksdb::{Options, WriteBatch, DB}; +use std::path::Path; + +const COLUMN_FAMILIES: &[&str] = &[ + "block_hash", + "block_header", + "block_transactions", + "meta", + "transaction", +]; + +pub struct RocksKeyValueDB { + db: DB, +} + +impl RocksKeyValueDB { + pub fn open>(path: P) -> Self { + let mut opts = Options::default(); + opts.create_if_missing(true); + opts.create_missing_column_families(true); + + let db = DB::open_cf(&opts, path, COLUMN_FAMILIES).unwrap(); + + RocksKeyValueDB { db } + } +} + +impl KeyValueDB for RocksKeyValueDB { + fn write(&self, batch: Batch) -> Result<()> { + let mut wb = WriteBatch::default(); + for op in batch.operations { + match op { + Operation::Insert(insert) => match insert { + KeyValue::BlockHash(key, value) => { + wb.put_cf( + self.db.cf_handle(COLUMN_FAMILIES[0]).unwrap(), + &serialize(&key).unwrap().to_vec(), + &serialize(&value).unwrap().to_vec(), + )?; + } + KeyValue::BlockHeader(key, value) => { + wb.put_cf( + self.db.cf_handle(COLUMN_FAMILIES[1]).unwrap(), + &serialize(&key).unwrap().to_vec(), + &serialize(&value).unwrap().to_vec(), + )?; + } + KeyValue::BlockTransactions(key, value) => { + wb.put_cf( + self.db.cf_handle(COLUMN_FAMILIES[2]).unwrap(), + &serialize(&key).unwrap().to_vec(), + &serialize(&value).unwrap().to_vec(), + )?; + } + KeyValue::Meta(key, value) => { + wb.put_cf( + self.db.cf_handle(COLUMN_FAMILIES[3]).unwrap(), + &serialize(&key).unwrap().to_vec(), + &value, + )?; + } + KeyValue::Transaction(key, value) => { + wb.put_cf( + self.db.cf_handle(COLUMN_FAMILIES[4]).unwrap(), + &serialize(&key).unwrap().to_vec(), + &serialize(&value).unwrap().to_vec(), + )?; + } + }, + Operation::Delete(delete) => match delete { + Key::BlockHash(key) => { + wb.delete_cf( + self.db.cf_handle(COLUMN_FAMILIES[0]).unwrap(), + &serialize(&key).unwrap().to_vec(), + )?; + } + Key::BlockHeader(key) => { + wb.delete_cf( + self.db.cf_handle(COLUMN_FAMILIES[1]).unwrap(), + &serialize(&key).unwrap().to_vec(), + )?; + } + Key::BlockTransactions(key) => { + wb.delete_cf( + self.db.cf_handle(COLUMN_FAMILIES[2]).unwrap(), + &serialize(&key).unwrap().to_vec(), + )?; + } + Key::Meta(key) => { + wb.delete_cf( + self.db.cf_handle(COLUMN_FAMILIES[3]).unwrap(), + &serialize(&key).unwrap().to_vec(), + )?; + } + Key::Transaction(key) => { + wb.delete_cf( + self.db.cf_handle(COLUMN_FAMILIES[4]).unwrap(), + &serialize(&key).unwrap().to_vec(), + )?; + } + }, + } + } + self.db.write(wb).map_err(|err| err.into()) + } + + fn read(&self, key: &Key) -> Result> { + let result = match *key { + Key::BlockHash(ref key) => self.db + .get_cf( + self.db.cf_handle(COLUMN_FAMILIES[0]).unwrap(), + &serialize(&key).unwrap().to_vec(), + ) + .map(|v| v.and_then(|ref v| Some(Value::BlockHash(deserialize(v).unwrap())))), + Key::BlockHeader(ref key) => self.db + .get_cf( + self.db.cf_handle(COLUMN_FAMILIES[1]).unwrap(), + &serialize(&key).unwrap().to_vec(), + ) + .map(|v| v.and_then(|ref v| Some(Value::BlockHeader(deserialize(v).unwrap())))), + Key::BlockTransactions(ref key) => self.db + .get_cf( + self.db.cf_handle(COLUMN_FAMILIES[2]).unwrap(), + &serialize(&key).unwrap().to_vec(), + ) + .map(|v| { + v.and_then(|ref v| Some(Value::BlockTransactions(deserialize(v).unwrap()))) + }), + Key::Meta(key) => self.db + .get_cf( + self.db.cf_handle(COLUMN_FAMILIES[3]).unwrap(), + &serialize(&key).unwrap().to_vec(), + ) + .map(|v| v.and_then(|v| Some(Value::Meta(v.to_vec())))), + Key::Transaction(ref key) => self.db + .get_cf( + self.db.cf_handle(COLUMN_FAMILIES[4]).unwrap(), + &serialize(&key).unwrap().to_vec(), + ) + .map(|v| v.and_then(|ref v| Some(Value::Transaction(deserialize(v).unwrap())))), + }; + result.map_err(|e| e.into()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use tempdir::TempDir; + + #[test] + fn save_and_get_meta() { + let dir = TempDir::new("_nervos_test_db").unwrap(); + let db = RocksKeyValueDB::open(dir); + let mut batch = Batch::default(); + batch.insert(KeyValue::Meta("abc", [0, 1, 2].to_vec())); + db.write(batch).unwrap(); + + assert_eq!( + db.read(&Key::Meta("abc")).unwrap().unwrap(), + Value::Meta([0, 1, 2].to_vec()) + ); + } + + #[test] + fn get_empty() { + let dir = TempDir::new("_nervos_test_db").unwrap(); + let db = RocksKeyValueDB::open(dir); + assert_eq!(db.read(&Key::BlockHash(0)).unwrap(), None); + } +} diff --git a/db/src/kvdb.rs b/db/src/kvdb.rs index b0403592a9..381f5cf00d 100644 --- a/db/src/kvdb.rs +++ b/db/src/kvdb.rs @@ -1,14 +1,11 @@ -use bincode::{deserialize, serialize}; +use batch::{Batch, Key, Value}; use bincode::Error as BcError; -use serde::de::DeserializeOwned; -use serde::ser::Serialize; -use std::collections::HashMap; +use rocksdb::Error as RdbError; use std::error::Error as StdError; use std::result; -use util::RwLock; type Error = Box; -type Result = result::Result; +pub type Result = result::Result; #[derive(Debug)] pub enum ErrorKind { @@ -22,74 +19,13 @@ impl From for Error { } } -pub trait KeyValueDB: Sync + Send { - fn put(&self, key: &[u8], value: &[u8]) -> Result<()>; - fn get(&self, key: &[u8]) -> Result>>; - - fn write(&self, key: &K, value: &T) -> Result<()> { - let k = serialize(key)?; - let v = serialize(value)?; - self.put(&k, &v) - } - - fn read(&self, key: &K) -> Result> - where - T: DeserializeOwned, - { - let k = serialize(key)?; - match self.get(&k) { - Ok(Some(ref value)) => Ok(Some(deserialize(value)?)), - Ok(None) => Ok(None), - Err(err) => Err(err), - } +impl From for Error { + fn from(err: RdbError) -> Error { + Box::new(ErrorKind::DBError(err.into())) } } -#[derive(Default)] -pub struct MemoryKeyValueDB { - hashmap: RwLock, Vec>>, -} - -impl KeyValueDB for MemoryKeyValueDB { - fn put(&self, key: &[u8], value: &[u8]) -> Result<()> { - let mut hashmap = self.hashmap.write(); - hashmap.insert(key.to_vec(), value.to_vec()); - Ok(()) - } - - fn get(&self, key: &[u8]) -> Result>> { - let hashmap = self.hashmap.read(); - if let Some(result) = hashmap.get(key) { - Ok(Some(result.to_vec())) - } else { - Ok(None) - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[derive(Debug, PartialEq, Serialize, Deserialize)] - struct Foo(u32); - - #[test] - fn put_and_get() { - let db = MemoryKeyValueDB::default(); - let key = &[0, 1, 2]; - let value = &[3, 4, 5]; - assert!(db.put(key, value).is_ok()); - assert_eq!(vec![3, 4, 5], db.get(key).unwrap().unwrap()); - } - - #[test] - fn write_and_read() { - let db = MemoryKeyValueDB::default(); - let key = &[0, 1, 2]; - let value = &Foo(345); - assert!(db.write(key, value).is_ok()); - println!("db get {:?}", db.get(key)); - assert_eq!(Foo(345), db.read(key).unwrap().unwrap()); - } +pub trait KeyValueDB: Sync + Send { + fn write(&self, batch: Batch) -> Result<()>; + fn read(&self, key: &Key) -> Result>; } diff --git a/db/src/lib.rs b/db/src/lib.rs index e2452714d7..ba974d7681 100644 --- a/db/src/lib.rs +++ b/db/src/lib.rs @@ -1,9 +1,17 @@ +extern crate bigint; extern crate bincode; +extern crate lru_cache; +extern crate nervos_core as core; extern crate nervos_util as util; +extern crate rocksdb; extern crate serde; +pub mod batch; +pub mod cachedb; +pub mod diskdb; pub mod kvdb; +pub mod memorydb; +pub mod store; #[cfg(test)] -#[macro_use] -extern crate serde_derive; +extern crate tempdir; diff --git a/db/src/memorydb.rs b/db/src/memorydb.rs new file mode 100644 index 0000000000..59b4838182 --- /dev/null +++ b/db/src/memorydb.rs @@ -0,0 +1,84 @@ +use batch::{Batch, Key, KeyValue, Operation, Value}; +use bigint::H256; +use core::block::Header; +use core::transaction::Transaction; +use kvdb::{KeyValueDB, Result}; +use std::collections::HashMap; +use util::RwLock; + +#[derive(Default, Debug)] +struct Inner { + meta: HashMap<&'static str, Vec>, + block_hash: HashMap, + block_header: HashMap>, + block_transactions: HashMap>, + transaction: HashMap>, +} + +#[derive(Default, Debug)] +pub struct MemoryKeyValueDB { + db: RwLock, +} + +impl KeyValueDB for MemoryKeyValueDB { + fn write(&self, batch: Batch) -> Result<()> { + let mut db = self.db.write(); + batch.operations.into_iter().for_each(|op| match op { + Operation::Insert(insert) => match insert { + KeyValue::BlockHash(key, value) => { + db.block_hash.insert(key, value); + } + KeyValue::BlockHeader(key, value) => { + db.block_header.insert(key, value); + } + KeyValue::BlockTransactions(key, value) => { + db.block_transactions.insert(key, value); + } + KeyValue::Meta(key, value) => { + db.meta.insert(key, value); + } + KeyValue::Transaction(key, value) => { + db.transaction.insert(key, value); + } + }, + Operation::Delete(delete) => match delete { + Key::BlockHash(key) => { + db.block_hash.remove(&key); + } + Key::BlockHeader(key) => { + db.block_header.remove(&key); + } + Key::BlockTransactions(key) => { + db.block_transactions.remove(&key); + } + Key::Meta(key) => { + db.meta.remove(&key); + } + Key::Transaction(key) => { + db.transaction.remove(&key); + } + }, + }); + Ok(()) + } + + fn read(&self, key: &Key) -> Result> { + let db = self.db.read(); + let result = match *key { + Key::BlockHash(ref key) => db.block_hash + .get(key) + .and_then(|v| Some(Value::BlockHash(*v))), + Key::BlockHeader(ref key) => db.block_header + .get(key) + .and_then(|v| Some(Value::BlockHeader(v.clone()))), + Key::BlockTransactions(ref key) => db.block_transactions + .get(key) + .and_then(|v| Some(Value::BlockTransactions(v.clone()))), + Key::Meta(key) => db.meta.get(key).and_then(|v| Some(Value::Meta(v.clone()))), + Key::Transaction(ref key) => db.transaction + .get(key) + .and_then(|v| Some(Value::Transaction(v.clone()))), + }; + Ok(result) + } +} diff --git a/db/src/store.rs b/db/src/store.rs new file mode 100644 index 0000000000..a77758c6b6 --- /dev/null +++ b/db/src/store.rs @@ -0,0 +1,146 @@ +use batch::{Batch, Key, KeyValue, Value}; +use bigint::H256; +use core::block::{Block, Header}; +use core::transaction::Transaction; +use kvdb::KeyValueDB; + +const META_HEAD_HEADER_KEY: &str = "HEAD_HEADER"; + +pub trait ChainStore: Sync + Send { + fn get_block(&self, h: &H256) -> Option; + fn get_header(&self, h: &H256) -> Option
; + fn get_block_hash(&self, height: u64) -> Option; + fn get_block_transactions(&self, h: &H256) -> Option>; + fn get_transaction(&self, h: &H256) -> Option; + fn save_block(&self, b: &Block); + fn save_block_hash(&self, height: u64, hash: &H256); + fn head_header(&self) -> Option
; + fn save_head_header(&self, h: &Header); + fn init(&self, genesis: &Block) -> (); +} + +pub struct ChainKVStore { + pub db: Box, +} + +impl ChainKVStore { + fn get(&self, key: &Key) -> Option { + self.db.read(key).expect("db operation should be ok") + } + + fn put(&self, batch: Batch) { + self.db.write(batch).expect("db operation should be ok") + } +} + +impl ChainStore for ChainKVStore { + // TODO error log + fn get_block(&self, h: &H256) -> Option { + self.get_header(h).and_then(|header| { + let transactions = self.get_block_transactions(h).unwrap(); + Some(Block { + header, + transactions, + }) + }) + } + + fn save_block(&self, b: &Block) { + let mut batch = Batch::default(); + batch.insert(KeyValue::BlockHeader(b.hash(), Box::new(b.header.clone()))); + batch.insert(KeyValue::BlockTransactions( + b.hash(), + b.transactions.iter().map(|tx| tx.hash()).collect(), + )); + self.put(batch); + } + + fn get_header(&self, h: &H256) -> Option
{ + self.get(&Key::BlockHeader(*h)).and_then(|v| match v { + Value::BlockHeader(h) => Some(*h), + _ => None, + }) + } + + fn get_block_transactions(&self, h: &H256) -> Option> { + self.get(&Key::BlockTransactions(*h)).and_then(|v| match v { + Value::BlockTransactions(hashes) => { + hashes.iter().map(|h| self.get_transaction(h)).collect() + } + _ => None, + }) + } + + fn get_transaction(&self, h: &H256) -> Option { + self.get(&Key::Transaction(*h)).and_then(|v| match v { + Value::Transaction(t) => Some(*t), + _ => None, + }) + } + + fn save_block_hash(&self, height: u64, hash: &H256) { + let mut batch = Batch::default(); + batch.insert(KeyValue::BlockHash(height, *hash)); + self.put(batch); + } + + fn get_block_hash(&self, height: u64) -> Option { + self.get(&Key::BlockHash(height)).and_then(|v| match v { + Value::BlockHash(h) => Some(h), + _ => None, + }) + } + + fn head_header(&self) -> Option
{ + self.get(&Key::Meta(META_HEAD_HEADER_KEY)) + .and_then(|v| match v { + Value::Meta(data) => self.get_header(&H256::from(&data[..])), + _ => None, + }) + } + + fn save_head_header(&self, h: &Header) { + let mut batch = Batch::default(); + batch.insert(KeyValue::Meta(META_HEAD_HEADER_KEY, h.hash().to_vec())); + self.put(batch); + } + + fn init(&self, genesis: &Block) { + self.save_block(genesis); + self.save_head_header(&genesis.header); + self.save_block_hash(genesis.header.height, &genesis.hash()); + } +} + +#[cfg(test)] +mod tests { + use super::*; + use bigint::{H256, H520, U256}; + use core::block::{Block, Header, RawHeader}; + use core::proof::Proof; + use memorydb::MemoryKeyValueDB; + + #[test] + fn save_and_get_block() { + let db = MemoryKeyValueDB::default(); + let store = ChainKVStore { db: Box::new(db) }; + let raw_header = RawHeader { + pre_hash: H256::from(0), + timestamp: 0, + transactions_root: H256::from(0), + difficulty: U256::from(0), + challenge: H256::from(0), + proof: Proof::default(), + height: 0, + }; + + let block = Block { + header: Header::new(raw_header, U256::from(0), Some(H520::from(0))), + transactions: vec![], + }; + + let hash = block.hash(); + store.save_block(&block); + assert_eq!(block, store.get_block(&hash).unwrap()); + } +} diff --git a/default.toml b/default.toml index 5470b16c7a..63230848f3 100644 --- a/default.toml +++ b/default.toml @@ -1,5 +1,6 @@ miner_private_key = "0x1162b2f150c789aed32e2e0b3081dd6852926865" signer_private_key = "0x097c1a2d03b6c8fc270991051553219e34951b656382ca951c4c226d40a3b2d5" +db_path = ".nervos/db" [logger] file = "/tmp/nervos0.log" filter = "main=info,miner=info,chain=info" diff --git a/miner/Cargo.toml b/miner/Cargo.toml index 70e45a22b6..bd06360b98 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -10,3 +10,4 @@ nervos-time = { path = "../util/time" } nervos-core = { path = "../core" } nervos-pool = { path = "../pool" } nervos-chain = { path = "../chain" } +nervos-db = { path = "../db" } diff --git a/miner/src/lib.rs b/miner/src/lib.rs index fee0b0b5f6..a92da351c1 100644 --- a/miner/src/lib.rs +++ b/miner/src/lib.rs @@ -3,6 +3,7 @@ extern crate bigint; extern crate log; extern crate nervos_chain as chain; extern crate nervos_core as core; +extern crate nervos_db as db; extern crate nervos_pool as pool; extern crate nervos_time as time; diff --git a/miner/src/miner.rs b/miner/src/miner.rs index 22fdebbc21..a7c11360cb 100644 --- a/miner/src/miner.rs +++ b/miner/src/miner.rs @@ -1,10 +1,10 @@ use bigint::{H160, H256}; use chain::chain::Chain; -use chain::store::ChainStore; use core::adapter::ChainAdapter; use core::block::Block; use core::global::{MAX_TX, TIME_STEP}; use core::proof::Proof; +use db::store::ChainStore; use pool::TransactionPool; use std::sync::Arc; use std::thread; diff --git a/src/adapter.rs b/src/adapter.rs index 60830b3442..17f618d2b6 100644 --- a/src/adapter.rs +++ b/src/adapter.rs @@ -1,11 +1,12 @@ use chain::chain::Chain; -use chain::store::ChainKVStore; use core::adapter::{ChainAdapter, NetAdapter}; use core::block::Block; use core::global::TIME_STEP; use core::keygroup::KeyGroup; use core::transaction::Transaction; -use db::kvdb::MemoryKeyValueDB; +use db::cachedb::CacheKeyValueDB; +use db::diskdb::RocksKeyValueDB; +use db::store::ChainKVStore; use network::Network; use pool::{OrphanBlockPool, PendingBlockPool, TransactionPool}; use std::sync::Arc; @@ -15,7 +16,7 @@ use time::{now_ms, Duration}; use util::RwLock; type NetworkImpl = Network; -type ChainImpl = Chain>; +type ChainImpl = Chain>>; type NetworkWeakRef = RwLock>>; fn upgrade_chain(chain: &Weak) -> Arc { diff --git a/src/cli/run_impl.rs b/src/cli/run_impl.rs index 2a011743fd..30c7bbd8a8 100644 --- a/src/cli/run_impl.rs +++ b/src/cli/run_impl.rs @@ -2,14 +2,16 @@ use adapter::{ChainToNetAndPoolAdapter, NetToChainAndPoolAdapter}; use bigint; use chain; use chain::chain::Chain; -use chain::store::ChainKVStore; use config::Config; use ctrlc; -use db::kvdb::MemoryKeyValueDB; +use db::cachedb::CacheKeyValueDB; +use db::diskdb::RocksKeyValueDB; +use db::store::ChainKVStore; use logger; use miner::miner::Miner; use network::Network; use pool::TransactionPool; +use std::path::Path; use std::sync::Arc; use std::thread; use util::{Condvar, Mutex}; @@ -21,7 +23,7 @@ pub fn run(config_path: &str) { info!(target: "main", "Value for config: {:?}", config); - let db = MemoryKeyValueDB::default(); + let db = CacheKeyValueDB::new(RocksKeyValueDB::open(Path::new(&config.db_path))); let store = ChainKVStore { db: Box::new(db) }; let tx_pool = Arc::new(TransactionPool::default()); diff --git a/src/config.rs b/src/config.rs index 9ba9b8fa14..be3fdb943c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -15,6 +15,7 @@ pub struct Config { pub signer_private_key: H256, pub key_pairs: Vec, pub network: NetworkConfig, + pub db_path: String, } #[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)] @@ -56,6 +57,7 @@ mod tests { let config: Config = toml::from_str(r#" miner_private_key = "0x1162b2f150c789aed32e2e0b3081dd6852926865" signer_private_key = "0x097c1a2d03b6c8fc270991051553219e34951b656382ca951c4c226d40a3b2d5" + db_path = ".nervos/db" [logger] file = "/tmp/nervos.log" filter = "main=info,miner=info,chain=info" diff --git a/util/kvdb-rocksdb/Cargo.toml b/util/kvdb-rocksdb/Cargo.toml deleted file mode 100644 index 85dbc27669..0000000000 --- a/util/kvdb-rocksdb/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "kvdb-rocksdb" -version = "0.1.0" -authors = ["Parity Technologies "] - -[dependencies] -elastic-array = "0.9" -bigint = { path = "../bigint" } -kvdb = { path = "../kvdb" } -log = "0.4" -num_cpus = "1.0" -parking_lot = "0.5" -regex = "0.2" -rocksdb = { git = "https://github.com/paritytech/rust-rocksdb" } -interleaved-ordered = "0.1.0" - -[dev-dependencies] -tempdir = "0.3" diff --git a/util/kvdb-rocksdb/src/lib.rs b/util/kvdb-rocksdb/src/lib.rs deleted file mode 100644 index 69661cbb5f..0000000000 --- a/util/kvdb-rocksdb/src/lib.rs +++ /dev/null @@ -1,923 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -#[macro_use] -extern crate log; - -extern crate elastic_array; -extern crate interleaved_ordered; -extern crate num_cpus; -extern crate parking_lot; -extern crate regex; -extern crate rocksdb; - -extern crate bigint; -extern crate kvdb; - -use std::{fs, io, mem, result}; -use std::cmp; -use std::collections::HashMap; -use std::marker::PhantomData; -use std::path::{Path, PathBuf}; - -use interleaved_ordered::{interleave_ordered, InterleaveOrdered}; -use parking_lot::{Mutex, MutexGuard, RwLock}; -use rocksdb::{BlockBasedOptions, Cache, Column, DBIterator, Direction, IteratorMode, Options, - ReadOptions, Writable, WriteBatch, WriteOptions, DB}; - -use elastic_array::ElasticArray32; -use kvdb::{DBOp, DBTransaction, DBValue, KeyValueDB, Result}; - -#[cfg(target_os = "linux")] -use regex::Regex; -#[cfg(target_os = "linux")] -use std::fs::File; -#[cfg(target_os = "linux")] -use std::process::Command; - -const DB_DEFAULT_MEMORY_BUDGET_MB: usize = 128; - -enum KeyState { - Insert(DBValue), - Delete, -} - -/// Compaction profile for the database settings -#[derive(Clone, Copy, PartialEq, Debug)] -pub struct CompactionProfile { - /// L0-L1 target file size - pub initial_file_size: u64, - /// block size - pub block_size: usize, - /// rate limiter for background flushes and compactions, bytes/sec, if any - pub write_rate_limit: Option, -} - -impl Default for CompactionProfile { - /// Default profile suitable for most storage - fn default() -> CompactionProfile { - CompactionProfile::ssd() - } -} - -/// Given output of df command return Linux rotational flag file path. -#[cfg(target_os = "linux")] -pub fn rotational_from_df_output(df_out: &[u8]) -> Option { - use std::str; - str::from_utf8(df_out) - .ok() - // Get the drive name. - .and_then(|df_str| Regex::new(r"/dev/(sd[:alpha:]{1,2})") - .ok() - .and_then(|re| re.captures(df_str)) - .and_then(|captures| captures.get(1))) - // Generate path e.g. /sys/block/sda/queue/rotational - .map(|drive_path| { - let mut p = PathBuf::from("/sys/block"); - p.push(drive_path.as_str()); - p.push("queue/rotational"); - p - }) -} - -impl CompactionProfile { - /// Attempt to determine the best profile automatically, only Linux for now. - #[cfg(target_os = "linux")] - pub fn auto(db_path: &Path) -> CompactionProfile { - use std::io::Read; - let hdd_check_file = db_path - .to_str() - .and_then(|path_str| Command::new("df").arg(path_str).output().ok()) - .and_then(|df_res| { - if df_res.status.success() { - Some(df_res.stdout) - } else { - None - } - }) - .and_then(|df| rotational_from_df_output(&df)); - // Read out the file and match compaction profile. - if let Some(hdd_check) = hdd_check_file { - if let Ok(mut file) = File::open(hdd_check.as_path()) { - let mut buffer = [0; 1]; - if file.read_exact(&mut buffer).is_ok() { - // 0 means not rotational. - if buffer == [48] { - return Self::ssd(); - } - // 1 means rotational. - if buffer == [49] { - return Self::hdd(); - } - } - } - } - // Fallback if drive type was not determined. - Self::default() - } - - /// Just default for other platforms. - #[cfg(not(target_os = "linux"))] - pub fn auto(_db_path: &Path) -> CompactionProfile { - Self::default() - } - - /// Default profile suitable for SSD storage - pub fn ssd() -> CompactionProfile { - CompactionProfile { - initial_file_size: 64 * 1024 * 1024, - block_size: 16 * 1024, - write_rate_limit: None, - } - } - - /// Slow HDD compaction profile - pub fn hdd() -> CompactionProfile { - CompactionProfile { - initial_file_size: 256 * 1024 * 1024, - block_size: 64 * 1024, - write_rate_limit: Some(16 * 1024 * 1024), - } - } -} - -/// Database configuration -#[derive(Clone)] -pub struct DatabaseConfig { - /// Max number of open files. - pub max_open_files: i32, - /// Memory budget (in MiB) used for setting block cache size, write buffer size. - pub memory_budget: Option, - /// Compaction profile - pub compaction: CompactionProfile, - /// Set number of columns - pub columns: Option, - /// Should we keep WAL enabled? - pub wal: bool, -} - -impl DatabaseConfig { - /// Create new `DatabaseConfig` with default parameters and specified set of columns. - /// Note that cache sizes must be explicitly set. - pub fn with_columns(columns: Option) -> Self { - let mut config = Self::default(); - config.columns = columns; - config - } - - pub fn memory_budget(&self) -> usize { - self.memory_budget.unwrap_or(DB_DEFAULT_MEMORY_BUDGET_MB) * 1024 * 1024 - } - - pub fn memory_budget_per_col(&self) -> usize { - self.memory_budget() / self.columns.unwrap_or(1) as usize - } -} - -impl Default for DatabaseConfig { - fn default() -> DatabaseConfig { - DatabaseConfig { - max_open_files: 512, - memory_budget: None, - compaction: CompactionProfile::default(), - columns: None, - wal: true, - } - } -} - -/// Database iterator (for flushed data only) -// The compromise of holding only a virtual borrow vs. holding a lock on the -// inner DB (to prevent closing via restoration) may be re-evaluated in the future. -// -type DBItem = (Box<[u8]>, Box<[u8]>); - -pub struct DatabaseIterator<'a> { - iter: InterleaveOrdered<::std::vec::IntoIter, DBIterator>, - _marker: PhantomData<&'a Database>, -} - -impl<'a> Iterator for DatabaseIterator<'a> { - type Item = DBItem; - - fn next(&mut self) -> Option { - self.iter.next() - } -} - -struct DBAndColumns { - db: DB, - cfs: Vec, -} - -// get column family configuration from database config. -fn col_config(config: &DatabaseConfig, block_opts: &BlockBasedOptions) -> Result { - let mut opts = Options::new(); - - opts.set_parsed_options("level_compaction_dynamic_level_bytes=true")?; - - opts.set_block_based_table_factory(block_opts); - - opts.set_parsed_options(&format!( - "block_based_table_factory={{{};{}}}", - "cache_index_and_filter_blocks=true", "pin_l0_filter_and_index_blocks_in_cache=true" - ))?; - - opts.optimize_level_style_compaction(config.memory_budget_per_col() as i32); - opts.set_target_file_size_base(config.compaction.initial_file_size); - - opts.set_parsed_options("compression_per_level=")?; - - Ok(opts) -} - -/// Key-Value database. -pub struct Database { - db: RwLock>, - config: DatabaseConfig, - write_opts: WriteOptions, - read_opts: ReadOptions, - block_opts: BlockBasedOptions, - path: String, - // Dirty values added with `write_buffered`. Cleaned on `flush`. - overlay: RwLock, KeyState>>>, - // Values currently being flushed. Cleared when `flush` completes. - flushing: RwLock, KeyState>>>, - // Prevents concurrent flushes. - // Value indicates if a flush is in progress. - flushing_lock: Mutex, -} - -#[inline] -fn check_for_corruption>( - path: P, - res: result::Result, -) -> result::Result { - if let Err(ref s) = res { - if s.starts_with("Corruption:") { - warn!( - "DB corrupted: {}. Repair will be triggered on next restart", - s - ); - let _ = fs::File::create(path.as_ref().join(Database::CORRUPTION_FILE_NAME)); - } - } - - res -} - -fn is_corrupted(s: &str) -> bool { - s.starts_with("Corruption:") - || s.starts_with("Invalid argument: You have to open all column families") -} - -impl Database { - const CORRUPTION_FILE_NAME: &'static str = "CORRUPTED"; - - /// Open database with default settings. - pub fn open_default(path: &str) -> Result { - Database::open(&DatabaseConfig::default(), path) - } - - /// Open database file. Creates if it does not exist. - pub fn open(config: &DatabaseConfig, path: &str) -> Result { - let mut opts = Options::new(); - - if let Some(rate_limit) = config.compaction.write_rate_limit { - opts.set_parsed_options(&format!("rate_limiter_bytes_per_sec={}", rate_limit))?; - } - opts.set_use_fsync(false); - opts.create_if_missing(true); - opts.set_max_open_files(config.max_open_files); - opts.set_parsed_options("keep_log_file_num=1")?; - opts.set_parsed_options("bytes_per_sync=1048576")?; - opts.set_db_write_buffer_size(config.memory_budget_per_col() / 2); - opts.increase_parallelism(cmp::max(1, ::num_cpus::get() as i32 / 2)); - - let mut block_opts = BlockBasedOptions::new(); - - { - block_opts.set_block_size(config.compaction.block_size); - let cache_size = cmp::max(8, config.memory_budget() / 3); - let cache = Cache::new(cache_size); - block_opts.set_cache(cache); - } - - // attempt database repair if it has been previously marked as corrupted - let db_corrupted = Path::new(path).join(Database::CORRUPTION_FILE_NAME); - if db_corrupted.exists() { - warn!("DB has been previously marked as corrupted, attempting repair"); - DB::repair(&opts, path)?; - fs::remove_file(db_corrupted)?; - } - - let columns = config.columns.unwrap_or(0) as usize; - - let mut cf_options = Vec::with_capacity(columns); - let cfnames: Vec<_> = (0..columns).map(|c| format!("col{}", c)).collect(); - let cfnames: Vec<&str> = cfnames.iter().map(|n| n as &str).collect(); - - for _ in 0..config.columns.unwrap_or(0) { - cf_options.push(col_config(config, &block_opts)?); - } - - let mut write_opts = WriteOptions::new(); - if !config.wal { - write_opts.disable_wal(true); - } - let mut read_opts = ReadOptions::new(); - read_opts.set_verify_checksums(false); - - let mut cfs: Vec = Vec::new(); - let db = match config.columns { - Some(_) => { - match DB::open_cf(&opts, path, &cfnames, &cf_options) { - Ok(db) => { - cfs = cfnames - .iter() - .map(|n| { - db.cf_handle(n) - .expect("rocksdb opens a cf_handle for each cfname; qed") - }) - .collect(); - Ok(db) - } - Err(_) => { - // retry and create CFs - match DB::open_cf(&opts, path, &[], &[]) { - Ok(mut db) => { - cfs = cfnames - .iter() - .enumerate() - .map(|(i, n)| db.create_cf(n, &cf_options[i])) - .collect::<::std::result::Result<_, _>>()?; - Ok(db) - } - err => err, - } - } - } - } - None => DB::open(&opts, path), - }; - - let db = match db { - Ok(db) => db, - Err(ref s) if is_corrupted(s) => { - warn!("DB corrupted: {}, attempting repair", s); - DB::repair(&opts, path)?; - - if cfnames.is_empty() { - DB::open(&opts, path)? - } else { - let db = DB::open_cf(&opts, path, &cfnames, &cf_options)?; - cfs = cfnames - .iter() - .map(|n| { - db.cf_handle(n) - .expect("rocksdb opens a cf_handle for each cfname; qed") - }) - .collect(); - db - } - } - Err(s) => { - return Err(s.into()); - } - }; - let num_cols = cfs.len(); - Ok(Database { - read_opts, - block_opts, - write_opts, - db: RwLock::new(Some(DBAndColumns { db, cfs })), - config: config.clone(), - overlay: RwLock::new((0..(num_cols + 1)).map(|_| HashMap::new()).collect()), - flushing: RwLock::new((0..(num_cols + 1)).map(|_| HashMap::new()).collect()), - flushing_lock: Mutex::new(false), - path: path.to_owned(), - }) - } - - /// Helper to create new transaction for this database. - pub fn transaction(&self) -> DBTransaction { - DBTransaction::new() - } - - #[cfg_attr(feature = "cargo-clippy", allow(wrong_self_convention))] - fn to_overlay_column(col: Option) -> usize { - col.map_or(0, |c| (c + 1) as usize) - } - - /// Commit transaction to database. - pub fn write_buffered(&self, tr: DBTransaction) { - let mut overlay = self.overlay.write(); - let ops = tr.ops; - for op in ops { - match op { - DBOp::Insert { col, key, value } => { - let c = Self::to_overlay_column(col); - overlay[c].insert(key, KeyState::Insert(value)); - } - DBOp::Delete { col, key } => { - let c = Self::to_overlay_column(col); - overlay[c].insert(key, KeyState::Delete); - } - } - } - } - - /// Commit buffered changes to database. Must be called under `flush_lock` - fn write_flushing_with_lock(&self, _lock: &mut MutexGuard) -> Result<()> { - match *self.db.read() { - Some(DBAndColumns { ref db, ref cfs }) => { - let batch = WriteBatch::new(); - mem::swap(&mut *self.overlay.write(), &mut *self.flushing.write()); - { - for (c, column) in self.flushing.read().iter().enumerate() { - for (key, state) in column.iter() { - match *state { - KeyState::Delete => { - if c > 0 { - batch.delete_cf(cfs[c - 1], key)?; - } else { - batch.delete(key)?; - } - } - KeyState::Insert(ref value) => { - if c > 0 { - batch.put_cf(cfs[c - 1], key, value)?; - } else { - batch.put(key, value)?; - } - } - } - } - } - } - - check_for_corruption(&self.path, db.write_opt(batch, &self.write_opts))?; - - for column in self.flushing.write().iter_mut() { - column.clear(); - column.shrink_to_fit(); - } - Ok(()) - } - None => Err("Database is closed".into()), - } - } - - /// Commit buffered changes to database. - pub fn flush(&self) -> Result<()> { - let mut lock = self.flushing_lock.lock(); - // If RocksDB batch allocation fails the thread gets terminated and the lock is released. - // The value inside the lock is used to detect that. - if *lock { - // This can only happen if another flushing thread is terminated unexpectedly. - return Err("Database write failure. Running low on memory perhaps?".into()); - } - *lock = true; - let result = self.write_flushing_with_lock(&mut lock); - *lock = false; - result - } - - /// Commit transaction to database. - pub fn write(&self, tr: DBTransaction) -> Result<()> { - match *self.db.read() { - Some(DBAndColumns { ref db, ref cfs }) => { - let batch = WriteBatch::new(); - let ops = tr.ops; - for op in ops { - match op { - DBOp::Insert { col, key, value } => col.map_or_else( - || batch.put(&key, &value), - |c| batch.put_cf(cfs[c as usize], &key, &value), - )?, - DBOp::Delete { col, key } => col.map_or_else( - || batch.delete(&key), - |c| batch.delete_cf(cfs[c as usize], &key), - )?, - } - } - - check_for_corruption(&self.path, db.write_opt(batch, &self.write_opts)) - .map_err(Into::into) - } - None => Err("Database is closed".into()), - } - } - - /// Get value by key. - pub fn get(&self, col: Option, key: &[u8]) -> Result> { - match *self.db.read() { - Some(DBAndColumns { ref db, ref cfs }) => { - let overlay = &self.overlay.read()[Self::to_overlay_column(col)]; - match overlay.get(key) { - Some(&KeyState::Insert(ref value)) => Ok(Some(value.clone())), - Some(&KeyState::Delete) => Ok(None), - None => { - let flushing = &self.flushing.read()[Self::to_overlay_column(col)]; - match flushing.get(key) { - Some(&KeyState::Insert(ref value)) => Ok(Some(value.clone())), - Some(&KeyState::Delete) => Ok(None), - None => col.map_or_else( - || { - db.get_opt(key, &self.read_opts) - .map(|r| r.map(|v| DBValue::from_slice(&v))) - }, - |c| { - db.get_cf_opt(cfs[c as usize], key, &self.read_opts) - .map(|r| r.map(|v| DBValue::from_slice(&v))) - }, - ).map_err(Into::into), - } - } - } - } - None => Ok(None), - } - } - - /// Get value by partial key. Prefix size should match configured prefix size. - /// Only searches flushed values. - // TODO: support prefix seek for unflushed data - pub fn get_by_prefix(&self, col: Option, prefix: &[u8]) -> Option> { - self.iter_from_prefix(col, prefix).and_then(|mut iter| { - match iter.next() { - // TODO: use prefix_same_as_start read option (not availabele in C API currently) - Some((k, v)) => if k[0..prefix.len()] == prefix[..] { - Some(v) - } else { - None - }, - _ => None, - } - }) - } - - /// Get database iterator for flushed data. - pub fn iter(&self, col: Option) -> Option { - match *self.db.read() { - Some(DBAndColumns { ref db, ref cfs }) => { - let overlay = &self.overlay.read()[Self::to_overlay_column(col)]; - let mut overlay_data = overlay - .iter() - .filter_map(|(k, v)| match *v { - KeyState::Insert(ref value) => Some(( - k.clone().into_vec().into_boxed_slice(), - value.clone().into_vec().into_boxed_slice(), - )), - KeyState::Delete => None, - }) - .collect::>(); - overlay_data.sort(); - - let iter = col.map_or_else( - || db.iterator_opt(IteratorMode::Start, &self.read_opts), - |c| { - db.iterator_cf_opt(cfs[c as usize], IteratorMode::Start, &self.read_opts) - .expect("iterator params are valid; qed") - }, - ); - - Some(DatabaseIterator { - iter: interleave_ordered(overlay_data, iter), - _marker: PhantomData, - }) - } - None => None, - } - } - - fn iter_from_prefix(&self, col: Option, prefix: &[u8]) -> Option { - match *self.db.read() { - Some(DBAndColumns { ref db, ref cfs }) => { - let iter = col.map_or_else( - || { - db.iterator_opt( - IteratorMode::From(prefix, Direction::Forward), - &self.read_opts, - ) - }, - |c| { - db.iterator_cf_opt( - cfs[c as usize], - IteratorMode::From(prefix, Direction::Forward), - &self.read_opts, - ).expect("iterator params are valid; qed") - }, - ); - - Some(DatabaseIterator { - iter: interleave_ordered(Vec::new(), iter), - _marker: PhantomData, - }) - } - None => None, - } - } - - /// Close the database - fn close(&self) { - *self.db.write() = None; - self.overlay.write().clear(); - self.flushing.write().clear(); - } - - /// Restore the database from a copy at given path. - pub fn restore(&self, new_db: &str) -> Result<()> { - self.close(); - - let mut backup_db = PathBuf::from(&self.path); - backup_db.pop(); - backup_db.push("backup_db"); - - let existed = match fs::rename(&self.path, &backup_db) { - Ok(_) => true, - Err(e) => if let io::ErrorKind::NotFound = e.kind() { - false - } else { - return Err(e.into()); - }, - }; - - match fs::rename(&new_db, &self.path) { - Ok(_) => { - // clean up the backup. - if existed { - fs::remove_dir_all(&backup_db)?; - } - } - Err(e) => { - // restore the backup. - if existed { - fs::rename(&backup_db, &self.path)?; - } - return Err(e.into()); - } - } - - // reopen the database and steal handles into self - let db = Self::open(&self.config, &self.path)?; - *self.db.write() = mem::replace(&mut *db.db.write(), None); - *self.overlay.write() = mem::replace(&mut *db.overlay.write(), Vec::new()); - *self.flushing.write() = mem::replace(&mut *db.flushing.write(), Vec::new()); - Ok(()) - } - - /// The number of non-default column families. - pub fn num_columns(&self) -> u32 { - self.db - .read() - .as_ref() - .and_then(|db| { - if db.cfs.is_empty() { - None - } else { - Some(db.cfs.len()) - } - }) - .map(|n| n as u32) - .unwrap_or(0) - } - - /// Drop a column family. - pub fn drop_column(&self) -> Result<()> { - match *self.db.write() { - Some(DBAndColumns { - ref mut db, - ref mut cfs, - }) => { - if let Some(_col) = cfs.pop() { - let name = format!("col{}", cfs.len()); - db.drop_cf(&name)?; - } - Ok(()) - } - None => Ok(()), - } - } - - /// Add a column family. - pub fn add_column(&self) -> Result<()> { - match *self.db.write() { - Some(DBAndColumns { - ref mut db, - ref mut cfs, - }) => { - let col = cfs.len() as u32; - let name = format!("col{}", col); - cfs.push(db.create_cf(&name, &col_config(&self.config, &self.block_opts)?)?); - Ok(()) - } - None => Ok(()), - } - } -} - -// duplicate declaration of methods here to avoid trait import in certain existing cases -// at time of addition. -impl KeyValueDB for Database { - fn get(&self, col: Option, key: &[u8]) -> Result> { - Database::get(self, col, key) - } - - fn get_by_prefix(&self, col: Option, prefix: &[u8]) -> Option> { - Database::get_by_prefix(self, col, prefix) - } - - fn write_buffered(&self, transaction: DBTransaction) { - Database::write_buffered(self, transaction) - } - - fn write(&self, transaction: DBTransaction) -> Result<()> { - Database::write(self, transaction) - } - - fn flush(&self) -> Result<()> { - Database::flush(self) - } - - fn iter<'a>(&'a self, col: Option) -> Box + 'a> { - let unboxed = Database::iter(self, col); - Box::new(unboxed.into_iter().flat_map(|inner| inner)) - } - - fn iter_from_prefix<'a>( - &'a self, - col: Option, - prefix: &'a [u8], - ) -> Box + 'a> { - let unboxed = Database::iter_from_prefix(self, col, prefix); - Box::new(unboxed.into_iter().flat_map(|inner| inner)) - } - - fn restore(&self, new_db: &str) -> Result<()> { - Database::restore(self, new_db) - } -} - -impl Drop for Database { - fn drop(&mut self) { - // write all buffered changes if we can. - let _ = self.flush(); - } -} - -#[cfg(test)] -mod tests { - extern crate tempdir; - - use self::tempdir::TempDir; - use super::*; - use bigint::H256; - use std::str::FromStr; - - fn test_db(config: &DatabaseConfig) { - let tempdir = TempDir::new("").unwrap(); - let db = Database::open(config, tempdir.path().to_str().unwrap()).unwrap(); - let key1 = H256::from_str( - "02c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc", - ).unwrap(); - let key2 = H256::from_str( - "03c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc", - ).unwrap(); - let key3 = H256::from_str( - "01c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc", - ).unwrap(); - - let mut batch = db.transaction(); - batch.put(None, &key1, b"cat"); - batch.put(None, &key2, b"dog"); - db.write(batch).unwrap(); - - assert_eq!(&*db.get(None, &key1).unwrap().unwrap(), b"cat"); - - let contents: Vec<_> = db.iter(None).into_iter().flat_map(|inner| inner).collect(); - assert_eq!(contents.len(), 2); - assert_eq!(&*contents[0].0, &*key1); - assert_eq!(&*contents[0].1, b"cat"); - assert_eq!(&*contents[1].0, &*key2); - assert_eq!(&*contents[1].1, b"dog"); - - let mut batch = db.transaction(); - batch.delete(None, &key1); - db.write(batch).unwrap(); - - assert!(db.get(None, &key1).unwrap().is_none()); - - let mut batch = db.transaction(); - batch.put(None, &key1, b"cat"); - db.write(batch).unwrap(); - - let mut transaction = db.transaction(); - transaction.put(None, &key3, b"elephant"); - transaction.delete(None, &key1); - db.write(transaction).unwrap(); - assert!(db.get(None, &key1).unwrap().is_none()); - assert_eq!(&*db.get(None, &key3).unwrap().unwrap(), b"elephant"); - - assert_eq!(&*db.get_by_prefix(None, &key3).unwrap(), b"elephant"); - assert_eq!(&*db.get_by_prefix(None, &key2).unwrap(), b"dog"); - - let mut transaction = db.transaction(); - transaction.put(None, &key1, b"horse"); - transaction.delete(None, &key3); - db.write_buffered(transaction); - assert!(db.get(None, &key3).unwrap().is_none()); - assert_eq!(&*db.get(None, &key1).unwrap().unwrap(), b"horse"); - - db.flush().unwrap(); - assert!(db.get(None, &key3).unwrap().is_none()); - assert_eq!(&*db.get(None, &key1).unwrap().unwrap(), b"horse"); - } - - #[test] - fn kvdb() { - let tempdir = TempDir::new("").unwrap(); - let _ = Database::open_default(tempdir.path().to_str().unwrap()).unwrap(); - test_db(&DatabaseConfig::default()); - } - - #[test] - #[cfg(target_os = "linux")] - fn df_to_rotational() { - use std::path::PathBuf; - // Example df output. - let example_df = vec![ - 70, 105, 108, 101, 115, 121, 115, 116, 101, 109, 32, 32, 32, 32, 32, 49, 75, 45, 98, - 108, 111, 99, 107, 115, 32, 32, 32, 32, 32, 85, 115, 101, 100, 32, 65, 118, 97, 105, - 108, 97, 98, 108, 101, 32, 85, 115, 101, 37, 32, 77, 111, 117, 110, 116, 101, 100, 32, - 111, 110, 10, 47, 100, 101, 118, 47, 115, 100, 97, 49, 32, 32, 32, 32, 32, 32, 32, 54, - 49, 52, 48, 57, 51, 48, 48, 32, 51, 56, 56, 50, 50, 50, 51, 54, 32, 32, 49, 57, 52, 52, - 52, 54, 49, 54, 32, 32, 54, 55, 37, 32, 47, 10, - ]; - let expected_output = Some(PathBuf::from("/sys/block/sda/queue/rotational")); - assert_eq!(rotational_from_df_output(&example_df[..]), expected_output); - } - - #[test] - fn add_columns() { - let config = DatabaseConfig::default(); - let config_5 = DatabaseConfig::with_columns(Some(5)); - - let tempdir = TempDir::new("").unwrap(); - - // open empty, add 5. - { - let db = Database::open(&config, tempdir.path().to_str().unwrap()).unwrap(); - assert_eq!(db.num_columns(), 0); - - for i in 0..5 { - db.add_column().unwrap(); - assert_eq!(db.num_columns(), i + 1); - } - } - - // reopen as 5. - { - let db = Database::open(&config_5, tempdir.path().to_str().unwrap()).unwrap(); - assert_eq!(db.num_columns(), 5); - } - } - - #[test] - fn drop_columns() { - let config = DatabaseConfig::default(); - let config_5 = DatabaseConfig::with_columns(Some(5)); - - let tempdir = TempDir::new("").unwrap(); - - // open 5, remove all. - { - let db = Database::open(&config_5, tempdir.path().to_str().unwrap()).unwrap(); - assert_eq!(db.num_columns(), 5); - - for i in (0..5).rev() { - db.drop_column().unwrap(); - assert_eq!(db.num_columns(), i); - } - } - - // reopen as 0. - { - let db = Database::open(&config, tempdir.path().to_str().unwrap()).unwrap(); - assert_eq!(db.num_columns(), 0); - } - } -} diff --git a/util/kvdb/Cargo.toml b/util/kvdb/Cargo.toml deleted file mode 100644 index 4c57593720..0000000000 --- a/util/kvdb/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "kvdb" -version = "0.1.0" -authors = ["Parity Technologies "] - -[dependencies] -elastic-array = "0.9" -error-chain = { version = "0.11", default-features = false } diff --git a/util/kvdb/src/lib.rs b/util/kvdb/src/lib.rs deleted file mode 100644 index 0f91af651e..0000000000 --- a/util/kvdb/src/lib.rs +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -//! Key-Value store abstraction with `RocksDB` backend. - -extern crate elastic_array; -#[macro_use] -extern crate error_chain; - -use elastic_array::{ElasticArray128, ElasticArray32}; -use std::io; - -/// Required length of prefixes. -pub const PREFIX_LEN: usize = 12; - -/// Database value. -pub type DBValue = ElasticArray128; -/// Bytes -pub type Bytes = Vec; - -error_chain! { - types { - Error, ErrorKind, ResultExt, Result; - } - - foreign_links { - Io(io::Error); - } -} - -/// Write transaction. Batches a sequence of put/delete operations for efficiency. -#[derive(Default, Clone, PartialEq)] -pub struct DBTransaction { - /// Database operations. - pub ops: Vec, -} - -/// Database operation. -#[derive(Clone, PartialEq)] -pub enum DBOp { - Insert { - col: Option, - key: ElasticArray32, - value: DBValue, - }, - Delete { - col: Option, - key: ElasticArray32, - }, -} - -impl DBTransaction { - /// Create new transaction. - pub fn new() -> DBTransaction { - DBTransaction::with_capacity(256) - } - - /// Create new transaction with capacity. - pub fn with_capacity(cap: usize) -> DBTransaction { - DBTransaction { - ops: Vec::with_capacity(cap), - } - } - - /// Insert a key-value pair in the transaction. Any existing value will be overwritten upon write. - pub fn put(&mut self, col: Option, key: &[u8], value: &[u8]) { - let mut ekey = ElasticArray32::new(); - ekey.append_slice(key); - self.ops.push(DBOp::Insert { - col, - key: ekey, - value: DBValue::from_slice(value), - }); - } - - /// Insert a key-value pair in the transaction. Any existing value will be overwritten upon write. - pub fn put_vec(&mut self, col: Option, key: &[u8], value: Bytes) { - let mut ekey = ElasticArray32::new(); - ekey.append_slice(key); - self.ops.push(DBOp::Insert { - col, - key: ekey, - value: DBValue::from_vec(value), - }); - } - - /// Delete value by key. - pub fn delete(&mut self, col: Option, key: &[u8]) { - let mut ekey = ElasticArray32::new(); - ekey.append_slice(key); - self.ops.push(DBOp::Delete { col, key: ekey }); - } -} - -/// Generic key-value database. -/// -/// This makes a distinction between "buffered" and "flushed" values. Values which have been -/// written can always be read, but may be present in an in-memory buffer. Values which have -/// been flushed have been moved to backing storage, like a `RocksDB` instance. There are certain -/// operations which are only guaranteed to operate on flushed data and not buffered, -/// although implementations may differ in this regard. -/// -/// The contents of an interior buffer may be explicitly flushed using the `flush` method. -/// -/// The `KeyValueDB` also deals in "column families", which can be thought of as distinct -/// stores within a database. Keys written in one column family will not be accessible from -/// any other. The number of column families must be specified at initialization, with a -/// differing interface for each database. The `None` argument in place of a column index -/// is always supported. -/// -/// The API laid out here, along with the `Sync` bound implies interior synchronization for -/// implementation. -type DBItem = (Box<[u8]>, Box<[u8]>); - -pub trait KeyValueDB: Sync + Send { - /// Helper to create a new transaction. - fn transaction(&self) -> DBTransaction { - DBTransaction::new() - } - - /// Get a value by key. - fn get(&self, col: Option, key: &[u8]) -> Result>; - - /// Get a value by partial key. Only works for flushed data. - fn get_by_prefix(&self, col: Option, prefix: &[u8]) -> Option>; - - /// Write a transaction of changes to the buffer. - fn write_buffered(&self, transaction: DBTransaction); - - /// Write a transaction of changes to the backing store. - fn write(&self, transaction: DBTransaction) -> Result<()> { - self.write_buffered(transaction); - self.flush() - } - - /// Flush all buffered data. - fn flush(&self) -> Result<()>; - - /// Iterate over flushed data for a given column. - fn iter<'a>(&'a self, col: Option) -> Box + 'a>; - - /// Iterate over flushed data for a given column, starting from a given prefix. - fn iter_from_prefix<'a>( - &'a self, - col: Option, - prefix: &'a [u8], - ) -> Box + 'a>; - - /// Attempt to replace this database with a new one located at the given path. - fn restore(&self, new_db: &str) -> Result<()>; -} From 074852dc941835c53834ce82366d9b403b24a539 Mon Sep 17 00:00:00 2001 From: quake wang Date: Sun, 18 Mar 2018 11:58:22 +0900 Subject: [PATCH 03/14] chore: Change libp2p to main repo --- Cargo.lock | 167 ++++++++++++++++++++++++----------------------------- Cargo.toml | 2 +- 2 files changed, 76 insertions(+), 93 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3aea386bba..f52e63781d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -193,6 +193,11 @@ dependencies = [ "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "bs58" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "byte-tools" version = "0.2.0" @@ -245,11 +250,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chashmap" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "2.2.1" +source = "git+https://github.com/redox-os/tfs#3e7dcdb0c586d0d8bb3f25bfd948d2f418a4ab10" dependencies = [ - "owning_ref 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -398,10 +403,10 @@ dependencies = [ [[package]] name = "datastore" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "base64 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "chashmap 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "chashmap 2.2.1 (git+https://github.com/redox-os/tfs)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -555,8 +560,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures-mutex" -version = "0.2.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +version = "0.3.0" +source = "git+https://github.com/paritytech/futures-mutex#18ca11258512a1846826bc83782e538ac692d990" dependencies = [ "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -572,7 +577,7 @@ name = "generic-array" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "typenum 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -711,12 +716,12 @@ dependencies = [ [[package]] name = "libp2p-peerstore" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ - "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "datastore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", "multihash 0.7.0 (git+https://github.com/tomaka/rust-multihash?branch=emscripten-hack)", "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -726,13 +731,14 @@ dependencies = [ [[package]] name = "libp2p-ping" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", - "multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", + "multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -741,16 +747,17 @@ dependencies = [ [[package]] name = "libp2p-secio" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.12.1 (git+https://github.com/briansmith/ring?rev=3a14ef619559f7d4b69e2286d49c833409eef34a)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -758,13 +765,14 @@ dependencies = [ [[package]] name = "libp2p-swarm" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", - "multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", + "multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -773,11 +781,12 @@ dependencies = [ [[package]] name = "libp2p-tcp-transport" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -785,12 +794,13 @@ dependencies = [ [[package]] name = "libp2p-websocket" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", - "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", + "rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "stdweb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -965,7 +975,7 @@ dependencies = [ [[package]] name = "multiaddr" version = "0.2.0" -source = "git+https://github.com/libp2p/rust-libp2p#9faf3fae299b567a9a1b5e33edaba721adcf01ef" +source = "git+https://github.com/multiformats/rust-multiaddr#cc39c90fdde4d0b0ec24ee887fcd62a1bec67677" dependencies = [ "byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "cid 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -998,32 +1008,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "multiplex" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-mutex 0.2.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "futures-mutex 0.3.0 (git+https://github.com/paritytech/futures-mutex)", + "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "num-bigint 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", ] [[package]] name = "multistream-select" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", ] [[package]] @@ -1130,17 +1140,17 @@ dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "libp2p-secio 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "libp2p-tcp-transport 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "libp2p-websocket 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "libp2p-peerstore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-ping 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-secio 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-tcp-transport 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-websocket 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mdns-discover 0.2.0 (git+https://github.com/NervosFoundation/rust-mdns-discover)", "mdns-responder 0.2.0 (git+https://github.com/NervosFoundation/rust-mdns-responder)", - "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", - "multiplex 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", + "multiplex 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "nervos-core 0.1.0", "nervos-util 0.1.0", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1150,7 +1160,7 @@ dependencies = [ "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", ] [[package]] @@ -1302,11 +1312,6 @@ dependencies = [ "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "owning_ref" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "owning_ref" version = "0.3.3" @@ -1315,16 +1320,6 @@ dependencies = [ "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "parking_lot" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "owning_ref 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "thread-id 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "parking_lot" version = "0.4.8" @@ -1543,7 +1538,7 @@ dependencies = [ [[package]] name = "rw-stream-sink" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1833,16 +1828,6 @@ dependencies = [ "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "thread-id" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "thread_local" version = "0.3.5" @@ -1926,7 +1911,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "typenum" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2002,7 +1987,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "varint" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2122,6 +2107,7 @@ dependencies = [ "checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" "checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab" "checksum bls 0.1.0 (git+https://github.com/NervosFoundation/bls-rs.git)" = "" +"checksum bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e6ea4851598d7433fbdba71fa2509d9b0df68124b9c0effe7588f5149692d9f" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" "checksum byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96c8b41881888cc08af32d47ac4edd52bc7fa27fef774be47a92443756451304" "checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" @@ -2130,7 +2116,7 @@ dependencies = [ "checksum cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "deaf9ec656256bb25b404c51ef50097207b9cbb29c933d31f92cae5a8a0ffee0" "checksum cexpr 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42aac45e9567d97474a834efdee3081b3c942b2205be932092f53354ce503d6c" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" -"checksum chashmap 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "47e651a8c1eb0cbbaa730f705e2531e75276c6f2bbe2eb12662cfd305213dff8" +"checksum chashmap 2.2.1 (git+https://github.com/redox-os/tfs)" = "" "checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9" "checksum cid 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d85ee025368e69063c420cbb2ed9f852cb03a5e69b73be021e65726ce03585b6" "checksum clang-sys 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e414af9726e1d11660801e73ccc7fb81803fb5f49e5903a25b348b2b3b480d2e" @@ -2144,7 +2130,7 @@ dependencies = [ "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" "checksum ctrlc 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "653abc99aa905f693d89df4797fadc08085baee379db92be9f2496cefe8a6f2c" -"checksum datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum datastore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" "checksum digest 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "00a49051fef47a72c9623101b19bd71924a45cca838826caae3eaa4d00772603" "checksum dns-parser 0.3.2 (git+https://github.com/plietar/dns-parser)" = "" "checksum dns-parser 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7020f6760aea312d43d23cb83bf6c0c49f162541db8b02bf95209ac51dc253d" @@ -2163,7 +2149,7 @@ dependencies = [ "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0bab5b5e94f5c31fc764ba5dd9ad16568aae5d4825538c01d6bca680c9bf94a7" -"checksum futures-mutex 0.2.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum futures-mutex 0.3.0 (git+https://github.com/paritytech/futures-mutex)" = "" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" @@ -2183,12 +2169,12 @@ dependencies = [ "checksum lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef" "checksum libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "1e5d97d6708edaa407429faa671b942dc0f2727222fb6b6539bf1db936e4b121" "checksum libloading 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fd38073de8f7965d0c17d30546d4bb6da311ab428d1c7a3fc71dff7f9d4979b9" -"checksum libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" -"checksum libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" -"checksum libp2p-secio 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" -"checksum libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" -"checksum libp2p-tcp-transport 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" -"checksum libp2p-websocket 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum libp2p-peerstore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum libp2p-ping 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum libp2p-secio 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum libp2p-tcp-transport 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum libp2p-websocket 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" "checksum librocksdb-sys 5.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24a1a39da9ee5980093768bf21e1f5872673eb1db4e91de719a64a0c237e8e92" "checksum linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7860ec297f7008ff7a1e3382d7f7e1dcd69efc94751a2284bafc3d013c2aa939" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" @@ -2205,12 +2191,12 @@ dependencies = [ "checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" "checksum mio 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "7da01a5e23070d92d99b1ecd1cd0af36447c6fd44b0fe283c2db199fa136724f" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)" = "" "checksum multibase 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b9c35dac080fd6e16a99924c8dfdef0af89d797dd851adab25feaffacf7850d6" "checksum multihash 0.7.0 (git+https://github.com/tomaka/rust-multihash?branch=emscripten-hack)" = "" "checksum multimap 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9223f4774d08e06185e44e555b9a7561243d387bac49c78a6205c42d6975fbf2" -"checksum multiplex 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" -"checksum multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum multiplex 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" "checksum native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f74dbadc8b43df7864539cedb7bc91345e532fdd913cfdc23ad94f4d2d40fbc0" "checksum net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "3a80f842784ef6c9a958b68b7516bc7e35883c614004dd94959a4dca1b716c09" "checksum nix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "47e49f6982987135c5e9620ab317623e723bd06738fd85377e8d55f57c8b6487" @@ -2226,9 +2212,7 @@ dependencies = [ "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" "checksum openssl 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "a3605c298474a3aa69de92d21139fb5e2a81688d308262359d85cdd0d12a7985" "checksum openssl-sys 0.9.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5a41ce2f5f2d939c80decde8fcfcf5837c203ca6c06a553510a2fcb84fa3ef1" -"checksum owning_ref 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9d52571ddcb42e9c900c901a18d8d67e393df723fcd51dd59c5b1a85d0acb6cc" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" -"checksum parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "fa12d706797d42551663426a45e2db2e0364bd1dbf6aeada87e89c5f981f43e9" "checksum parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "149d8f5b97f3c1133e3cfcd8886449959e856b557ff281e292b733d7c69e005e" "checksum parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9fd9d732f2de194336fb02fe11f9eed13d9e76f13f4315b4d88a14ca411750cd" "checksum parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "538ef00b7317875071d5e00f603f24d16f0b474c1a5fc0ccb8b454ca72eafa79" @@ -2256,7 +2240,7 @@ dependencies = [ "checksum rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ceb8ce7a5e520de349e1fa172baeba4a9e8d5ef06c47471863530bc4972ee1e" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" -"checksum rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" "checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" "checksum schannel 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "acece75e0f987c48863a6c792ec8b7d6c4177d4a027f8ccc72f849794f437016" "checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d" @@ -2293,7 +2277,6 @@ dependencies = [ "checksum termcolor 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "56c456352e44f9f91f774ddeeed27c1ec60a2455ed66d692059acfb1d731bda1" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693" -"checksum thread-id 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2af4d6289a69a35c4d3aea737add39685f2784122c28119a7713165a63d68c9d" "checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" "checksum time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a15375f1df02096fb3317256ce2cee6a1f42fc84ea5ad5fc8c421cfe40c73098" "checksum tiny-keccak 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "58911ed5eb275a8fd2f1f0418ed360a42f59329864b64e1e95377a9024498c01" @@ -2303,7 +2286,7 @@ dependencies = [ "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" -"checksum typenum 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "13a99dc6780ef33c78780b826cf9d2a78840b72cae9474de4bcaf9051e60ebbd" +"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "51ccda9ef9efa3f7ef5d91e8f9b83bbe6955f9bf86aec89d5cce2c874625920f" @@ -2313,7 +2296,7 @@ dependencies = [ "checksum untrusted 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70afa43c8c5d23a53a3c39ec9b56232c5badc19f6bb5ad529c1d6448a7241365" "checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" -"checksum varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" "checksum vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9e0a7d8bed3178a8fb112199d466eeca9ed09a14ba8ad67718179b4fd5487d0b" "checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c" "checksum version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6b772017e347561807c1aa192438c5fd74242a670a6cffacc40f2defd1dc069d" diff --git a/Cargo.toml b/Cargo.toml index d789a6e815..792f96c34a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ ctrlc = { version = "3.1", features = ["termination"] } "ring" = { git = "https://github.com/briansmith/ring", rev = "3a14ef619559f7d4b69e2286d49c833409eef34a" } # Using a local improved version of multiaddr for now # TODO: remove once merged upstream -"multiaddr" = { git = "https://github.com/libp2p/rust-libp2p" } +"multiaddr" = { git = "https://github.com/multiformats/rust-multiaddr" } # Using a version of rust-multihash that compiles on emscripten # TODO: remove once merged upstream "multihash" = { git = "https://github.com/tomaka/rust-multihash", branch = "emscripten-hack" } From 08177e89babc64b3977e31776240ca4bdb75151b Mon Sep 17 00:00:00 2001 From: ian Date: Mon, 19 Mar 2018 15:48:16 +0800 Subject: [PATCH 04/14] feat(cell): Update cell structure according to Cell RFC. --- core/src/transaction.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/src/transaction.rs b/core/src/transaction.rs index 7b6fab2e93..8ad153d449 100644 --- a/core/src/transaction.rs +++ b/core/src/transaction.rs @@ -13,9 +13,9 @@ pub struct OutPoint { } #[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] -pub enum Lock { - LockForever, - LockByScript(Vec), +pub struct Recipient { + pub module_id: u32, + pub lock: Vec, } #[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] @@ -28,10 +28,11 @@ pub struct CellInput { #[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] pub struct CellOutput { + pub module: u32, + pub capacity: u32, pub data: Vec, - pub capacity: u64, - pub transform_lock: Lock, - pub destroy_lock: Option, + pub lock: Vec, + pub recipient: Option, } #[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] @@ -43,7 +44,7 @@ pub struct CellOperation { #[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] pub struct Transaction { pub version: u32, - pub cell_operations: Vec, + pub cell_groups: Vec>, } impl Transaction { From 2e5d7ef9134e67e3364fc6f05e3ef6bcf2e83b86 Mon Sep 17 00:00:00 2001 From: zhangsoledad <787953403@qq.com> Date: Mon, 12 Mar 2018 18:22:24 +0800 Subject: [PATCH 05/14] feat: Add sub command to generate node data directory --- Cargo.lock | 673 +++++++++++++++------------ Cargo.toml | 8 +- core/src/keygroup.rs | 6 + src/cli/app.yml | 16 + src/cli/mod.rs | 7 + src/cli/rsa.rs | 45 ++ src/cli/run_impl.rs | 8 +- src/cli/signer.rs | 139 ++++++ src/cli/spec.rs | 97 ++++ src/cli/template.rs | 77 +++ src/cli/templates/config.template | 10 + src/cli/templates/signer.template | 8 + src/config.rs | 121 ++--- src/main.rs | 35 +- util/crypto/Cargo.toml | 7 +- util/crypto/src/lib.rs | 9 + util/crypto/src/rsa/mod.rs | 63 +++ util/crypto/src/rsa/test/private.pem | 27 ++ util/crypto/src/rsa/test/private.pk8 | Bin 0 -> 1218 bytes util/crypto/src/rsa/test/public.der | Bin 0 -> 294 bytes util/dir/Cargo.toml | 7 + util/dir/src/lib.rs | 72 +++ 22 files changed, 1032 insertions(+), 403 deletions(-) create mode 100644 src/cli/app.yml create mode 100644 src/cli/rsa.rs create mode 100644 src/cli/signer.rs create mode 100644 src/cli/spec.rs create mode 100644 src/cli/template.rs create mode 100644 src/cli/templates/config.template create mode 100644 src/cli/templates/signer.template create mode 100644 util/crypto/src/rsa/mod.rs create mode 100644 util/crypto/src/rsa/test/private.pem create mode 100644 util/crypto/src/rsa/test/private.pk8 create mode 100644 util/crypto/src/rsa/test/public.der create mode 100644 util/dir/Cargo.toml create mode 100644 util/dir/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index f52e63781d..cb9ce0c42b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,6 +19,17 @@ dependencies = [ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "app_dirs" +version = "1.1.1" +source = "git+https://github.com/NervosFoundation/app-dirs-rs.git#faf50760ec1dd5eaf13a2193ad646c387a4731a4" +dependencies = [ + "ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "arrayref" version = "0.3.4" @@ -32,14 +43,6 @@ dependencies = [ "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "aster" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "atty" version = "0.2.6" @@ -67,7 +70,7 @@ name = "backtrace-sys" version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -115,7 +118,7 @@ dependencies = [ "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "fixed-hash 0.1.3", "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "uint 0.1.2", ] @@ -123,7 +126,7 @@ dependencies = [ name = "bigint-serialize" version = "0.2.1" dependencies = [ - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -132,27 +135,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bindgen" -version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cexpr 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "clang-sys 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.31.1 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi_codegen 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -160,11 +143,6 @@ name = "bitflags" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "bitflags" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bitflags" version = "0.9.1" @@ -189,15 +167,10 @@ name = "bls" version = "0.1.0" source = "git+https://github.com/NervosFoundation/bls-rs.git#44d332666e6fd4688f705139732c810e3e76fc8c" dependencies = [ - "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "bs58" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "byte-tools" version = "0.2.0" @@ -229,18 +202,10 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.4" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rayon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "cexpr" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -250,11 +215,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chashmap" -version = "2.2.1" -source = "git+https://github.com/redox-os/tfs#3e7dcdb0c586d0d8bb3f25bfd948d2f418a4ab10" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "owning_ref 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -276,16 +241,6 @@ dependencies = [ "multihash 0.7.0 (git+https://github.com/tomaka/rust-multihash?branch=emscripten-hack)", ] -[[package]] -name = "clang-sys" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "libloading 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "clap" version = "2.31.1" @@ -298,6 +253,7 @@ dependencies = [ "textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -385,9 +341,12 @@ dependencies = [ "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.3 (git+https://github.com/NervosFoundation/rust-openssl.git?branch=pkcs8_der)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "secp256k1 0.8.3 (git+https://github.com/NervosFoundation/rust-secp256k1)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -403,13 +362,13 @@ dependencies = [ [[package]] name = "datastore" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" dependencies = [ "base64 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "chashmap 2.2.1 (git+https://github.com/redox-os/tfs)", + "chashmap 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -421,6 +380,13 @@ dependencies = [ "generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "dir" +version = "0.1.0" +dependencies = [ + "app_dirs 1.1.1 (git+https://github.com/NervosFoundation/app-dirs-rs.git)", +] + [[package]] name = "dns-parser" version = "0.3.2" @@ -450,6 +416,14 @@ name = "either" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "elastic-array" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "env_logger" version = "0.4.3" @@ -461,7 +435,7 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -560,8 +534,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures-mutex" -version = "0.3.0" -source = "git+https://github.com/paritytech/futures-mutex#18ca11258512a1846826bc83782e538ac692d990" +version = "0.2.0" +source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" dependencies = [ "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -571,15 +545,23 @@ dependencies = [ name = "gcc" version = "0.3.54" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "generic-array" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "getopts" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "glob" version = "0.2.11" @@ -605,6 +587,11 @@ name = "httparse" version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "humansize" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "humantime" version = "1.1.0" @@ -655,6 +642,11 @@ name = "integer-encoding" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "interleaved-ordered" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "iovec" version = "0.1.2" @@ -678,6 +670,30 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "kvdb" +version = "0.1.0" +dependencies = [ + "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "kvdb-rocksdb" +version = "0.1.0" +dependencies = [ + "bigint 0.2.3", + "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb 0.1.0", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)", + "tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "language-tags" version = "0.2.2" @@ -703,42 +719,31 @@ name = "libc" version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "libloading" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "libp2p-peerstore" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" dependencies = [ - "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "datastore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", + "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", "multihash 0.7.0 (git+https://github.com/tomaka/rust-multihash?branch=emscripten-hack)", "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ping" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", - "multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", + "multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -747,17 +752,16 @@ dependencies = [ [[package]] name = "libp2p-secio" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.12.1 (git+https://github.com/briansmith/ring?rev=3a14ef619559f7d4b69e2286d49c833409eef34a)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -765,14 +769,13 @@ dependencies = [ [[package]] name = "libp2p-swarm" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", - "multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", + "multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -781,12 +784,11 @@ dependencies = [ [[package]] name = "libp2p-tcp-transport" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" dependencies = [ "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", + "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -794,34 +796,27 @@ dependencies = [ [[package]] name = "libp2p-websocket" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" dependencies = [ "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", - "rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", + "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", "stdweb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "librocksdb-sys" -version = "5.10.2" +name = "local-encoding" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bindgen 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "make-cmd 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "skeptic 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "linked-hash-map" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "log" version = "0.3.9" @@ -845,28 +840,15 @@ dependencies = [ "ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "lru-cache" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "make-cmd" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "matches" version = "0.1.6" @@ -901,14 +883,6 @@ dependencies = [ "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "memchr" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "memchr" version = "2.0.1" @@ -975,7 +949,7 @@ dependencies = [ [[package]] name = "multiaddr" version = "0.2.0" -source = "git+https://github.com/multiformats/rust-multiaddr#cc39c90fdde4d0b0ec24ee887fcd62a1bec67677" +source = "git+https://github.com/libp2p/rust-libp2p#9faf3fae299b567a9a1b5e33edaba721adcf01ef" dependencies = [ "byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "cid 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1008,32 +982,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "multiplex" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-mutex 0.3.0 (git+https://github.com/paritytech/futures-mutex)", - "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "futures-mutex 0.2.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", "num-bigint 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", ] [[package]] name = "multistream-select" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", ] [[package]] @@ -1056,7 +1030,10 @@ version = "0.1.0" dependencies = [ "bigint 0.2.3", "clap 2.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crypto 0.1.0", "ctrlc 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "dir 0.1.0", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "logger 0.1.0", "nervos-chain 0.1.0", @@ -1067,8 +1044,9 @@ dependencies = [ "nervos-pool 0.1.0", "nervos-time 0.1.0", "nervos-util 0.1.0", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "tera 0.11.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1084,7 +1062,7 @@ dependencies = [ "nervos-db 0.1.0", "nervos-util 0.1.0", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1097,9 +1075,11 @@ dependencies = [ "bls 0.1.0 (git+https://github.com/NervosFoundation/bls-rs.git)", "crypto 0.1.0", "hash 0.1.0", + "kvdb 0.1.0", + "kvdb-rocksdb 0.1.0", "merkle-root 0.1.0", "nervos-time 0.1.0", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1107,15 +1087,10 @@ dependencies = [ name = "nervos-db" version = "0.1.0" dependencies = [ - "bigint 0.2.3", "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nervos-core 0.1.0", "nervos-util 0.1.0", - "rocksdb 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", - "tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1126,7 +1101,6 @@ dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "nervos-chain 0.1.0", "nervos-core 0.1.0", - "nervos-db 0.1.0", "nervos-pool 0.1.0", "nervos-time 0.1.0", ] @@ -1140,27 +1114,27 @@ dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-peerstore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "libp2p-ping 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "libp2p-secio 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "libp2p-tcp-transport 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "libp2p-websocket 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "libp2p-secio 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "libp2p-tcp-transport 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "libp2p-websocket 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mdns-discover 0.2.0 (git+https://github.com/NervosFoundation/rust-mdns-discover)", "mdns-responder 0.2.0 (git+https://github.com/NervosFoundation/rust-mdns-responder)", - "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", - "multiplex 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", + "multiplex 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", "nervos-core 0.1.0", "nervos-util 0.1.0", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", ] [[package]] @@ -1222,14 +1196,6 @@ name = "nodrop" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "nom" -version = "3.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "num" version = "0.1.42" @@ -1247,7 +1213,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1289,6 +1255,15 @@ dependencies = [ "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ole32-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "openssl" version = "0.9.24" @@ -1298,20 +1273,37 @@ dependencies = [ "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.26 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.26 (git+https://github.com/NervosFoundation/rust-openssl.git?branch=pkcs8_der)", +] + +[[package]] +name = "openssl" +version = "0.10.3" +source = "git+https://github.com/NervosFoundation/rust-openssl.git?branch=pkcs8_der#b9a6d87912f1a5a5d4e42309b39684b31d72a0cc" +dependencies = [ + "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.26 (git+https://github.com/NervosFoundation/rust-openssl.git?branch=pkcs8_der)", ] [[package]] name = "openssl-sys" version = "0.9.26" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/NervosFoundation/rust-openssl.git?branch=pkcs8_der#b9a6d87912f1a5a5d4e42309b39684b31d72a0cc" dependencies = [ - "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "owning_ref" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "owning_ref" version = "0.3.3" @@ -1320,6 +1312,16 @@ dependencies = [ "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "owning_ref 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "thread-id 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parking_lot" version = "0.4.8" @@ -1350,15 +1352,25 @@ dependencies = [ ] [[package]] -name = "peeking_take_while" -version = "0.1.2" +name = "percent-encoding" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "percent-encoding" -version = "1.0.1" +name = "pest" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "pest_derive" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "pest 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "pkg-config" version = "0.3.9" @@ -1370,23 +1382,11 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "quasi" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quasi_codegen" -version = "0.32.0" +name = "pulldown-cmark" +version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1419,6 +1419,14 @@ dependencies = [ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rayon" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rayon" version = "0.9.0" @@ -1428,6 +1436,15 @@ dependencies = [ "rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rayon" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rayon-core" version = "1.4.0" @@ -1437,7 +1454,7 @@ dependencies = [ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1484,7 +1501,7 @@ name = "ring" version = "0.12.1" source = "git+https://github.com/briansmith/ring?rev=3a14ef619559f7d4b69e2286d49c833409eef34a#3a14ef619559f7d4b69e2286d49c833409eef34a" dependencies = [ - "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1493,11 +1510,23 @@ dependencies = [ [[package]] name = "rocksdb" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.4.5" +source = "git+https://github.com/paritytech/rust-rocksdb#ecf06adf3148ab10f6f7686b724498382ff4f36e" +dependencies = [ + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "local-encoding 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rocksdb-sys 0.3.0 (git+https://github.com/paritytech/rust-rocksdb)", +] + +[[package]] +name = "rocksdb-sys" +version = "0.3.0" +source = "git+https://github.com/paritytech/rust-rocksdb#ecf06adf3148ab10f6f7686b724498382ff4f36e" dependencies = [ + "cc 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "librocksdb-sys 5.10.2 (registry+https://github.com/rust-lang/crates.io-index)", + "local-encoding 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "snappy-sys 0.1.0 (git+https://github.com/paritytech/rust-snappy)", ] [[package]] @@ -1538,7 +1567,7 @@ dependencies = [ [[package]] name = "rw-stream-sink" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1574,7 +1603,7 @@ name = "secp256k1" version = "0.8.3" source = "git+https://github.com/NervosFoundation/rust-secp256k1#7f50d7ad0590b73047c983dc81d6beec4ba9a3f1" dependencies = [ - "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1614,7 +1643,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.27" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1638,13 +1667,13 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1668,6 +1697,24 @@ dependencies = [ "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "shell32-sys" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "skeptic" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "pulldown-cmark 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "slab" version = "0.3.0" @@ -1678,6 +1725,14 @@ name = "slab" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "slug" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unidecode 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "smallvec" version = "0.5.0" @@ -1688,6 +1743,15 @@ name = "smallvec" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "snappy-sys" +version = "0.1.0" +source = "git+https://github.com/paritytech/rust-snappy#858eac97192ea25d18d3f3626a8cc13ca0b175bb" +dependencies = [ + "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "stable_deref_trait" version = "1.0.0" @@ -1730,48 +1794,6 @@ dependencies = [ "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "syntex" -version = "0.58.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syntex_errors" -version = "0.58.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syntex_pos" -version = "0.58.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syntex_syntax" -version = "0.58.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "tempdir" version = "0.3.6" @@ -1794,12 +1816,22 @@ dependencies = [ ] [[package]] -name = "term" -version = "0.4.6" +name = "tera" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pest 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "pest_derive 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "slug 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1828,6 +1860,16 @@ dependencies = [ "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "thread-id" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "thread_local" version = "0.3.5" @@ -1896,7 +1938,7 @@ name = "toml" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1911,7 +1953,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "typenum" -version = "1.10.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1956,6 +1998,11 @@ name = "unicode-xid" version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unidecode" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unreachable" version = "1.0.0" @@ -1987,7 +2034,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "varint" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2084,13 +2131,23 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "xdg" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "yaml-rust" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [metadata] "checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4" "checksum ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b3568b48b7cefa6b8ce125f9bb4989e52fbcc29ebea88df04cc7c5f12f70455" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum app_dirs 1.1.1 (git+https://github.com/NervosFoundation/app-dirs-rs.git)" = "" "checksum arrayref 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0fd1479b7c29641adbd35ff3b5c293922d696a92f25c8c975da3e0acbc87258f" "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" -"checksum aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfdf7355d9db158df68f976ed030ab0f6578af811f5a7bb6dcf221ec24e0e0" "checksum atty 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8352656fd42c30a0c3c89d26dea01e3b77c0ab2af18230835c15e2e13cd51859" "checksum backtrace 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbbf59b1c43eefa8c3ede390fcc36820b4999f7914104015be25025e0d62af2" "checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661" @@ -2100,26 +2157,21 @@ dependencies = [ "checksum base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96434f987501f0ed4eb336a411e0631ecd1afa11574fe148587adc4ff96143c9" "checksum base64 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5032d51da2741729bfdaeb2664d9b8c6d9fd1e2b90715c660b6def36628499c2" "checksum bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bda13183df33055cbb84b847becce220d392df502ebe7a4a78d7021771ed94d0" -"checksum bindgen 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ba610cba0c1727ed837316540068b51349b8268c073906067b7c3948598929bd" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" -"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" "checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab" "checksum bls 0.1.0 (git+https://github.com/NervosFoundation/bls-rs.git)" = "" -"checksum bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e6ea4851598d7433fbdba71fa2509d9b0df68124b9c0effe7588f5149692d9f" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" "checksum byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96c8b41881888cc08af32d47ac4edd52bc7fa27fef774be47a92443756451304" "checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" "checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23" "checksum bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1b7db437d718977f6dc9b2e3fd6fc343c02ac6b899b73fdd2179163447bd9ce9" -"checksum cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "deaf9ec656256bb25b404c51ef50097207b9cbb29c933d31f92cae5a8a0ffee0" -"checksum cexpr 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42aac45e9567d97474a834efdee3081b3c942b2205be932092f53354ce503d6c" +"checksum cc 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "87f38f122db5615319a985757e526c00161d924d19b71a0f3e80c52bab1adcf6" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" -"checksum chashmap 2.2.1 (git+https://github.com/redox-os/tfs)" = "" +"checksum chashmap 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "47e651a8c1eb0cbbaa730f705e2531e75276c6f2bbe2eb12662cfd305213dff8" "checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9" "checksum cid 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d85ee025368e69063c420cbb2ed9f852cb03a5e69b73be021e65726ce03585b6" -"checksum clang-sys 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e414af9726e1d11660801e73ccc7fb81803fb5f49e5903a25b348b2b3b480d2e" "checksum clap 2.31.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dc18f6f4005132120d9711636b32c46a233fad94df6217fa1d81c5e97a9f200" "checksum core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25bfd746d203017f7d5cbd31ee5d8e17f94b6521c7af77ece6c9e4b2d4b16c67" "checksum core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "065a5d7ffdcbc8fa145d6f0746f3555025b9097a9e9cda59f7467abae670c78d" @@ -2130,14 +2182,15 @@ dependencies = [ "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" "checksum ctrlc 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "653abc99aa905f693d89df4797fadc08085baee379db92be9f2496cefe8a6f2c" -"checksum datastore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" "checksum digest 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "00a49051fef47a72c9623101b19bd71924a45cca838826caae3eaa4d00772603" "checksum dns-parser 0.3.2 (git+https://github.com/plietar/dns-parser)" = "" "checksum dns-parser 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7020f6760aea312d43d23cb83bf6c0c49f162541db8b02bf95209ac51dc253d" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" "checksum either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "740178ddf48b1a9e878e6d6509a1442a2d42fd2928aae8e7a6f8a36fb01981b3" +"checksum elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "258ff6a9a94f648d0379dbd79110e057edbb53eb85cc237e33eadf8e5a30df85" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" -"checksum env_logger 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f3cc21490995c841d68e00276eba02071ebb269ec24011d5728bd00eabd39e31" +"checksum env_logger 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f0628f04f7c26ebccf40d7fc2c1cf92236c05ec88cf2132641cc956812312f0f" "checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" "checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" "checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82" @@ -2149,17 +2202,20 @@ dependencies = [ "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0bab5b5e94f5c31fc764ba5dd9ad16568aae5d4825538c01d6bca680c9bf94a7" -"checksum futures-mutex 0.3.0 (git+https://github.com/paritytech/futures-mutex)" = "" +"checksum futures-mutex 0.2.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" +"checksum getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "b900c08c1939860ce8b54dc6a89e26e00c04c380fd0e09796799bd7f12861e05" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2f407128745b78abc95c0ffbe4e5d37427fdc0d45470710cfef8c44522a2e37" +"checksum humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e" "checksum humantime 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369e01a05e3404c421b5d6dcfea6ecf7d5e65eba8a275948151358cd8282042" "checksum hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)" = "368cb56b2740ebf4230520e2b90ebb0461e69034d85d1945febd9b3971426db2" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum ifaces 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa5cce6b4cae6792378aefb34152be19600949dde0041e7910430022f94b81f1" "checksum integer-encoding 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26746cbc2e680af687e88d717f20ff90079bd10fc984ad57d277cd0e37309fa5" +"checksum interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141340095b15ed7491bd3d4ced9d20cebfb826174b6bb03386381f62b01e3d77" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" @@ -2168,41 +2224,35 @@ dependencies = [ "checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" "checksum lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef" "checksum libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "1e5d97d6708edaa407429faa671b942dc0f2727222fb6b6539bf1db936e4b121" -"checksum libloading 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fd38073de8f7965d0c17d30546d4bb6da311ab428d1c7a3fc71dff7f9d4979b9" -"checksum libp2p-peerstore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" -"checksum libp2p-ping 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" -"checksum libp2p-secio 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" -"checksum libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" -"checksum libp2p-tcp-transport 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" -"checksum libp2p-websocket 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" -"checksum librocksdb-sys 5.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24a1a39da9ee5980093768bf21e1f5872673eb1db4e91de719a64a0c237e8e92" -"checksum linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7860ec297f7008ff7a1e3382d7f7e1dcd69efc94751a2284bafc3d013c2aa939" +"checksum libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum libp2p-secio 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum libp2p-tcp-transport 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum libp2p-websocket 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum local-encoding 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1ceb20f39ff7ae42f3ff9795f3986b1daad821caaa1e1732a0944103a5a1a66" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" -"checksum lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4d06ff7ff06f729ce5f4e227876cb88d10bc59cd4ae1e09fbb2bde15c850dc21" -"checksum make-cmd 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8ca8afbe8af1785e09636acb5a41e08a765f5f0340568716c18a8700ba3c0d3" "checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376" "checksum mdns-discover 0.2.0 (git+https://github.com/NervosFoundation/rust-mdns-discover)" = "" "checksum mdns-responder 0.2.0 (git+https://github.com/NervosFoundation/rust-mdns-responder)" = "" -"checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum memoffset 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e163e5baece1a039e71e75b074de17a9b4114982aa109921fc20253bdf91a53c" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" "checksum mio 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "7da01a5e23070d92d99b1ecd1cd0af36447c6fd44b0fe283c2db199fa136724f" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)" = "" +"checksum multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)" = "" "checksum multibase 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b9c35dac080fd6e16a99924c8dfdef0af89d797dd851adab25feaffacf7850d6" "checksum multihash 0.7.0 (git+https://github.com/tomaka/rust-multihash?branch=emscripten-hack)" = "" "checksum multimap 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9223f4774d08e06185e44e555b9a7561243d387bac49c78a6205c42d6975fbf2" -"checksum multiplex 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" -"checksum multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum multiplex 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" "checksum native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f74dbadc8b43df7864539cedb7bc91345e532fdd913cfdc23ad94f4d2d40fbc0" "checksum net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "3a80f842784ef6c9a958b68b7516bc7e35883c614004dd94959a4dca1b716c09" "checksum nix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "47e49f6982987135c5e9620ab317623e723bd06738fd85377e8d55f57c8b6487" "checksum nix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2c5afeb0198ec7be8569d666644b574345aad2e95a53baf3a532da3e0f3fb32" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" -"checksum nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05aec50c70fd288702bcd93284a8444607f3292dbdf2a30de5ea5dcdbe72287b" "checksum num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e" "checksum num-bigint 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "81b483ea42927c463e191802e7334556b48e7875297564c0e9951bd3a0ae53e3" "checksum num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f8d26da319fb45674985c78f1d1caf99aa4941f785d384a2ae36d0740bc3e2fe" @@ -2210,23 +2260,29 @@ dependencies = [ "checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" "checksum num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7de20f146db9d920c45ee8ed8f71681fd9ade71909b48c3acbd766aa504cf10" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" +"checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" +"checksum openssl 0.10.3 (git+https://github.com/NervosFoundation/rust-openssl.git?branch=pkcs8_der)" = "" "checksum openssl 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "a3605c298474a3aa69de92d21139fb5e2a81688d308262359d85cdd0d12a7985" -"checksum openssl-sys 0.9.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5a41ce2f5f2d939c80decde8fcfcf5837c203ca6c06a553510a2fcb84fa3ef1" +"checksum openssl-sys 0.9.26 (git+https://github.com/NervosFoundation/rust-openssl.git?branch=pkcs8_der)" = "" +"checksum owning_ref 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9d52571ddcb42e9c900c901a18d8d67e393df723fcd51dd59c5b1a85d0acb6cc" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" +"checksum parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "fa12d706797d42551663426a45e2db2e0364bd1dbf6aeada87e89c5f981f43e9" "checksum parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "149d8f5b97f3c1133e3cfcd8886449959e856b557ff281e292b733d7c69e005e" "checksum parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9fd9d732f2de194336fb02fe11f9eed13d9e76f13f4315b4d88a14ca411750cd" "checksum parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "538ef00b7317875071d5e00f603f24d16f0b474c1a5fc0ccb8b454ca72eafa79" -"checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +"checksum pest 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0fce5d8b5cc33983fc74f78ad552b5522ab41442c4ca91606e4236eb4b5ceefc" +"checksum pest_derive 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6453faedc5c9980a3c278f28b1df33344a79cc6d4a2fd96e2b56288374dc822a" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" "checksum protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bec26e67194b7d991908145fdf21b7cae8b08423d96dcb9e860cd31f854b9506" -"checksum quasi 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18c45c4854d6d1cf5d531db97c75880feb91c958b0720f4ec1057135fec358b3" -"checksum quasi_codegen 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9e25fa23c044c1803f43ca59c98dac608976dd04ce799411edd58ece776d4" +"checksum pulldown-cmark 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8361e81576d2e02643b04950e487ec172b687180da65c731c03cf336784e6c07" "checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" +"checksum rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b614fe08b6665cb9a231d07ac1364b0ef3cb3698f1239ee0c4c3a88a524f54c8" "checksum rayon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed02d09394c94ffbdfdc755ad62a132e94c3224a8354e78a1200ced34df12edf" +"checksum rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "485541959c8ecc49865526fe6c4de9653dd6e60d829d6edf0be228167b60372d" "checksum rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d24ad214285a7729b174ed6d3bcfcb80177807f959d95fafd5bfc5c4f201ac8" "checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" @@ -2234,13 +2290,14 @@ dependencies = [ "checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e" "checksum remove_dir_all 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b5d2f806b0fcdabd98acd380dc8daef485e22bcb7cddc811d1337967f2528cf5" "checksum ring 0.12.1 (git+https://github.com/briansmith/ring?rev=3a14ef619559f7d4b69e2286d49c833409eef34a)" = "" -"checksum rocksdb 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41eb461abed4e4f2b3f9a852b38f9cb2ef25ae866a3e8fa827fbe4a7d8dc42c3" +"checksum rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)" = "" +"checksum rocksdb-sys 0.3.0 (git+https://github.com/paritytech/rust-rocksdb)" = "" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" "checksum rustc-demangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11fb43a206a04116ffd7cfcf9bcb941f8eb6cc7ff667272246b0a1c74259a3cb" "checksum rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ceb8ce7a5e520de349e1fa172baeba4a9e8d5ef06c47471863530bc4972ee1e" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" -"checksum rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" "checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" "checksum schannel 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "acece75e0f987c48863a6c792ec8b7d6c4177d4a027f8ccc72f849794f437016" "checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d" @@ -2250,33 +2307,34 @@ dependencies = [ "checksum security-framework-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "5421621e836278a0b139268f36eee0dc7e389b784dc3f79d8f11aabadf41bead" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "db99f3919e20faa51bb2996057f5031d8685019b5a06139b1ce761da671b8526" +"checksum serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "c73f63e08b33f6e59dfb3365b009897ebc3a3edc4af6e4f3ce8e483cf3d80ce7" "checksum serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "f4ba7591cfe93755e89eeecdbcc668885624829b020050e6aec99c2a03bd3fd0" "checksum serde_derive_internals 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6e03f1c9530c3fb0a0a5c9b826bdd9246a5921ae995d75f512ac917fc4dd55b5" -"checksum serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c9db7266c7d63a4c4b7fe8719656ccdd51acf1bed6124b174f933b009fb10bcb" +"checksum serde_json 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "fab6c4d75bedcf880711c85e39ebf8ccc70d0eba259899047ec5d7436643ee17" "checksum sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc30b1e1e8c40c121ca33b86c23308a090d19974ef001b4bf6e61fd1a0fb095c" "checksum sha1 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "171698ce4ec7cbb93babeb3190021b4d72e96ccb98e33d277ae4ea959d6f2d9e" "checksum sha2 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7daca11f2fdb8559c4f6c588386bed5e2ad4b6605c1442935a7f08144a918688" +"checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" +"checksum skeptic 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24ebf8a06f5f8bae61ae5bbc7af7aac4ef6907ae975130faba1199e5fe82256a" "checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" "checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d" +"checksum slug 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f5ff4b43cb07b86c5f9236c92714a22cdf9e5a27a7d85e398e2c9403328cb8" "checksum smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "872c0ff227000041c520cca51e883b858d388ab0ecf646bab76f065cebaec025" "checksum smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44db0ecb22921ef790d17ae13a3f6d15784183ff5f2a01aa32098c7498d2b4b9" +"checksum snappy-sys 0.1.0 (git+https://github.com/paritytech/rust-snappy)" = "" "checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b" "checksum stdweb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef5430c8e36b713e13b48a9f709cc21e046723fe44ce34587b73a830203b533e" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" -"checksum syntex 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a8f5e3aaa79319573d19938ea38d068056b826db9883a5d47f86c1cecc688f0e" -"checksum syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "867cc5c2d7140ae7eaad2ae9e8bf39cb18a67ca651b7834f88d46ca98faadb9c" -"checksum syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13ad4762fe52abc9f4008e85c4fb1b1fe3aa91ccb99ff4826a439c7c598e1047" -"checksum syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6e0e4dbae163dd98989464c23dd503161b338790640e11537686f2ef0f25c791" "checksum tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f73eebdb68c14bcb24aef74ea96079830e7fa7b31a6106e42ea7ee887c1e134e" "checksum tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11ce2fe9db64b842314052e2421ac61a73ce41b898dc8e3750398b219c5fc1e0" -"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" +"checksum tera 0.11.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fc1a35d04c2444875b1319293fbc72c00215ae6220f8c70f9f14fefa5eaae0c6" "checksum termcolor 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "56c456352e44f9f91f774ddeeed27c1ec60a2455ed66d692059acfb1d731bda1" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693" +"checksum thread-id 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2af4d6289a69a35c4d3aea737add39685f2784122c28119a7713165a63d68c9d" "checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" "checksum time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a15375f1df02096fb3317256ce2cee6a1f42fc84ea5ad5fc8c421cfe40c73098" "checksum tiny-keccak 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "58911ed5eb275a8fd2f1f0418ed360a42f59329864b64e1e95377a9024498c01" @@ -2286,17 +2344,18 @@ dependencies = [ "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" -"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" +"checksum typenum 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "13a99dc6780ef33c78780b826cf9d2a78840b72cae9474de4bcaf9051e60ebbd" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "51ccda9ef9efa3f7ef5d91e8f9b83bbe6955f9bf86aec89d5cce2c874625920f" "checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" +"checksum unidecode 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2adb95ee07cd579ed18131f2d9e7a17c25a4b76022935c7f2460d2bfae89fd2" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum untrusted 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70afa43c8c5d23a53a3c39ec9b56232c5badc19f6bb5ad529c1d6448a7241365" "checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" -"checksum varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" "checksum vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9e0a7d8bed3178a8fb112199d466eeca9ed09a14ba8ad67718179b4fd5487d0b" "checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c" "checksum version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6b772017e347561807c1aa192438c5fd74242a670a6cffacc40f2defd1dc069d" @@ -2309,3 +2368,5 @@ dependencies = [ "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +"checksum xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a66b7c2281ebde13cf4391d70d4c7e5946c3c25e72a7b859ca8f677dcd0b0c61" +"checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" diff --git a/Cargo.toml b/Cargo.toml index 792f96c34a..67b9485b67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Nervos Core Dev "] [dependencies] -clap = "2" +clap = { version = "2", features = ["yaml"] } toml = "0.4" serde = "1.0" serde_derive = "1.0" @@ -19,7 +19,11 @@ nervos-pool = { path = "pool"} nervos-time = { path = "util/time"} logger = { path = "util/logger" } bigint = { path = "util/bigint" } +dir = { path = "util/dir" } +crypto = { path = "util/crypto", features = ["rsa"] } ctrlc = { version = "3.1", features = ["termination"] } +tera = "0.11" +lazy_static = "1.0" # The [patch] sections in Cargo.toml are only recognized in the root crate's manifest [patch.crates-io] @@ -31,6 +35,7 @@ ctrlc = { version = "3.1", features = ["termination"] } # Using a version of rust-multihash that compiles on emscripten # TODO: remove once merged upstream "multihash" = { git = "https://github.com/tomaka/rust-multihash", branch = "emscripten-hack" } +"openssl-sys" = { git = "https://github.com/NervosFoundation/rust-openssl.git", branch = "pkcs8_der" } [workspace] members = [ @@ -38,6 +43,7 @@ members = [ "util/hash", "util/merkle-root", "util/crypto", + "util/dir", "network", "core", "chain", diff --git a/core/src/keygroup.rs b/core/src/keygroup.rs index 6908f5b9f1..f97b92a996 100644 --- a/core/src/keygroup.rs +++ b/core/src/keygroup.rs @@ -8,6 +8,12 @@ pub struct KeyGroup { } impl KeyGroup { + pub fn with_capacity(capacity: usize) -> KeyGroup { + KeyGroup { + data: HashMap::with_capacity(capacity), + } + } + pub fn insert( &mut self, signer_public_key: PublicKey, diff --git a/src/cli/app.yml b/src/cli/app.yml new file mode 100644 index 0000000000..dc1bf797b1 --- /dev/null +++ b/src/cli/app.yml @@ -0,0 +1,16 @@ +name: nervos +version: "0.1.0" +author: Nervos Core Dev +about: Nervos CKB - The Common Knowledge Base +args: + - data-dir: + short: d + long: data-dir + value_name: PATH + help: Specify the database and configuration directory PATH. + takes_value: true +subcommands: + - run: + about: run + - new: + about: init data dir diff --git a/src/cli/mod.rs b/src/cli/mod.rs index a061ae7128..fbb853825e 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -1,3 +1,10 @@ +mod rsa; mod run_impl; +mod signer; +mod spec; +mod template; pub use self::run_impl::run; +pub use self::signer::Signer; +pub use self::spec::Spec; +pub use self::template::{Templates, TemplatesExt, TEMPLATES}; diff --git a/src/cli/rsa.rs b/src/cli/rsa.rs new file mode 100644 index 0000000000..77d2c1e119 --- /dev/null +++ b/src/cli/rsa.rs @@ -0,0 +1,45 @@ +use super::template::TemplatesExt; +use crypto::rsa::Rsa; +use std::error::Error; +use std::fs::{File, OpenOptions}; +use std::io::{self, BufReader, Read, Write}; +use std::path::Path; +use toml; + +impl TemplatesExt for Rsa { + type Output = Rsa; + + fn load>(path: P) -> io::Result { + use std::error::Error; + + let file = File::open(path)?; + let mut reader = BufReader::new(file); + let mut rsa_string = String::new(); + reader.read_to_string(&mut rsa_string)?; + toml::from_str(&rsa_string) + .map_err(|e| io::Error::new(io::ErrorKind::Other, e.description())) + } + + fn write>(&self, path: P) -> io::Result<()> { + let mut file = OpenOptions::new().write(true).create_new(true).open(path)?; + let content = + toml::to_vec(self).map_err(|e| io::Error::new(io::ErrorKind::Other, e.description()))?; + file.write_all(&content)?; + Ok(()) + } + + fn load_or_write_default>(path: P) -> io::Result { + match Self::load(path.as_ref()) { + Ok(ret) => Ok(ret), + Err(e) => { + if e.kind() == io::ErrorKind::NotFound { + let ret = Self::Output::default(); + ret.write(path)?; + Ok(ret) + } else { + Err(e) + } + } + } + } +} diff --git a/src/cli/run_impl.rs b/src/cli/run_impl.rs index 30c7bbd8a8..e077a2f485 100644 --- a/src/cli/run_impl.rs +++ b/src/cli/run_impl.rs @@ -16,9 +16,7 @@ use std::sync::Arc; use std::thread; use util::{Condvar, Mutex}; -pub fn run(config_path: &str) { - let config = Config::load(config_path); - +pub fn run(config: Config) { logger::init(config.logger_config()).expect("Init Logger"); info!(target: "main", "Value for config: {:?}", config); @@ -44,8 +42,8 @@ pub fn run(config_path: &str) { let miner = Miner { chain, tx_pool, - miner_key: config.miner_private_key, - signer_key: bigint::H256::from(&config.signer_private_key[..]), + miner_key: config.signer.miner_private_key, + signer_key: bigint::H256::from(&config.signer.signer_private_key[..]), }; let _ = thread::Builder::new() diff --git a/src/cli/signer.rs b/src/cli/signer.rs new file mode 100644 index 0000000000..89be043de6 --- /dev/null +++ b/src/cli/signer.rs @@ -0,0 +1,139 @@ +use super::template::{TemplatesExt, TEMPLATES}; +use bigint::{H160, H256}; +use core::{ProofPublicG, ProofPublickey, PublicKey}; +use std::fs::{File, OpenOptions}; +use std::io::{self, BufReader, Read, Write}; +use std::path::Path; +use toml; + +#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)] +pub struct KeyPair { + pub proof_public_key: ProofPublickey, + pub proof_public_g: ProofPublicG, + pub signer_public_key: PublicKey, +} + +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct Signer { + pub miner_private_key: H160, + pub signer_private_key: H256, + pub key_pairs: Vec, +} + +impl Default for Signer { + fn default() -> Self { + use std::str::FromStr; + + let key_pairs = vec![ + KeyPair { + proof_public_key: ProofPublickey::from_str("037151adfd9b0167d943ad816352bf0a96cfedfa15b60caddda91ad710732cb80cb54d46ce2fa9fc00").unwrap(), + proof_public_g: ProofPublicG::from_str("0ce477d8a5e6b27c9d8ec9e54efbf6f5b3455ffa01899a237d80d463f737f65f0d975a8bb3ceca9e00").unwrap(), + signer_public_key: PublicKey::from_str("8c651d8deaef3119589ab0ba527661d97cb2fd595348ef283b7a14ba252ba493184be105beeb4ef62a20fa93a3d93672dab07381e8f01017ef5124624ddbe2a0").unwrap(), + }, + KeyPair { + proof_public_key: ProofPublickey::from_str("03a02e943dc86d0d09a84f4c9c1d5ce0fbe4337c06fe1975e13fa1a7013f297701818d27400604d101").unwrap(), + proof_public_g: ProofPublicG::from_str("15f3b0f38a316392cb6829b18eb220bf9e40bef301869f275d27d35e176fcfaae839bc387021c7ce01").unwrap(), + signer_public_key: PublicKey::from_str("2cb94bd40d4f9edbeb77f682f095fc68e71a8d639d4afd93470e23a2cfb845e1ec4d0c034913e27eb64fad7c8254db7812252065bfbc7432f38944569e7941d5").unwrap(), + }, + KeyPair { + proof_public_key: ProofPublickey::from_str("133f84a2fba7d7d75c8bef53662ce555c034bdcc059765937f5b5fa3fad7fc5de96929f47285612001").unwrap(), + proof_public_g: ProofPublicG::from_str("004ca4aa1dcafbf4392cf395e8e78f3ebdc880ab0ef4a512f0dd486bf1a6861114f4d835d6dcacf001").unwrap(), + signer_public_key: PublicKey::from_str("aef7c4b07094501fe566859b6b713b541beb4ddf5c1821337d57836095a1eb1371223aa6904a26dbe1ebd74556c1cf1831910c5349a118a771edd6919aed701e").unwrap(), + }, + KeyPair { + proof_public_key: ProofPublickey::from_str("07cafa7797efe36d26bb0af68bf8a55640f57fc811f5ee73bb7d10a2735cf0eb059b7cfb1107fc9d00").unwrap(), + proof_public_g: ProofPublicG::from_str("0318e21e32b26d6310e3609e78cdddfcc817f0f41a3deb02a611d63af17c7246b939360692bfd14900").unwrap(), + signer_public_key: PublicKey::from_str("415a033b4596c0c95542b304ae3241bbc82508cf4425950abb273023931adc37c77f92759e079c81967a5ba65b2d93027eda0e4c89a84f32917c24bf82be57ad").unwrap(), + } + ]; + + let miner_private_key = H160::from_str("1162b2f150c789aed32e2e0b3081dd6852926865").unwrap(); + let signer_private_key = H256::from_str( + "097c1a2d03b6c8fc270991051553219e34951b656382ca951c4c226d40a3b2d5", + ).unwrap(); + + Signer { + miner_private_key, + signer_private_key, + key_pairs, + } + } +} + +impl TemplatesExt for Signer { + type Output = Signer; + + fn load>(path: P) -> io::Result { + use std::error::Error; + + let file = File::open(path)?; + let mut reader = BufReader::new(file); + let mut config_string = String::new(); + reader.read_to_string(&mut config_string)?; + toml::from_str(&config_string) + .map_err(|e| io::Error::new(io::ErrorKind::Other, e.description())) + } + + fn write>(&self, path: P) -> io::Result<()> { + let mut file = OpenOptions::new().write(true).create_new(true).open(path)?; + let content = TEMPLATES.render_signer(self); + file.write_all(content.as_bytes())?; + Ok(()) + } + + fn load_or_write_default>(path: P) -> io::Result { + match Self::load(path.as_ref()) { + Ok(ret) => Ok(ret), + Err(e) => { + if e.kind() == io::ErrorKind::NotFound { + let ret = Self::Output::default(); + ret.write(path)?; + Ok(ret) + } else { + Err(e) + } + } + } + } +} + +#[cfg(test)] +mod tests { + use super::{toml, H160, H256, Signer}; + use std::str::FromStr; + + #[test] + fn signer_de() { + let signer: Signer = toml::from_str(r#" + miner_private_key = "0x1162b2f150c789aed32e2e0b3081dd6852926865" + signer_private_key = "0x097c1a2d03b6c8fc270991051553219e34951b656382ca951c4c226d40a3b2d5" + [[key_pairs]] + proof_public_key = "0x037151adfd9b0167d943ad816352bf0a96cfedfa15b60caddda91ad710732cb80cb54d46ce2fa9fc00" + proof_public_g = "0x0ce477d8a5e6b27c9d8ec9e54efbf6f5b3455ffa01899a237d80d463f737f65f0d975a8bb3ceca9e00" + signer_public_key = "0x1fd4decbd2ed6eb0f2d817eecffc26d1ff73b43b5d198a0bd2a973440f56d36d33e405525ecfb12215438a4bed517b9f8c3291dc80d03b51a8221caf983d703e" + [[key_pairs]] + proof_public_key = "0x03a02e943dc86d0d09a84f4c9c1d5ce0fbe4337c06fe1975e13fa1a7013f297701818d27400604d101" + proof_public_g = "0x15f3b0f38a316392cb6829b18eb220bf9e40bef301869f275d27d35e176fcfaae839bc387021c7ce01" + signer_public_key = "0xe3b72557d9bc2ed7f50a6f598dd6213c15eabb4b827d65ca32bf8d184c06c99fd76ab439b1cfe2c810bcdaa3890b5d4d1b816782cef0a37974ea0ec0a0f8bace" + [[key_pairs]] + proof_public_key = "0x133f84a2fba7d7d75c8bef53662ce555c034bdcc059765937f5b5fa3fad7fc5de96929f47285612001" + proof_public_g = "0x004ca4aa1dcafbf4392cf395e8e78f3ebdc880ab0ef4a512f0dd486bf1a6861114f4d835d6dcacf001" + signer_public_key = "0xa94942232300b74bf191e37435102a90cbe81b1ad5e2fccacfcd5aec115fd2b414d887b44641b3e3dc5fc137178cd1e027d104e7985aea9c539c46dd42dc2b9c" + [[key_pairs]] + proof_public_key = "0x07cafa7797efe36d26bb0af68bf8a55640f57fc811f5ee73bb7d10a2735cf0eb059b7cfb1107fc9d00" + proof_public_g = "0x0318e21e32b26d6310e3609e78cdddfcc817f0f41a3deb02a611d63af17c7246b939360692bfd14900" + signer_public_key = "0x223f2c5f71a9b3f42c65accc76ca90cd3a76f8587bf40f1069f3a6c05d1fbd645b04cfa45beaf884e2cf3b8d734aa7c6b68063eaa530f8fabf20c0341ae95156" + "#).expect("Spec deserialize."); + + assert_eq!( + H160::from_str("1162b2f150c789aed32e2e0b3081dd6852926865").unwrap(), + signer.miner_private_key + ); + assert_eq!( + H256::from_str("097c1a2d03b6c8fc270991051553219e34951b656382ca951c4c226d40a3b2d5") + .unwrap(), + signer.signer_private_key + ); + assert_eq!(4, signer.key_pairs.len()); + } +} diff --git a/src/cli/spec.rs b/src/cli/spec.rs new file mode 100644 index 0000000000..ba89fe85fc --- /dev/null +++ b/src/cli/spec.rs @@ -0,0 +1,97 @@ +use super::template::{TemplatesExt, TEMPLATES}; +use logger::Config as LogConfig; +use std::fs::{File, OpenOptions}; +use std::io::{self, BufReader, Read, Write}; +use std::path::Path; +use toml; + +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct NetworkConfig { + pub listen_addr: String, + pub bootstrap_nodes: Vec<(String, String)>, +} + +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct Spec { + pub logger: LogConfig, + pub network: NetworkConfig, +} + +impl Default for Spec { + fn default() -> Self { + let logger = LogConfig { + filter: Some("main=info,miner=info,chain=info".to_string()), + color: true, + file: Some("/tmp/nervos0.log".to_string()), + }; + + let network = NetworkConfig { + listen_addr: "/ip4/0.0.0.0/tcp/12300".to_string(), + bootstrap_nodes: vec![ + ( + "QmWvoPbu9AgEFLL5UyxpCfhxkLDd9T7zuerjhHiwsnqSh4".to_string(), + "/ip4/127.0.0.1/tcp/12345".to_string(), + ), + ], + }; + + Spec { logger, network } + } +} + +impl TemplatesExt for Spec { + type Output = Spec; + + fn load>(path: P) -> io::Result { + use std::error::Error; + + let file = File::open(path)?; + let mut reader = BufReader::new(file); + let mut config_string = String::new(); + reader.read_to_string(&mut config_string)?; + toml::from_str(&config_string) + .map_err(|e| io::Error::new(io::ErrorKind::Other, e.description())) + } + + fn write>(&self, path: P) -> io::Result<()> { + let mut file = OpenOptions::new().write(true).create_new(true).open(path)?; + let content = TEMPLATES.render_spec(self); + file.write_all(content.as_bytes())?; + Ok(()) + } + + fn load_or_write_default>(path: P) -> io::Result { + match Self::load(path.as_ref()) { + Ok(ret) => Ok(ret), + Err(e) => { + if e.kind() == io::ErrorKind::NotFound { + let ret = Self::Output::default(); + ret.write(path)?; + Ok(ret) + } else { + Err(e) + } + } + } + } +} + +#[cfg(test)] +mod tests { + use super::{toml, Spec}; + + #[test] + fn spec_de() { + let spec: Spec = toml::from_str(r#" + [logger] + file = "/tmp/nervos.log" + filter = "main=info,miner=info,chain=info" + color = true + [network] + listen_addr = "/ip4/0.0.0.0/tcp/0" + bootstrap_nodes = [["QmWvoPbu9AgEFLL5UyxpCfhxkLDd9T7zuerjhHiwsnqSh4", "/ip4/127.0.0.1/tcp/12345"]] + "#).expect("Spec deserialize."); + + assert_eq!(true, spec.logger.color); + } +} diff --git a/src/cli/template.rs b/src/cli/template.rs new file mode 100644 index 0000000000..2675e9a515 --- /dev/null +++ b/src/cli/template.rs @@ -0,0 +1,77 @@ +#![allow(dead_code)] + +use super::signer::Signer; +use super::spec::Spec; +use std::io; +use std::path::Path; +use tera::Context; +use tera::Tera; + +lazy_static! { + pub static ref TEMPLATES: Templates = Templates::new(); +} + +pub trait TemplatesExt { + type Output; + + fn load>(path: P) -> io::Result; + + fn write>(&self, path: P) -> io::Result<()>; + + fn load_or_write_default>(path: P) -> io::Result; +} + +pub struct Templates { + inner: Tera, +} + +impl Templates { + pub fn new() -> Templates { + let config_template = include_str!("templates/config.template"); + let signer_template = include_str!("templates/signer.template"); + + let mut tera = Tera::default(); + tera.add_raw_templates(vec![ + ("config.toml", config_template), + ("signer.toml", signer_template), + ]).expect("Load templates"); + + Templates { inner: tera } + } + + pub fn render_spec(&self, spec: &Spec) -> String { + let mut context = Context::new(); + context.add("logger", &spec.logger); + context.add("network", &spec.network); + self.inner + .render("config.toml", &context) + .expect("Render config") + } + + pub fn render_signer(&self, signer: &Signer) -> String { + let mut context = Context::new(); + context.add("miner_private_key", &signer.miner_private_key); + context.add("signer_private_key", &signer.signer_private_key); + context.add("key_pairs", &signer.key_pairs); + self.inner + .render("signer.toml", &context) + .expect("Render signer") + } +} + +#[cfg(test)] +mod tests { + use super::{Signer, Spec, Templates}; + + #[test] + fn render_spec() { + let spec = Spec::default(); + println!("{}", Templates::new().render_spec(&spec)); + } + + #[test] + fn render_signer() { + let signer = Signer::default(); + println!("{}", Templates::new().render_signer(&signer)); + } +} diff --git a/src/cli/templates/config.template b/src/cli/templates/config.template new file mode 100644 index 0000000000..8b297b3e37 --- /dev/null +++ b/src/cli/templates/config.template @@ -0,0 +1,10 @@ +[logger] +file = "{{ logger.file }}" +filter = "{{ logger.filter }}" +color = {{ logger.color }} + +[network] +listen_addr = "{{ network.listen_addr }}" +bootstrap_nodes = [{% for bootstrap_node in network.bootstrap_nodes %} + ["{{bootstrap_node.0}}", "{{bootstrap_node.1}}"] +{% endfor %}] diff --git a/src/cli/templates/signer.template b/src/cli/templates/signer.template new file mode 100644 index 0000000000..a55009db36 --- /dev/null +++ b/src/cli/templates/signer.template @@ -0,0 +1,8 @@ +miner_private_key = "{{ miner_private_key }}" +signer_private_key = "{{ signer_private_key }}" +{% for key_pair in key_pairs %} +[[key_pairs]] +proof_public_key = "{{ key_pair.proof_public_key }}" +proof_public_g = "{{ key_pair.proof_public_g }}" +signer_public_key = "{{ key_pair.signer_public_key }}" +{% endfor %} diff --git a/src/config.rs b/src/config.rs index be3fdb943c..31eefdd60d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,37 +1,58 @@ -use bigint::{H160, H256}; -use core::{ProofPublicG, ProofPublickey, PublicKey}; +use clap; +use cli::{Signer, Spec, TemplatesExt}; use core::keygroup::KeyGroup; +use crypto::rsa::Rsa; +use dir::{default_base_path, Directories}; use logger::Config as LogConfig; use network::Config as NetworkConfig; -use std::fs::File; -use std::io::BufReader; -use std::io::Read; -use toml; -#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)] +const CONFIG_FILE: &str = "config.toml"; +const SIGNER_FILE: &str = "signer.toml"; +const RSA_FILE: &str = "rsa.toml"; + +#[derive(Clone, Debug, Default, PartialEq)] pub struct Config { pub logger: LogConfig, - pub miner_private_key: H160, - pub signer_private_key: H256, - pub key_pairs: Vec, + pub signer: Signer, pub network: NetworkConfig, - pub db_path: String, -} - -#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)] -pub struct KeyPair { - pub proof_public_key: ProofPublickey, - pub proof_public_g: ProofPublicG, - pub signer_public_key: PublicKey, + pub dirs: Directories, } impl Config { - pub fn load(path: &str) -> Config { - let file = File::open(path).unwrap(); - let mut reader = BufReader::new(file); - let mut config_string = String::new(); - reader.read_to_string(&mut config_string).unwrap(); - toml::from_str(&config_string).unwrap() + pub fn parse(matches: &clap::ArgMatches) -> Config { + let dirs = Self::parse_data_path(matches); + let spec = Spec::load_or_write_default(&dirs.base.join(CONFIG_FILE)).expect("load spec"); + + let signer = + Signer::load_or_write_default(&dirs.signer.join(SIGNER_FILE)).expect("load signer"); + + let rsa = Rsa::load_or_write_default(&dirs.keys.join(RSA_FILE)).expect("load signer"); + + let Spec { network, logger } = spec; + + let network = NetworkConfig { + private_key: rsa.privkey_pkcs8, + public_key: rsa.pubkey_der, + listen_addr: network.listen_addr, + bootstrap_nodes: network.bootstrap_nodes, + }; + + Config { + dirs, + signer, + logger, + network, + } + } + + fn parse_data_path(matches: &clap::ArgMatches) -> Directories { + let data_path = matches + .value_of("data-dir") + .map(Into::into) + .unwrap_or_else(default_base_path); + let data_dir = Directories::new(&data_path); + data_dir.create_dirs().expect("Create data dir"); + data_dir } pub fn logger_config(&self) -> LogConfig { @@ -39,57 +60,11 @@ impl Config { } pub fn key_group(&self) -> KeyGroup { - let mut kg = KeyGroup::default(); - for kp in self.key_pairs.clone() { + let key_pairs = self.signer.key_pairs.clone(); + let mut kg = KeyGroup::with_capacity(key_pairs.len()); + for kp in key_pairs { kg.insert(kp.signer_public_key, kp.proof_public_key, kp.proof_public_g); } kg } } - -#[cfg(test)] -mod tests { - use super::{toml, Config, H160}; - use std::str::FromStr; - - #[test] - fn config_deserialize() { - let config: Config = toml::from_str(r#" - miner_private_key = "0x1162b2f150c789aed32e2e0b3081dd6852926865" - signer_private_key = "0x097c1a2d03b6c8fc270991051553219e34951b656382ca951c4c226d40a3b2d5" - db_path = ".nervos/db" - [logger] - file = "/tmp/nervos.log" - filter = "main=info,miner=info,chain=info" - color = true - [[key_pairs]] - proof_public_key = "0x037151adfd9b0167d943ad816352bf0a96cfedfa15b60caddda91ad710732cb80cb54d46ce2fa9fc00" - proof_public_g = "0x0ce477d8a5e6b27c9d8ec9e54efbf6f5b3455ffa01899a237d80d463f737f65f0d975a8bb3ceca9e00" - signer_public_key = "0x1fd4decbd2ed6eb0f2d817eecffc26d1ff73b43b5d198a0bd2a973440f56d36d33e405525ecfb12215438a4bed517b9f8c3291dc80d03b51a8221caf983d703e" - [[key_pairs]] - proof_public_key = "0x03a02e943dc86d0d09a84f4c9c1d5ce0fbe4337c06fe1975e13fa1a7013f297701818d27400604d101" - proof_public_g = "0x15f3b0f38a316392cb6829b18eb220bf9e40bef301869f275d27d35e176fcfaae839bc387021c7ce01" - signer_public_key = "0xe3b72557d9bc2ed7f50a6f598dd6213c15eabb4b827d65ca32bf8d184c06c99fd76ab439b1cfe2c810bcdaa3890b5d4d1b816782cef0a37974ea0ec0a0f8bace" - [[key_pairs]] - proof_public_key = "0x133f84a2fba7d7d75c8bef53662ce555c034bdcc059765937f5b5fa3fad7fc5de96929f47285612001" - proof_public_g = "0x004ca4aa1dcafbf4392cf395e8e78f3ebdc880ab0ef4a512f0dd486bf1a6861114f4d835d6dcacf001" - signer_public_key = "0xa94942232300b74bf191e37435102a90cbe81b1ad5e2fccacfcd5aec115fd2b414d887b44641b3e3dc5fc137178cd1e027d104e7985aea9c539c46dd42dc2b9c" - [[key_pairs]] - proof_public_key = "0x07cafa7797efe36d26bb0af68bf8a55640f57fc811f5ee73bb7d10a2735cf0eb059b7cfb1107fc9d00" - proof_public_g = "0x0318e21e32b26d6310e3609e78cdddfcc817f0f41a3deb02a611d63af17c7246b939360692bfd14900" - signer_public_key = "0x223f2c5f71a9b3f42c65accc76ca90cd3a76f8587bf40f1069f3a6c05d1fbd645b04cfa45beaf884e2cf3b8d734aa7c6b68063eaa530f8fabf20c0341ae95156" - [network] - private_key = [0, 1, 2] - public_key = [3, 4, 5] - listen_addr = "/ip4/0.0.0.0/tcp/0" - bootstrap_nodes = [["QmWvoPbu9AgEFLL5UyxpCfhxkLDd9T7zuerjhHiwsnqSh4", "/ip4/127.0.0.1/tcp/12345"]] - "#).expect("Load config."); - - assert_eq!(true, config.logger_config().color); - assert_eq!( - H160::from_str("1162b2f150c789aed32e2e0b3081dd6852926865").unwrap(), - config.miner_private_key - ); - assert_eq!(4, config.key_group().len()); - } -} diff --git a/src/main.rs b/src/main.rs index 8db85708b4..80459412b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,11 @@ extern crate bigint; #[macro_use] extern crate clap; +extern crate crypto; extern crate ctrlc; +extern crate dir; +#[macro_use] +extern crate lazy_static; #[macro_use] extern crate log; extern crate logger; @@ -16,35 +20,32 @@ extern crate nervos_util as util; extern crate serde; #[macro_use] extern crate serde_derive; +extern crate tera; extern crate toml; mod adapter; mod cli; mod config; +use config::Config; + fn main() { // Always print backtrace on panic. - ::std::env::set_var("RUST_BACKTRACE", "1"); + ::std::env::set_var("RUST_BACKTRACE", "full"); + + let yaml = load_yaml!("cli/app.yml"); - let matches = clap_app!(nervos => - (version: "0.1") - (author: "Nervos ") - (about: "Nervos") - (@subcommand run => - (about: "run nervos") - (@arg config: -c --config +takes_value "Sets a custom config file") - ) - (@subcommand new => - (about: "new nervos config") - ) - ).get_matches(); + let matches = clap::App::from_yaml(yaml).get_matches(); + + let config = Config::parse(&matches); match matches.subcommand() { - ("run", Some(run_cmd)) => { - let config_path = run_cmd.value_of("config").unwrap_or("default.toml"); - cli::run(config_path); + ("run", Some(_run_cmd)) => { + cli::run(config); } ("new", Some(_new_cmd)) => {} - _ => {} + _ => { + cli::run(config); + } } } diff --git a/util/crypto/Cargo.toml b/util/crypto/Cargo.toml index 6e339d383b..fb592a9a7d 100644 --- a/util/crypto/Cargo.toml +++ b/util/crypto/Cargo.toml @@ -11,9 +11,14 @@ failure_derive = "0.1.1" bigint = { path = "../bigint" } rand = "0.4" rustc-hex = "1.0" -crunchy = "0.1.5" +crunchy = { version = "0.1.5", optional = true } +openssl = { git = "https://github.com/NervosFoundation/rust-openssl.git", branch = "pkcs8_der", optional = true } +serde = "1.0" +serde_derive = "1.0" [features] default = ["secp"] secp = ["secp256k1"] +bech32 = [] +rsa = ["openssl"] dev = [] diff --git a/util/crypto/src/lib.rs b/util/crypto/src/lib.rs index e0e80fbdbf..0500948d6d 100644 --- a/util/crypto/src/lib.rs +++ b/util/crypto/src/lib.rs @@ -3,6 +3,7 @@ extern crate test; extern crate bigint; +#[cfg(feature = "bech32")] #[macro_use] extern crate crunchy; #[macro_use] @@ -11,7 +12,15 @@ extern crate failure; extern crate lazy_static; extern crate rand; extern crate rustc_hex; +#[cfg(feature = "rsa")] +extern crate serde; +#[cfg(feature = "rsa")] +#[macro_use] +extern crate serde_derive; #[cfg(feature = "secp")] pub mod secp; +#[cfg(feature = "bech32")] pub mod bech32; +#[cfg(feature = "rsa")] +pub mod rsa; diff --git a/util/crypto/src/rsa/mod.rs b/util/crypto/src/rsa/mod.rs new file mode 100644 index 0000000000..6ffef92ae2 --- /dev/null +++ b/util/crypto/src/rsa/mod.rs @@ -0,0 +1,63 @@ +#![allow(dead_code)] + +extern crate openssl; + +use self::openssl::pkey::PKey; +use self::openssl::rsa::Rsa as RsaGen; + +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct Rsa { + pub privkey_pkcs8: Vec, + pub pubkey_der: Vec, +} + +impl Default for Rsa { + fn default() -> Self { + let rsa = RsaGen::generate(2048).expect("Initialize Rsa"); + let pkey = PKey::from_rsa(rsa).expect("Initialize PKey"); + let privkey_pkcs8: Vec = pkey.private_key_to_der_pkcs8() + .expect("Serialize privkey to pkcs8"); + let pubkey_der: Vec = pkey.public_key_to_der().expect("Serialize pubkey der"); + + Rsa { + privkey_pkcs8, + pubkey_der, + } + } +} + +impl Rsa { + fn from_private_pem>(privkey_pem: T) -> Self { + let rsa = RsaGen::private_key_from_pem(privkey_pem.as_ref()).expect("Read privkey pem"); + let pkey = PKey::from_rsa(rsa).expect("Initialize PKey"); + let privkey_pkcs8: Vec = pkey.private_key_to_der_pkcs8() + .expect("Serialize privkey to pkcs8"); + let pubkey_der: Vec = pkey.public_key_to_der().expect("Serialize pubkey der"); + + Rsa { + privkey_pkcs8, + pubkey_der, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_rsa_gen() { + let _rsa = Rsa::default(); + } + + #[test] + fn test_rsa_load() { + let test_privkey = include_bytes!("test/private.pem"); + let test_privkey_pkcs8 = include_bytes!("test/private.pk8").to_vec(); + let test_pubkey = include_bytes!("test/public.der").to_vec(); + let rsa = Rsa::from_private_pem(&test_privkey[..]); + + assert_eq!(test_privkey_pkcs8, rsa.privkey_pkcs8); + assert_eq!(test_pubkey, rsa.pubkey_der); + } +} diff --git a/util/crypto/src/rsa/test/private.pem b/util/crypto/src/rsa/test/private.pem new file mode 100644 index 0000000000..d9ad84a7bd --- /dev/null +++ b/util/crypto/src/rsa/test/private.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAwTG3B8yJnOUbFU5WSV0VeNAyFQtTW5QpaHwBLAR79/VqL5PY +Gdy3FqbpKr+TZC1a67mKg73g0FALAdlsanln20rZnStrO/s2Ib7dz6pS7tCSHGVC +dCdCa4cmTy1Qd7gn5R8fVnN/wk3MO4HVP3pLbF10wJe71xw2Xk7oBC90vxHBO3hx +zT+r9vZqcJwBSjbFI5w73WoqnSjZRs3ArnskrQF8KxgUyB/fPweiXc7Ard8Pgh6f +hzqDRBhKVn7wD0zljWzp95HG1asDnHSVPfAbBDYq0XUOOBzPHZkjdS+3bWq2PtzA +BOWYPDCf0fdg845XAi7K3XCslk66QtKQCayoOQIDAQABAoIBAFHe/J6sekDoAmM0 +EHMEpH3PVPoAE7JCho3Fx0VdHSAGe5pv/+tt0pUh5Lv99btFUTuGJIIR7Hy6/v8o +ob45dt7CyJfHd6kym00PsrY3iu+zqceozdGldYtV+dEh9fDWNOnvF3uudJzmFT++ +lJ1S+TWSIVEgvDS7uvqaW86yQbpaUM/1RfwvrhKqwGsTSgqZ0LI/OH6KAqsd9KBH +aPC/jc9RKpCGLbXy7TZBsCRFR89c7JBZ9eWSJdwgZFaTLr1nw6oYumqqo5rVIlSY +dPJG6I+aM379N8vSoHXIs8O89k0A5uhliQpjerDmzPIsXTsKFUi1kktZg+6SYUU+ +VYNx4ZUCgYEA/J/6Rje5+P9fpfy4i5jkP87xfGpnmQQ0gZgyk1hv/8fIkBNxq15w +F0JKVYR1aiPw1/EeL/agC1bmyYfUGUKC7/16GLX7W19rDZr8ZihdUd/is2fMXoNp +eHoIuqd9wkAQS42toDiZfhRRB3iTq32CczDwoXQMBFQfRJjvnF0pBxMCgYEAw8Z5 +Qf87jOnrvlfQf4KqDFvK/kwGMtSPD+JVvS8teXfKmRmf/oGQQ8l2g8IwxUzzDpUd +/C72CoxSzVBFYNGT0IJGc/rVN3hrG2Ky0jqQnKJ66FhG9qc60N6Z6rinZzoGh0Ey +D4LiNbZ7vg790rklx3TuFqxOLqQSweyWsBL7gQMCgYAegYsNc6lHgj8gojX+1YWq +lujeZ1L/TVyx0Zk55dIQhyWXEGIHma3bgSvMy+QJ3zE0Qm+sxxFojSPtbjOUoU2C +gY9+8GrcC9e3muGjzHgIbQrJM12ghCn2XHY1ZAhxrp7JIOC4ml0etoFab5sVeGCK +XHySYpsY4rer5vP4Y9+SdQKBgQCb3NeNA3aVqWZWE/OakJxxWmMyMbR9o1yCeN9p +zrWVjxls6knGhcAlN69zFpddfPXFFlLZA0o++5iwfMe/XRshVZZhn8FAeE5NbzaO +yLF5AqJ3eFCG7nyU7aP8iyY7uKaZ5/3C+6C8wpuhpK3Ppje9pAopYuSbnWSRn5oY +dARnoQKBgQCR6ENOAsLSQo7vSe20yUYajnq6gigSg76V6J8WZpLegdE2monrdrkS +z50aziJZsWpWSuarDT1FV/qWnYrJfsPueBD/carAEVlfEogY02dDtbyzs8olOogV +41wMog/BDF5IQmi+V2T6SxxGtlb4i73hWyVDNaN0T9lsYN6TpHuwrg== +-----END RSA PRIVATE KEY----- diff --git a/util/crypto/src/rsa/test/private.pk8 b/util/crypto/src/rsa/test/private.pk8 new file mode 100644 index 0000000000000000000000000000000000000000..cbcff402134d76c992c5f3428890105c3025a63b GIT binary patch literal 1218 zcmV;z1U>sOf&{(-0RS)!1_>&LNQUrs4#*Aqyhl|0)hbn0KqZ02h53_ za>R&#&CP0Txi)jxVm zY+ZD~m%G;-HeOEX1TS>I5y3lnam_!g_V#LUoB>KU#Uq?M-D)bGDA`8Mz^;2FtpR*1 z7!=4K-#-VUUCzL*-w%QwpNBewL>Nj|e((=W<&A9V_mRfcs{@>Ll|Aqq1U4$sbq+Wj z&mEZ~buYJVYPLSyzy#%(JTRZp_h9pmR{}1|-EgdyPP#(UkO{1)IRXO#009Dm0RU0n z{GP0OK0PyZ!aMMNvD3B!Us_ ze7gSsD51VNcHY9sm&bRhGMh~gvbHyh@3X1LsLj!(b&FN`(INHl)->tw7kjRBoaPlj zzLcF(`8ARuQ6RiDySn``r^+o(It`e%iYZFQenb5L7IDU!(s~z;9M`-ZB zjn7dkkcKU_^6fT3up~uC&s^+~S@q?TCEOrnR+BEhXTz!(x@xMUn$;pym~`?+=#QE+ ze*HJg(x7$7v%|dhO#tTTWr+%7da&lq@+@6D3KdATl1o{G?vi0eK2?Kp;gte`fdKrU z`bIao`2Sy}{J4vlzxcR3Ai`@0?vJ2NME;fdIqCc|rd>jOpvXSI~cgstjAo{!9ik)Q=D1 zRlP4Qd3Va08K3@vkVDCKgTgSyO!E$v9sDl#3XD?CP(@(TlhA@jbNbaccxxMCveG(` zoT7T@SVs1zI?&#k>bR$8ItGV9G7o~{HMV=c4*k-(CC7B`7OYM#q!PjGmar20fdc}8 zfF6O14RfhSf9XHx%7T(QxaIpxw2hb5N~Vh5S6+kq?0%j5~)F*HJN ztj7^(jU(-DGnAoCf`N~I@M_!(*SDJCqs({+Z3@XVU7&<1_FQ%~WC(Gtp2;BKxSCxa zwt-r2n-zFqid=k>Vw)J^x2xv!_+#IabpnBb0Gr&`jRSU-sb*Fa^O}&HaavW7 zT!MJtY0kBkj~Q(0Nydf1B{#2g7MERo^~Dxa*#k;G`xfj0-|?#P=@Y&l0ondAf&n5h4F(A+hDe6@4FLfG1potr0S^E$f&mHwf&l>l!7;Z7%!!=k8x>Ag zNnI6q&@vSZQ(KfNXnX-I1bg@OYA=)68QixPrs*oblVmMg>$!@9z2MML3jx_|YI$ed zO4*$&YdiZkA->(us#5OIk{o41bSFYg zyVo2xUQXx)FLb{V!8>?y%|EO5_G)mP0ZKN-Bb+"] + +[dependencies] +app_dirs = { git = "https://github.com/NervosFoundation/app-dirs-rs.git" } diff --git a/util/dir/src/lib.rs b/util/dir/src/lib.rs new file mode 100644 index 0000000000..6f08f28741 --- /dev/null +++ b/util/dir/src/lib.rs @@ -0,0 +1,72 @@ +extern crate app_dirs; + +use app_dirs::{get_app_root, AppDataType, AppInfo}; +use std::{env, fs, io}; +use std::path::{Path, PathBuf}; + +const APP_INFO: AppInfo = AppInfo { + name: "nervos", + author: "Nervos Dev", +}; + +#[derive(Debug, PartialEq, Clone)] +pub struct Directories { + /// Base dir + pub base: PathBuf, + /// Database dir + pub db: PathBuf, + /// Dir to store keys + pub keys: PathBuf, + /// Signer dir + pub signer: PathBuf, +} + +impl Default for Directories { + fn default() -> Self { + let base = default_base_path(); + Directories::new(&base) + } +} + +impl Directories { + pub fn new>(base: P) -> Self { + let base = base.as_ref().to_path_buf(); + let db = base.join("db"); + let keys = base.join("keys"); + let signer = base.join("signer"); + Directories { + base, + db, + keys, + signer, + } + } + + pub fn create_dirs(&self) -> io::Result<()> { + fs::create_dir_all(&self.base)?; + fs::create_dir_all(&self.db)?; + fs::create_dir_all(&self.keys)?; + fs::create_dir_all(&self.signer)?; + Ok(()) + } +} + +/// Default data path +pub fn default_base_path() -> PathBuf { + get_app_root(AppDataType::UserData, &APP_INFO).unwrap_or_else(|_| home().join(".nervos")) +} + +/// Get home directory. +fn home() -> PathBuf { + env::home_dir().expect("Failed to get home dir") +} + +#[cfg(test)] +mod tests { + use super::default_base_path; + + #[test] + fn test_default_base_path() { + println!("{:?}", default_base_path()); + } +} From 1df0e153239cf9f208a9984e42a2ae8131c2dcd7 Mon Sep 17 00:00:00 2001 From: Ian Yang Date: Tue, 20 Mar 2018 20:36:41 +0800 Subject: [PATCH 06/14] doc(README): Add homepage link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c7b4dc54aa..9084383cff 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# [Nervos CKB]() - The Common Knowledge Base +# [Nervos CKB](http://nervos.org) - The Common Knowledge Base [![TravisCI](https://travis-ci.com/NervosFoundation/nervos.svg?token=y9uR6ygmT3geQaMJ4jpJ&branch=develop)](https://travis-ci.com/NervosFoundation/nervos) From 87008efb6835d846ae62078fba8e4f4d25a1b29d Mon Sep 17 00:00:00 2001 From: zhangsoledad <787953403@qq.com> Date: Tue, 20 Mar 2018 16:46:30 +0800 Subject: [PATCH 07/14] feat: Add sub command signer --- Cargo.lock | 478 +++++++++++++++++++------------- Cargo.toml | 3 +- core/src/block.rs | 6 +- core/src/proof.rs | 40 +-- pool/src/lib.rs | 5 +- src/cli/app.yml | 8 +- src/cli/helper.rs | 21 ++ src/cli/mod.rs | 8 + src/cli/signer.rs | 29 ++ src/main.rs | 3 +- util/crypto/src/secp/privkey.rs | 8 +- util/crypto/src/secp/pubkey.rs | 8 +- 12 files changed, 389 insertions(+), 228 deletions(-) create mode 100644 src/cli/helper.rs diff --git a/Cargo.lock b/Cargo.lock index cb9ce0c42b..40905f3362 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,6 +43,14 @@ dependencies = [ "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "aster" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "atty" version = "0.2.6" @@ -138,11 +146,36 @@ dependencies = [ "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "bindgen" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cexpr 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "clang-sys 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi_codegen 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bitflags" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "bitflags" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "bitflags" version = "0.9.1" @@ -165,12 +198,17 @@ dependencies = [ [[package]] name = "bls" version = "0.1.0" -source = "git+https://github.com/NervosFoundation/bls-rs.git#44d332666e6fd4688f705139732c810e3e76fc8c" +source = "git+https://github.com/NervosFoundation/bls-rs.git#30df0ce9d60a55978a75d5a6d2375c7e2ee727cc" dependencies = [ "cc 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "bs58" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "byte-tools" version = "0.2.0" @@ -208,6 +246,14 @@ dependencies = [ "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cexpr" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cfg-if" version = "0.1.2" @@ -215,11 +261,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chashmap" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "2.2.1" +source = "git+https://github.com/redox-os/tfs#3e7dcdb0c586d0d8bb3f25bfd948d2f418a4ab10" dependencies = [ - "owning_ref 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -241,9 +287,19 @@ dependencies = [ "multihash 0.7.0 (git+https://github.com/tomaka/rust-multihash?branch=emscripten-hack)", ] +[[package]] +name = "clang-sys" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "libloading 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "clap" -version = "2.31.1" +version = "2.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -362,10 +418,10 @@ dependencies = [ [[package]] name = "datastore" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "base64 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "chashmap 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "chashmap 2.2.1 (git+https://github.com/redox-os/tfs)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -416,14 +472,6 @@ name = "either" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "elastic-array" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "env_logger" version = "0.4.3" @@ -534,8 +582,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures-mutex" -version = "0.2.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +version = "0.3.0" +source = "git+https://github.com/paritytech/futures-mutex#18ca11258512a1846826bc83782e538ac692d990" dependencies = [ "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -545,9 +593,6 @@ dependencies = [ name = "gcc" version = "0.3.54" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "generic-array" @@ -557,11 +602,6 @@ dependencies = [ "typenum 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "getopts" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "glob" version = "0.2.11" @@ -642,11 +682,6 @@ name = "integer-encoding" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "interleaved-ordered" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "iovec" version = "0.1.2" @@ -670,30 +705,6 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "kvdb" -version = "0.1.0" -dependencies = [ - "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "kvdb-rocksdb" -version = "0.1.0" -dependencies = [ - "bigint 0.2.3", - "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb 0.1.0", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)", - "tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "language-tags" version = "0.2.2" @@ -719,15 +730,25 @@ name = "libc" version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "libloading" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "libp2p-peerstore" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ - "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "datastore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", "multihash 0.7.0 (git+https://github.com/tomaka/rust-multihash?branch=emscripten-hack)", "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", @@ -737,13 +758,14 @@ dependencies = [ [[package]] name = "libp2p-ping" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", - "multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", + "multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -752,16 +774,17 @@ dependencies = [ [[package]] name = "libp2p-secio" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.12.1 (git+https://github.com/briansmith/ring?rev=3a14ef619559f7d4b69e2286d49c833409eef34a)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -769,13 +792,14 @@ dependencies = [ [[package]] name = "libp2p-swarm" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", - "multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", + "multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -784,11 +808,12 @@ dependencies = [ [[package]] name = "libp2p-tcp-transport" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -796,27 +821,34 @@ dependencies = [ [[package]] name = "libp2p-websocket" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", - "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", + "rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "stdweb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "local-encoding" -version = "0.2.0" +name = "librocksdb-sys" +version = "5.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "skeptic 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "bindgen 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "make-cmd 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "linked-hash-map" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "log" version = "0.3.9" @@ -849,6 +881,19 @@ dependencies = [ "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lru-cache" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "make-cmd" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "matches" version = "0.1.6" @@ -883,6 +928,14 @@ dependencies = [ "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "memchr" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "memchr" version = "2.0.1" @@ -949,7 +1002,7 @@ dependencies = [ [[package]] name = "multiaddr" version = "0.2.0" -source = "git+https://github.com/libp2p/rust-libp2p#9faf3fae299b567a9a1b5e33edaba721adcf01ef" +source = "git+https://github.com/multiformats/rust-multiaddr#cc39c90fdde4d0b0ec24ee887fcd62a1bec67677" dependencies = [ "byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "cid 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -982,32 +1035,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "multiplex" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-mutex 0.2.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "futures-mutex 0.3.0 (git+https://github.com/paritytech/futures-mutex)", + "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "num-bigint 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", ] [[package]] name = "multistream-select" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", ] [[package]] @@ -1029,7 +1082,8 @@ name = "nervos" version = "0.1.0" dependencies = [ "bigint 0.2.3", - "clap 2.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bls 0.1.0 (git+https://github.com/NervosFoundation/bls-rs.git)", + "clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)", "crypto 0.1.0", "ctrlc 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "dir 0.1.0", @@ -1075,8 +1129,6 @@ dependencies = [ "bls 0.1.0 (git+https://github.com/NervosFoundation/bls-rs.git)", "crypto 0.1.0", "hash 0.1.0", - "kvdb 0.1.0", - "kvdb-rocksdb 0.1.0", "merkle-root 0.1.0", "nervos-time 0.1.0", "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1087,10 +1139,15 @@ dependencies = [ name = "nervos-db" version = "0.1.0" dependencies = [ + "bigint 0.2.3", "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nervos-core 0.1.0", "nervos-util 0.1.0", + "rocksdb 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1101,6 +1158,7 @@ dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "nervos-chain 0.1.0", "nervos-core 0.1.0", + "nervos-db 0.1.0", "nervos-pool 0.1.0", "nervos-time 0.1.0", ] @@ -1114,17 +1172,17 @@ dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "libp2p-secio 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "libp2p-tcp-transport 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", - "libp2p-websocket 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "libp2p-peerstore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-ping 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-secio 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-tcp-transport 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-websocket 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mdns-discover 0.2.0 (git+https://github.com/NervosFoundation/rust-mdns-discover)", "mdns-responder 0.2.0 (git+https://github.com/NervosFoundation/rust-mdns-responder)", - "multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)", - "multiplex 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", + "multiplex 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", "nervos-core 0.1.0", "nervos-util 0.1.0", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1134,7 +1192,7 @@ dependencies = [ "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)", + "varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", ] [[package]] @@ -1196,6 +1254,14 @@ name = "nodrop" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "nom" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "num" version = "0.1.42" @@ -1299,11 +1365,6 @@ dependencies = [ "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "owning_ref" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "owning_ref" version = "0.3.3" @@ -1312,16 +1373,6 @@ dependencies = [ "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "parking_lot" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "owning_ref 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "thread-id 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "parking_lot" version = "0.4.8" @@ -1351,6 +1402,11 @@ dependencies = [ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "percent-encoding" version = "1.0.1" @@ -1382,11 +1438,23 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "pulldown-cmark" -version = "0.0.3" +name = "quasi" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quasi_codegen" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1419,14 +1487,6 @@ dependencies = [ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rayon" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rayon" version = "0.9.0" @@ -1510,23 +1570,11 @@ dependencies = [ [[package]] name = "rocksdb" -version = "0.4.5" -source = "git+https://github.com/paritytech/rust-rocksdb#ecf06adf3148ab10f6f7686b724498382ff4f36e" -dependencies = [ - "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "local-encoding 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rocksdb-sys 0.3.0 (git+https://github.com/paritytech/rust-rocksdb)", -] - -[[package]] -name = "rocksdb-sys" -version = "0.3.0" -source = "git+https://github.com/paritytech/rust-rocksdb#ecf06adf3148ab10f6f7686b724498382ff4f36e" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "local-encoding 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "snappy-sys 0.1.0 (git+https://github.com/paritytech/rust-snappy)", + "librocksdb-sys 5.11.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1567,7 +1615,7 @@ dependencies = [ [[package]] name = "rw-stream-sink" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1706,15 +1754,6 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "skeptic" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "pulldown-cmark 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "slab" version = "0.3.0" @@ -1743,15 +1782,6 @@ name = "smallvec" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "snappy-sys" -version = "0.1.0" -source = "git+https://github.com/paritytech/rust-snappy#858eac97192ea25d18d3f3626a8cc13ca0b175bb" -dependencies = [ - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "stable_deref_trait" version = "1.0.0" @@ -1794,6 +1824,48 @@ dependencies = [ "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syntex" +version = "0.58.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syntex_errors" +version = "0.58.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syntex_pos" +version = "0.58.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syntex_syntax" +version = "0.58.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tempdir" version = "0.3.6" @@ -1834,6 +1906,15 @@ dependencies = [ "url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "term" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "termcolor" version = "0.3.5" @@ -1860,16 +1941,6 @@ dependencies = [ "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "thread-id" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "thread_local" version = "0.3.5" @@ -2034,7 +2105,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "varint" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=kademlia#b0517240e3600032085b80fc96b17b637d048834" +source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2148,6 +2219,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum app_dirs 1.1.1 (git+https://github.com/NervosFoundation/app-dirs-rs.git)" = "" "checksum arrayref 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0fd1479b7c29641adbd35ff3b5c293922d696a92f25c8c975da3e0acbc87258f" "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" +"checksum aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfdf7355d9db158df68f976ed030ab0f6578af811f5a7bb6dcf221ec24e0e0" "checksum atty 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8352656fd42c30a0c3c89d26dea01e3b77c0ab2af18230835c15e2e13cd51859" "checksum backtrace 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbbf59b1c43eefa8c3ede390fcc36820b4999f7914104015be25025e0d62af2" "checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661" @@ -2157,22 +2229,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96434f987501f0ed4eb336a411e0631ecd1afa11574fe148587adc4ff96143c9" "checksum base64 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5032d51da2741729bfdaeb2664d9b8c6d9fd1e2b90715c660b6def36628499c2" "checksum bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bda13183df33055cbb84b847becce220d392df502ebe7a4a78d7021771ed94d0" +"checksum bindgen 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ba610cba0c1727ed837316540068b51349b8268c073906067b7c3948598929bd" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" +"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" "checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab" "checksum bls 0.1.0 (git+https://github.com/NervosFoundation/bls-rs.git)" = "" +"checksum bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e6ea4851598d7433fbdba71fa2509d9b0df68124b9c0effe7588f5149692d9f" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" "checksum byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96c8b41881888cc08af32d47ac4edd52bc7fa27fef774be47a92443756451304" "checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" "checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23" "checksum bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1b7db437d718977f6dc9b2e3fd6fc343c02ac6b899b73fdd2179163447bd9ce9" "checksum cc 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "87f38f122db5615319a985757e526c00161d924d19b71a0f3e80c52bab1adcf6" +"checksum cexpr 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42aac45e9567d97474a834efdee3081b3c942b2205be932092f53354ce503d6c" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" -"checksum chashmap 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "47e651a8c1eb0cbbaa730f705e2531e75276c6f2bbe2eb12662cfd305213dff8" +"checksum chashmap 2.2.1 (git+https://github.com/redox-os/tfs)" = "" "checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9" "checksum cid 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d85ee025368e69063c420cbb2ed9f852cb03a5e69b73be021e65726ce03585b6" -"checksum clap 2.31.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dc18f6f4005132120d9711636b32c46a233fad94df6217fa1d81c5e97a9f200" +"checksum clang-sys 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e414af9726e1d11660801e73ccc7fb81803fb5f49e5903a25b348b2b3b480d2e" +"checksum clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f16b89cbb9ee36d87483dc939fe9f1e13c05898d56d7b230a0d4dff033a536" "checksum core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25bfd746d203017f7d5cbd31ee5d8e17f94b6521c7af77ece6c9e4b2d4b16c67" "checksum core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "065a5d7ffdcbc8fa145d6f0746f3555025b9097a9e9cda59f7467abae670c78d" "checksum crossbeam-channel 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9d7b07a3084d8718d95338443d5a46aab38ce16d5f991d4027a0906b369f70a3" @@ -2182,13 +2259,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" "checksum ctrlc 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "653abc99aa905f693d89df4797fadc08085baee379db92be9f2496cefe8a6f2c" -"checksum datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum datastore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" "checksum digest 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "00a49051fef47a72c9623101b19bd71924a45cca838826caae3eaa4d00772603" "checksum dns-parser 0.3.2 (git+https://github.com/plietar/dns-parser)" = "" "checksum dns-parser 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7020f6760aea312d43d23cb83bf6c0c49f162541db8b02bf95209ac51dc253d" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" "checksum either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "740178ddf48b1a9e878e6d6509a1442a2d42fd2928aae8e7a6f8a36fb01981b3" -"checksum elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "258ff6a9a94f648d0379dbd79110e057edbb53eb85cc237e33eadf8e5a30df85" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum env_logger 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f0628f04f7c26ebccf40d7fc2c1cf92236c05ec88cf2132641cc956812312f0f" "checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" @@ -2202,10 +2278,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0bab5b5e94f5c31fc764ba5dd9ad16568aae5d4825538c01d6bca680c9bf94a7" -"checksum futures-mutex 0.2.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum futures-mutex 0.3.0 (git+https://github.com/paritytech/futures-mutex)" = "" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" -"checksum getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "b900c08c1939860ce8b54dc6a89e26e00c04c380fd0e09796799bd7f12861e05" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2f407128745b78abc95c0ffbe4e5d37427fdc0d45470710cfef8c44522a2e37" @@ -2215,7 +2290,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum ifaces 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa5cce6b4cae6792378aefb34152be19600949dde0041e7910430022f94b81f1" "checksum integer-encoding 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26746cbc2e680af687e88d717f20ff90079bd10fc984ad57d277cd0e37309fa5" -"checksum interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141340095b15ed7491bd3d4ced9d20cebfb826174b6bb03386381f62b01e3d77" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" @@ -2224,35 +2298,41 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" "checksum lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef" "checksum libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "1e5d97d6708edaa407429faa671b942dc0f2727222fb6b6539bf1db936e4b121" -"checksum libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" -"checksum libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" -"checksum libp2p-secio 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" -"checksum libp2p-swarm 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" -"checksum libp2p-tcp-transport 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" -"checksum libp2p-websocket 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" -"checksum local-encoding 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1ceb20f39ff7ae42f3ff9795f3986b1daad821caaa1e1732a0944103a5a1a66" +"checksum libloading 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fd38073de8f7965d0c17d30546d4bb6da311ab428d1c7a3fc71dff7f9d4979b9" +"checksum libp2p-peerstore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum libp2p-ping 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum libp2p-secio 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum libp2p-tcp-transport 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum libp2p-websocket 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum librocksdb-sys 5.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0fa7f4ca5ceff76237db63802cb073d84e64a327e38478e79a669093fb7fa5" +"checksum linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7860ec297f7008ff7a1e3382d7f7e1dcd69efc94751a2284bafc3d013c2aa939" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" +"checksum lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4d06ff7ff06f729ce5f4e227876cb88d10bc59cd4ae1e09fbb2bde15c850dc21" +"checksum make-cmd 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8ca8afbe8af1785e09636acb5a41e08a765f5f0340568716c18a8700ba3c0d3" "checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376" "checksum mdns-discover 0.2.0 (git+https://github.com/NervosFoundation/rust-mdns-discover)" = "" "checksum mdns-responder 0.2.0 (git+https://github.com/NervosFoundation/rust-mdns-responder)" = "" +"checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum memoffset 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e163e5baece1a039e71e75b074de17a9b4114982aa109921fc20253bdf91a53c" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" "checksum mio 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "7da01a5e23070d92d99b1ecd1cd0af36447c6fd44b0fe283c2db199fa136724f" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum multiaddr 0.2.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)" = "" "checksum multibase 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b9c35dac080fd6e16a99924c8dfdef0af89d797dd851adab25feaffacf7850d6" "checksum multihash 0.7.0 (git+https://github.com/tomaka/rust-multihash?branch=emscripten-hack)" = "" "checksum multimap 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9223f4774d08e06185e44e555b9a7561243d387bac49c78a6205c42d6975fbf2" -"checksum multiplex 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" -"checksum multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum multiplex 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" "checksum native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f74dbadc8b43df7864539cedb7bc91345e532fdd913cfdc23ad94f4d2d40fbc0" "checksum net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "3a80f842784ef6c9a958b68b7516bc7e35883c614004dd94959a4dca1b716c09" "checksum nix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "47e49f6982987135c5e9620ab317623e723bd06738fd85377e8d55f57c8b6487" "checksum nix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2c5afeb0198ec7be8569d666644b574345aad2e95a53baf3a532da3e0f3fb32" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" +"checksum nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05aec50c70fd288702bcd93284a8444607f3292dbdf2a30de5ea5dcdbe72287b" "checksum num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e" "checksum num-bigint 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "81b483ea42927c463e191802e7334556b48e7875297564c0e9951bd3a0ae53e3" "checksum num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f8d26da319fb45674985c78f1d1caf99aa4941f785d384a2ae36d0740bc3e2fe" @@ -2264,23 +2344,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum openssl 0.10.3 (git+https://github.com/NervosFoundation/rust-openssl.git?branch=pkcs8_der)" = "" "checksum openssl 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "a3605c298474a3aa69de92d21139fb5e2a81688d308262359d85cdd0d12a7985" "checksum openssl-sys 0.9.26 (git+https://github.com/NervosFoundation/rust-openssl.git?branch=pkcs8_der)" = "" -"checksum owning_ref 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9d52571ddcb42e9c900c901a18d8d67e393df723fcd51dd59c5b1a85d0acb6cc" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" -"checksum parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "fa12d706797d42551663426a45e2db2e0364bd1dbf6aeada87e89c5f981f43e9" "checksum parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "149d8f5b97f3c1133e3cfcd8886449959e856b557ff281e292b733d7c69e005e" "checksum parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9fd9d732f2de194336fb02fe11f9eed13d9e76f13f4315b4d88a14ca411750cd" "checksum parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "538ef00b7317875071d5e00f603f24d16f0b474c1a5fc0ccb8b454ca72eafa79" +"checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pest 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0fce5d8b5cc33983fc74f78ad552b5522ab41442c4ca91606e4236eb4b5ceefc" "checksum pest_derive 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6453faedc5c9980a3c278f28b1df33344a79cc6d4a2fd96e2b56288374dc822a" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" "checksum protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bec26e67194b7d991908145fdf21b7cae8b08423d96dcb9e860cd31f854b9506" -"checksum pulldown-cmark 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8361e81576d2e02643b04950e487ec172b687180da65c731c03cf336784e6c07" +"checksum quasi 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18c45c4854d6d1cf5d531db97c75880feb91c958b0720f4ec1057135fec358b3" +"checksum quasi_codegen 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9e25fa23c044c1803f43ca59c98dac608976dd04ce799411edd58ece776d4" "checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" -"checksum rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b614fe08b6665cb9a231d07ac1364b0ef3cb3698f1239ee0c4c3a88a524f54c8" "checksum rayon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed02d09394c94ffbdfdc755ad62a132e94c3224a8354e78a1200ced34df12edf" "checksum rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "485541959c8ecc49865526fe6c4de9653dd6e60d829d6edf0be228167b60372d" "checksum rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d24ad214285a7729b174ed6d3bcfcb80177807f959d95fafd5bfc5c4f201ac8" @@ -2290,14 +2369,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e" "checksum remove_dir_all 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b5d2f806b0fcdabd98acd380dc8daef485e22bcb7cddc811d1337967f2528cf5" "checksum ring 0.12.1 (git+https://github.com/briansmith/ring?rev=3a14ef619559f7d4b69e2286d49c833409eef34a)" = "" -"checksum rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)" = "" -"checksum rocksdb-sys 0.3.0 (git+https://github.com/paritytech/rust-rocksdb)" = "" +"checksum rocksdb 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41eb461abed4e4f2b3f9a852b38f9cb2ef25ae866a3e8fa827fbe4a7d8dc42c3" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" "checksum rustc-demangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11fb43a206a04116ffd7cfcf9bcb941f8eb6cc7ff667272246b0a1c74259a3cb" "checksum rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ceb8ce7a5e520de349e1fa172baeba4a9e8d5ef06c47471863530bc4972ee1e" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" -"checksum rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" "checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" "checksum schannel 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "acece75e0f987c48863a6c792ec8b7d6c4177d4a027f8ccc72f849794f437016" "checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d" @@ -2315,26 +2393,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum sha1 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "171698ce4ec7cbb93babeb3190021b4d72e96ccb98e33d277ae4ea959d6f2d9e" "checksum sha2 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7daca11f2fdb8559c4f6c588386bed5e2ad4b6605c1442935a7f08144a918688" "checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" -"checksum skeptic 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24ebf8a06f5f8bae61ae5bbc7af7aac4ef6907ae975130faba1199e5fe82256a" "checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" "checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d" "checksum slug 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f5ff4b43cb07b86c5f9236c92714a22cdf9e5a27a7d85e398e2c9403328cb8" "checksum smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "872c0ff227000041c520cca51e883b858d388ab0ecf646bab76f065cebaec025" "checksum smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44db0ecb22921ef790d17ae13a3f6d15784183ff5f2a01aa32098c7498d2b4b9" -"checksum snappy-sys 0.1.0 (git+https://github.com/paritytech/rust-snappy)" = "" "checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b" "checksum stdweb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef5430c8e36b713e13b48a9f709cc21e046723fe44ce34587b73a830203b533e" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" +"checksum syntex 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a8f5e3aaa79319573d19938ea38d068056b826db9883a5d47f86c1cecc688f0e" +"checksum syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "867cc5c2d7140ae7eaad2ae9e8bf39cb18a67ca651b7834f88d46ca98faadb9c" +"checksum syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13ad4762fe52abc9f4008e85c4fb1b1fe3aa91ccb99ff4826a439c7c598e1047" +"checksum syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6e0e4dbae163dd98989464c23dd503161b338790640e11537686f2ef0f25c791" "checksum tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f73eebdb68c14bcb24aef74ea96079830e7fa7b31a6106e42ea7ee887c1e134e" "checksum tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11ce2fe9db64b842314052e2421ac61a73ce41b898dc8e3750398b219c5fc1e0" "checksum tera 0.11.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fc1a35d04c2444875b1319293fbc72c00215ae6220f8c70f9f14fefa5eaae0c6" +"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" "checksum termcolor 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "56c456352e44f9f91f774ddeeed27c1ec60a2455ed66d692059acfb1d731bda1" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693" -"checksum thread-id 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2af4d6289a69a35c4d3aea737add39685f2784122c28119a7713165a63d68c9d" "checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" "checksum time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a15375f1df02096fb3317256ce2cee6a1f42fc84ea5ad5fc8c421cfe40c73098" "checksum tiny-keccak 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "58911ed5eb275a8fd2f1f0418ed360a42f59329864b64e1e95377a9024498c01" @@ -2355,7 +2435,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum untrusted 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70afa43c8c5d23a53a3c39ec9b56232c5badc19f6bb5ad529c1d6448a7241365" "checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" -"checksum varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=kademlia)" = "" +"checksum varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" "checksum vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9e0a7d8bed3178a8fb112199d466eeca9ed09a14ba8ad67718179b4fd5487d0b" "checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c" "checksum version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6b772017e347561807c1aa192438c5fd74242a670a6cffacc40f2defd1dc069d" diff --git a/Cargo.toml b/Cargo.toml index 67b9485b67..cdc1ba1f3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,10 +20,11 @@ nervos-time = { path = "util/time"} logger = { path = "util/logger" } bigint = { path = "util/bigint" } dir = { path = "util/dir" } -crypto = { path = "util/crypto", features = ["rsa"] } +crypto = { path = "util/crypto", features = ["rsa", "secp"] } ctrlc = { version = "3.1", features = ["termination"] } tera = "0.11" lazy_static = "1.0" +bls = { git = "https://github.com/NervosFoundation/bls-rs.git" } # The [patch] sections in Cargo.toml are only recognized in the root crate's manifest [patch.crates-io] diff --git a/core/src/block.rs b/core/src/block.rs index 01fb931abd..c7cf012c4a 100644 --- a/core/src/block.rs +++ b/core/src/block.rs @@ -124,9 +124,9 @@ impl Header { } // check proof - pub fn check_proof(&self, pubkey: ProofPublickey, g: ProofPublicG) -> Result<(), Error> { + pub fn check_proof(&self, pubkey: &ProofPublickey, g: &ProofPublicG) -> Result<(), Error> { if self.proof - .verify(self.timestamp, self.height, self.challenge, pubkey, g) + .verify(self.timestamp, self.height, &self.challenge, pubkey, g) { Ok(()) } else { @@ -154,7 +154,7 @@ impl Block { let pubkey = self.header.recover_pubkey()?; let (key, g) = kg.get(&pubkey) .ok_or_else(|| Error::InvalidPublicKey(pubkey))?; - self.header.check_proof(key, g)?; + self.header.check_proof(&key, &g)?; Ok(()) } diff --git a/core/src/proof.rs b/core/src/proof.rs index 9bde15cfd3..60f48eca4e 100644 --- a/core/src/proof.rs +++ b/core/src/proof.rs @@ -1,5 +1,5 @@ use super::{ProofPublicG, ProofPublickey}; -use bigint::{H256, U256}; +use bigint::{H160, H256, U256}; use bls; use difficulty::boundary_to_difficulty; use global::TIME_STEP; @@ -7,49 +7,55 @@ use hash::{Sha3, sha3_256}; #[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)] pub struct Proof { - pub sig: Vec, + pub sig: [u8; 21], } impl Proof { // generate proof - pub fn new(private_key: &[u8], time: u64, height: u64, challenge: &H256) -> Proof { + pub fn new(private_key: &H160, time: u64, height: u64, challenge: &H256) -> Proof { let mut hash = [0u8; 32]; - let h1 = H256::from(time / TIME_STEP).to_vec(); - let h2 = H256::from(height).to_vec(); - let h3 = challenge.to_vec(); + let h1 = H256::from(time / TIME_STEP); + let h2 = H256::from(height); + let h3 = challenge; let mut sha3 = Sha3::new_sha3_256(); sha3.update(&h1); sha3.update(&h2); - sha3.update(&h3); + sha3.update(h3); sha3.finalize(&mut hash); Proof { - sig: bls::sign(hash.to_vec(), private_key.to_vec()), + sig: bls::sign(&hash, &private_key.0), } } + pub fn from_slice(src: &[u8]) -> Proof { + let mut sig = [0u8; 21]; + sig.clone_from_slice(src); + Proof { sig } + } + /// verify the proof. pub fn verify( &self, time: u64, height: u64, - challenge: H256, - pubkey: ProofPublickey, - g: ProofPublicG, + challenge: &H256, + pubkey: &ProofPublickey, + g: &ProofPublicG, ) -> bool { let mut hash = [0u8; 32]; - let h1 = H256::from(time / TIME_STEP).to_vec(); - let h2 = H256::from(height).to_vec(); - let h3 = challenge.to_vec(); + let h1 = H256::from(time / TIME_STEP); + let h2 = H256::from(height); + let h3 = challenge; let mut sha3 = Sha3::new_sha3_256(); sha3.update(&h1); sha3.update(&h2); - sha3.update(&h3); + sha3.update(h3); sha3.finalize(&mut hash); - bls::verify(hash.to_vec(), self.sig.clone(), pubkey.to_vec(), g.to_vec()) + bls::verify(&hash, &self.sig, &pubkey.0, &g.0) } pub fn hash(&self) -> H256 { - sha3_256(self.sig.as_slice()).into() + sha3_256(&self.sig).into() } /// Get difficulty diff --git a/pool/src/lib.rs b/pool/src/lib.rs index e44f7fde91..48bfa86546 100644 --- a/pool/src/lib.rs +++ b/pool/src/lib.rs @@ -67,10 +67,9 @@ impl OrphanBlockPool { pub fn remove_block(&self, h: &H256) -> Vec { if let Some(blocks) = self.pool.write().remove(h) { let mut hashes = self.hashes.write(); - for b in blocks.clone() { + for b in &blocks { hashes.remove(&b.hash()); } - blocks } else { Vec::new() @@ -114,7 +113,7 @@ impl PendingBlockPool { *self.pool.write() = lt; let mut hashes = self.hashes.write(); - for b in bt.clone() { + for b in &bt { hashes.remove(&b.hash()); } bt diff --git a/src/cli/app.yml b/src/cli/app.yml index dc1bf797b1..af8310f93e 100644 --- a/src/cli/app.yml +++ b/src/cli/app.yml @@ -11,6 +11,10 @@ args: takes_value: true subcommands: - run: + version: "0.1.0" about: run - - new: - about: init data dir + - signer: + version: "0.1.0" + subcommands: + - new: + about: generate new signer diff --git a/src/cli/helper.rs b/src/cli/helper.rs new file mode 100644 index 0000000000..58c75d5717 --- /dev/null +++ b/src/cli/helper.rs @@ -0,0 +1,21 @@ +use std::fmt; + +pub struct HexSlice<'a>(&'a [u8]); + +impl<'a> HexSlice<'a> { + pub fn new(data: &'a T) -> HexSlice<'a> + where + T: ?Sized + AsRef<[u8]> + 'a, + { + HexSlice(data.as_ref()) + } +} + +impl<'a> fmt::Display for HexSlice<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + for byte in self.0 { + write!(f, "{:x}", byte)?; + } + Ok(()) + } +} diff --git a/src/cli/mod.rs b/src/cli/mod.rs index fbb853825e..1c23c0dd03 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -1,3 +1,4 @@ +mod helper; mod rsa; mod run_impl; mod signer; @@ -8,3 +9,10 @@ pub use self::run_impl::run; pub use self::signer::Signer; pub use self::spec::Spec; pub use self::template::{Templates, TemplatesExt, TEMPLATES}; +use clap::ArgMatches; + +pub fn signer_cmd(matches: &ArgMatches) { + if let Some(_matches) = matches.subcommand_matches("new") { + Signer::gen_and_print(); + } +} diff --git a/src/cli/signer.rs b/src/cli/signer.rs index 89be043de6..2b5eb36616 100644 --- a/src/cli/signer.rs +++ b/src/cli/signer.rs @@ -1,6 +1,9 @@ +use super::helper::HexSlice; use super::template::{TemplatesExt, TEMPLATES}; use bigint::{H160, H256}; +use bls; use core::{ProofPublicG, ProofPublickey, PublicKey}; +use crypto::secp::Generator; use std::fs::{File, OpenOptions}; use std::io::{self, BufReader, Read, Write}; use std::path::Path; @@ -20,6 +23,32 @@ pub struct Signer { pub key_pairs: Vec, } +impl Signer { + // temporary + pub fn gen_and_print() { + let (miner_private_key, proof_public_key, proof_public_g) = bls::key_gen(); + + let gen = Generator::new(); + let (signer_private_key, signer_public_key) = gen.random_keypair() + .expect("Generate random secp256k1 keypair"); + + println!( + "miner_private_key: 0x{}", + HexSlice::new(&miner_private_key[..]) + ); + println!( + "proof_public_key: 0x{}", + HexSlice::new(&proof_public_key[..]) + ); + println!( + "proof_public_g: 0x{}", + HexSlice::new(&proof_public_g[..]) + ); + println!("signer_private_key: 0x{}", signer_private_key); + println!("signer_public_key: 0x{}", signer_public_key); + } +} + impl Default for Signer { fn default() -> Self { use std::str::FromStr; diff --git a/src/main.rs b/src/main.rs index 80459412b4..bac27bad38 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ extern crate bigint; +extern crate bls; #[macro_use] extern crate clap; extern crate crypto; @@ -43,7 +44,7 @@ fn main() { ("run", Some(_run_cmd)) => { cli::run(config); } - ("new", Some(_new_cmd)) => {} + ("signer", Some(signer_matches)) => cli::signer_cmd(signer_matches), _ => { cli::run(config); } diff --git a/util/crypto/src/secp/privkey.rs b/util/crypto/src/secp/privkey.rs index 2a0d11b8e2..5a5f106dc2 100644 --- a/util/crypto/src/secp/privkey.rs +++ b/util/crypto/src/secp/privkey.rs @@ -4,7 +4,7 @@ use super::secp256k1::Message as SecpMessage; use super::secp256k1::key; use super::signature::Signature; use bigint::H256; -use std::ops; +use std::{fmt, ops}; use std::str::FromStr; #[derive(Debug, Eq, PartialEq)] @@ -64,3 +64,9 @@ impl From for Privkey { Privkey { inner: h } } } + +impl fmt::Display for Privkey { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(f, "{:x}", self.inner) + } +} diff --git a/util/crypto/src/secp/pubkey.rs b/util/crypto/src/secp/pubkey.rs index 1dfca16cde..68059d5137 100644 --- a/util/crypto/src/secp/pubkey.rs +++ b/util/crypto/src/secp/pubkey.rs @@ -6,7 +6,7 @@ use super::secp256k1::Message as SecpMessage; use super::secp256k1::key; use super::signature::Signature; use bigint::H512; -use std::ops; +use std::{fmt, ops}; #[derive(Debug, Eq, PartialEq)] pub struct Pubkey { @@ -61,3 +61,9 @@ impl From for Pubkey { pubkey.into() } } + +impl fmt::Display for Pubkey { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(f, "{:x}", self.inner) + } +} From 7433ab135896c333a31a3e8f50744eb8ed4c8d06 Mon Sep 17 00:00:00 2001 From: Ian Yang Date: Tue, 20 Mar 2018 20:41:37 +0800 Subject: [PATCH 08/14] ci(circleci): remove obsoleted circleci config --- .circleci/config.yml | 45 -------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 90199508cb..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: nervos/nervos-build:latest - working_directory: ~/nervos-build - steps: - - checkout - - run: - name: format - command: 'cargo fmt --all -- --write-mode diff' - - run: - name: build - command: 'cargo build' - - save_cache: - key: nervos-build-{{ .Environment.CIRCLE_SHA1 }} - paths: - - ~/nervos-build - - save_cache: - key: deps-{{ checksum "Cargo.lock" }} - paths: - - ~/.cargo - - - basic_test: - docker: - - image: nervos/nervos-build:latest - working_directory: ~/nervos-build - steps: - - restore_cache: - key: nervos-build-{{ .Environment.CIRCLE_SHA1 }} - - restore_cache: - key: deps-{{ checksum "Cargo.lock" }} - - run: - name: test - command: 'cargo test --all' - -workflows: - version: 2 - build-and-test: - jobs: - - build - - basic_test: - requires: - - build From da4327232fd90434103964a95bf7e8e231c9d887 Mon Sep 17 00:00:00 2001 From: ian Date: Tue, 27 Mar 2018 12:26:28 +0800 Subject: [PATCH 09/14] feat(tx): Compact tx inputs and outputs list. Store inputs and outputs in consecutive list. Grouping information is stored separately. --- core/src/transaction.rs | 212 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 208 insertions(+), 4 deletions(-) diff --git a/core/src/transaction.rs b/core/src/transaction.rs index 8ad153d449..0494be440d 100644 --- a/core/src/transaction.rs +++ b/core/src/transaction.rs @@ -3,6 +3,8 @@ use bigint::H256; use bincode::serialize; use hash::sha3_256; +use std::iter::Zip; +use std::slice::Iter; #[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] pub struct OutPoint { @@ -35,16 +37,42 @@ pub struct CellOutput { pub recipient: Option, } +// The cell operations are ordered by group. +// +// In each group, transform inputs are ordered before destroy inputs. And transform outputs are +// ordered before create outputs. +// +// For example, a transaction has inputs i1, i2, i3, outputs o1, o2, o3, o4, 2 groups: +// +// - g1: transform_count = 1, destroy_count = 1, create_count = 2 +// - g2: transform_count = 1, destroy_count = 0, create_count = 0 +// +// Then g1 has operations: +// +// - Transform i1 -> o1 +// - Destroy i2 -> x +// - Create x -> o2 +// - Create x -> o3 +// +// Group g2 has following operations: +// +// - Transform i3 -> o4 #[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] -pub struct CellOperation { - pub input: Option, - pub output: Option, +pub struct OperationGrouping { + pub transform_count: u32, + pub destroy_count: u32, + pub create_count: u32, } #[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] pub struct Transaction { pub version: u32, - pub cell_groups: Vec>, + pub inputs: Vec, + pub outputs: Vec, + + // Number of operations in each group. Sum of the numbers must equal to the size of operations + // list. + pub grouping: Vec, } impl Transaction { @@ -57,3 +85,179 @@ impl Transaction { sha3_256(serialize(self).unwrap()).into() } } + +#[derive(PartialEq, Debug)] +pub struct OperationGroup<'a> { + inputs_slice: &'a [CellInput], + outputs_slice: &'a [CellOutput], + grouping: &'a OperationGrouping, +} + +#[derive(Debug)] +pub struct OperationGroupIter<'a> { + inputs_slice: &'a [CellInput], + outputs_slice: &'a [CellOutput], + grouping_iter: Iter<'a, OperationGrouping>, +} + +impl Transaction { + pub fn group_iter(&self) -> OperationGroupIter { + OperationGroupIter { + inputs_slice: &self.inputs[..], + outputs_slice: &self.outputs[..], + grouping_iter: self.grouping.iter(), + } + } +} + +impl<'a> Iterator for OperationGroupIter<'a> { + type Item = OperationGroup<'a>; + + fn next(&mut self) -> Option { + match self.grouping_iter.next() { + Some(grouping) => { + let consumed_inputs_count = + (grouping.transform_count + grouping.destroy_count) as usize; + let consumed_outputs_count = + (grouping.transform_count + grouping.create_count) as usize; + + let group = OperationGroup { + inputs_slice: &self.inputs_slice[0..consumed_inputs_count], + outputs_slice: &self.outputs_slice[0..consumed_outputs_count], + grouping, + }; + + self.inputs_slice = &self.inputs_slice[consumed_inputs_count..]; + self.outputs_slice = &self.outputs_slice[consumed_outputs_count..]; + + Some(group) + } + None => None, + } + } +} + +impl<'a> OperationGroup<'a> { + pub fn transform_operations(&self) -> Zip, Iter> { + let count = self.grouping.transform_count as usize; + (&self.inputs_slice[0..count]) + .iter() + .zip((&self.outputs_slice[0..count]).iter()) + } + + pub fn destroy_operations(&self) -> Iter { + let start_from = self.grouping.transform_count as usize; + (&self.inputs_slice[start_from..]).iter() + } + + pub fn create_operations(&self) -> Iter { + let start_from = self.grouping.transform_count as usize; + (&self.outputs_slice[start_from..]).iter() + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn build_cell_input(tag: &u8) -> CellInput { + CellInput { + previous_output: OutPoint { + hash: 0.into(), + index: 0, + }, + unlock: vec![*tag], + } + } + + fn build_cell_output(tag: &u8) -> CellOutput { + CellOutput { + module: 0, + capacity: 0, + data: vec![], + lock: vec![*tag], + recipient: None, + } + } + + #[test] + fn empty_group_iter() { + let tx = Transaction { + version: 0, + inputs: Vec::new(), + outputs: Vec::new(), + grouping: Vec::new(), + }; + + let mut iter = tx.group_iter(); + assert_eq!(iter.next(), None); + } + + #[test] + fn group_iter_happy_pass() { + let tx = Transaction { + version: 0, + inputs: [1u8, 2u8, 3u8].into_iter().map(build_cell_input).collect(), + outputs: [1u8, 2u8, 3u8, 4u8] + .into_iter() + .map(build_cell_output) + .collect(), + grouping: vec![ + OperationGrouping { + transform_count: 1, + destroy_count: 1, + create_count: 2, + }, + OperationGrouping { + transform_count: 1, + destroy_count: 0, + create_count: 0, + }, + ], + }; + + let mut iter = tx.group_iter(); + if let Some(group) = iter.next() { + let transform_operations: Vec<(&CellInput, &CellOutput)> = + group.transform_operations().collect(); + let destroy_operations: Vec<&CellInput> = group.destroy_operations().collect(); + let create_operations: Vec<&CellOutput> = group.create_operations().collect(); + + assert_eq!(1, transform_operations.len()); + // i1 -> o1 + assert_eq!(1, transform_operations[0].0.unlock[0]); + assert_eq!(1, transform_operations[0].1.lock[0]); + + assert_eq!(1, destroy_operations.len()); + // i2 -> x + assert_eq!(2, destroy_operations[0].unlock[0]); + + assert_eq!(2, create_operations.len()); + // x -> o2 + assert_eq!(2, create_operations[0].lock[0]); + // x -> o3 + assert_eq!(3, create_operations[1].lock[0]); + } else { + panic!("Expect 2 groups, got 0"); + } + + if let Some(group) = iter.next() { + let transform_operations: Vec<(&CellInput, &CellOutput)> = + group.transform_operations().collect(); + let destroy_operations: Vec<&CellInput> = group.destroy_operations().collect(); + let create_operations: Vec<&CellOutput> = group.create_operations().collect(); + + assert_eq!(1, transform_operations.len()); + // i3 -> o4 + assert_eq!(3, transform_operations[0].0.unlock[0]); + assert_eq!(4, transform_operations[0].1.lock[0]); + + assert_eq!(0, destroy_operations.len()); + assert_eq!(0, create_operations.len()); + } else { + panic!("Expect 2 groups, got 1"); + } + + assert_eq!(iter.next(), None, "Expect 2 groups, got more"); + } +} From 4a58337842eb010e38606799bf85159ba83abe30 Mon Sep 17 00:00:00 2001 From: quake wang Date: Sun, 25 Mar 2018 10:19:36 +0900 Subject: [PATCH 10/14] feat: Upgrade libp2p --- Cargo.lock | 241 ++++++++++++++++++++++---------- Makefile | 2 +- src/adapter.rs | 2 +- src/cli/run_impl.rs | 19 ++- src/cli/signer.rs | 34 ++--- src/cli/spec.rs | 4 +- src/config.rs | 4 +- util/crypto/src/secp/privkey.rs | 6 + util/crypto/src/secp/pubkey.rs | 6 + 9 files changed, 212 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 40905f3362..b1506e1f90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,11 +87,6 @@ name = "base-x" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "base58" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "base64" version = "0.5.2" @@ -130,6 +125,16 @@ dependencies = [ "uint 0.1.2", ] +[[package]] +name = "bigint" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bigint-serialize" version = "0.2.1" @@ -287,6 +292,14 @@ dependencies = [ "multihash 0.7.0 (git+https://github.com/tomaka/rust-multihash?branch=emscripten-hack)", ] +[[package]] +name = "circular-buffer" +version = "0.1.0" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" +dependencies = [ + "smallvec 0.6.0 (git+https://github.com/Vurich/rust-smallvec.git?branch=array-zero)", +] + [[package]] name = "clang-sys" version = "0.21.2" @@ -418,11 +431,11 @@ dependencies = [ [[package]] name = "datastore" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" dependencies = [ "base64 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "chashmap 2.2.1 (git+https://github.com/redox-os/tfs)", - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -577,7 +590,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -585,7 +598,7 @@ name = "futures-mutex" version = "0.3.0" source = "git+https://github.com/paritytech/futures-mutex#18ca11258512a1846826bc83782e538ac692d990" dependencies = [ - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -740,14 +753,78 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "libp2p-floodsub" +version = "0.1.0" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" +dependencies = [ + "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-peerstore 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "libp2p-swarm 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", + "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "varint 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", +] + +[[package]] +name = "libp2p-identify" +version = "0.1.0" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" +dependencies = [ + "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-peerstore 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "libp2p-swarm 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", + "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "varint 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", +] + +[[package]] +name = "libp2p-kad" +version = "0.1.0" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" +dependencies = [ + "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "bigint 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "datastore 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-identify 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "libp2p-peerstore 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "libp2p-ping 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "libp2p-swarm 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", + "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "varint 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", +] + [[package]] name = "libp2p-peerstore" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" dependencies = [ "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "datastore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "datastore 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", "multihash 0.7.0 (git+https://github.com/tomaka/rust-multihash?branch=emscripten-hack)", "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -758,14 +835,14 @@ dependencies = [ [[package]] name = "libp2p-ping" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-swarm 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", - "multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "multistream-select 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -774,17 +851,17 @@ dependencies = [ [[package]] name = "libp2p-secio" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-swarm 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.12.1 (git+https://github.com/briansmith/ring?rev=3a14ef619559f7d4b69e2286d49c833409eef34a)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "rw-stream-sink 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -792,14 +869,14 @@ dependencies = [ [[package]] name = "libp2p-swarm" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", - "multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "multistream-select 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -808,10 +885,10 @@ dependencies = [ [[package]] name = "libp2p-tcp-transport" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" dependencies = [ - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-swarm 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -821,13 +898,13 @@ dependencies = [ [[package]] name = "libp2p-websocket" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" dependencies = [ - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-swarm 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", - "rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "rw-stream-sink 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", "stdweb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -918,7 +995,7 @@ source = "git+https://github.com/NervosFoundation/rust-mdns-responder#64761272af dependencies = [ "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.3.2 (git+https://github.com/plietar/dns-parser)", - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "multimap 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1035,32 +1112,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "multiplex" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "circular-buffer 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "futures-mutex 0.3.0 (git+https://github.com/paritytech/futures-mutex)", - "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "libp2p-swarm 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", "num-bigint 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "varint 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", ] [[package]] name = "multistream-select" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "varint 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", ] [[package]] @@ -1167,32 +1245,33 @@ dependencies = [ name = "nervos-network" version = "0.1.0" dependencies = [ - "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bigint 0.2.3", + "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-peerstore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "libp2p-ping 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "libp2p-secio 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "libp2p-tcp-transport 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", - "libp2p-websocket 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-floodsub 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "libp2p-identify 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "libp2p-kad 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "libp2p-peerstore 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "libp2p-ping 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "libp2p-secio 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "libp2p-swarm 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "libp2p-tcp-transport 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", + "libp2p-websocket 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mdns-discover 0.2.0 (git+https://github.com/NervosFoundation/rust-mdns-discover)", "mdns-responder 0.2.0 (git+https://github.com/NervosFoundation/rust-mdns-responder)", "multiaddr 0.2.0 (git+https://github.com/multiformats/rust-multiaddr)", - "multiplex 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "multiplex 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", "nervos-core 0.1.0", "nervos-util 0.1.0", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)", + "varint 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)", ] [[package]] @@ -1615,10 +1694,10 @@ dependencies = [ [[package]] name = "rw-stream-sink" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1777,6 +1856,11 @@ name = "smallvec" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "smallvec" +version = "0.6.0" +source = "git+https://github.com/Vurich/rust-smallvec.git?branch=array-zero#cccd87359f8b52b109e96abe3f94815c14b01a67" + [[package]] name = "smallvec" version = "0.6.0" @@ -1974,7 +2058,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1989,16 +2073,25 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-timer" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio-tls" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2105,11 +2198,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "varint" version = "0.1.0" -source = "git+https://github.com/libp2p/rust-libp2p#1e86c6ed352628129d89446e6753fa0f90e29d4d" +source = "git+https://github.com/NervosFoundation/rust-libp2p#9eb8656d267a810171c88011e0bb4470f60af7ef" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2144,7 +2237,7 @@ dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2224,10 +2317,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum backtrace 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbbf59b1c43eefa8c3ede390fcc36820b4999f7914104015be25025e0d62af2" "checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661" "checksum base-x 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f59103b47307f76e03bef1633aec7fa9e29bfb5aa6daf5a334f94233c71f6c1" -"checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" "checksum base64 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "30e93c03064e7590d0466209155251b90c22e37fab1daf2771582598b5827557" "checksum base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96434f987501f0ed4eb336a411e0631ecd1afa11574fe148587adc4ff96143c9" "checksum base64 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5032d51da2741729bfdaeb2664d9b8c6d9fd1e2b90715c660b6def36628499c2" +"checksum bigint 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5442186ef6560f30f1ee4b9c1e4c87a35a6879d3644550cc248ec2b955eb5fcd" "checksum bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bda13183df33055cbb84b847becce220d392df502ebe7a4a78d7021771ed94d0" "checksum bindgen 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ba610cba0c1727ed837316540068b51349b8268c073906067b7c3948598929bd" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" @@ -2248,6 +2341,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum chashmap 2.2.1 (git+https://github.com/redox-os/tfs)" = "" "checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9" "checksum cid 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d85ee025368e69063c420cbb2ed9f852cb03a5e69b73be021e65726ce03585b6" +"checksum circular-buffer 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" "checksum clang-sys 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e414af9726e1d11660801e73ccc7fb81803fb5f49e5903a25b348b2b3b480d2e" "checksum clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f16b89cbb9ee36d87483dc939fe9f1e13c05898d56d7b230a0d4dff033a536" "checksum core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25bfd746d203017f7d5cbd31ee5d8e17f94b6521c7af77ece6c9e4b2d4b16c67" @@ -2259,7 +2353,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" "checksum ctrlc 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "653abc99aa905f693d89df4797fadc08085baee379db92be9f2496cefe8a6f2c" -"checksum datastore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum datastore 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" "checksum digest 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "00a49051fef47a72c9623101b19bd71924a45cca838826caae3eaa4d00772603" "checksum dns-parser 0.3.2 (git+https://github.com/plietar/dns-parser)" = "" "checksum dns-parser 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7020f6760aea312d43d23cb83bf6c0c49f162541db8b02bf95209ac51dc253d" @@ -2277,7 +2371,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0bab5b5e94f5c31fc764ba5dd9ad16568aae5d4825538c01d6bca680c9bf94a7" +"checksum futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f32b9e9aaa890fe8b9453b27ebbf3d11136a5ce59032500effd0e707bbcd80" "checksum futures-mutex 0.3.0 (git+https://github.com/paritytech/futures-mutex)" = "" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" @@ -2299,12 +2393,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef" "checksum libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "1e5d97d6708edaa407429faa671b942dc0f2727222fb6b6539bf1db936e4b121" "checksum libloading 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fd38073de8f7965d0c17d30546d4bb6da311ab428d1c7a3fc71dff7f9d4979b9" -"checksum libp2p-peerstore 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" -"checksum libp2p-ping 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" -"checksum libp2p-secio 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" -"checksum libp2p-swarm 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" -"checksum libp2p-tcp-transport 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" -"checksum libp2p-websocket 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum libp2p-floodsub 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" +"checksum libp2p-identify 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" +"checksum libp2p-kad 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" +"checksum libp2p-peerstore 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" +"checksum libp2p-ping 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" +"checksum libp2p-secio 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" +"checksum libp2p-swarm 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" +"checksum libp2p-tcp-transport 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" +"checksum libp2p-websocket 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" "checksum librocksdb-sys 5.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0fa7f4ca5ceff76237db63802cb073d84e64a327e38478e79a669093fb7fa5" "checksum linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7860ec297f7008ff7a1e3382d7f7e1dcd69efc94751a2284bafc3d013c2aa939" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" @@ -2325,8 +2422,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum multibase 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b9c35dac080fd6e16a99924c8dfdef0af89d797dd851adab25feaffacf7850d6" "checksum multihash 0.7.0 (git+https://github.com/tomaka/rust-multihash?branch=emscripten-hack)" = "" "checksum multimap 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9223f4774d08e06185e44e555b9a7561243d387bac49c78a6205c42d6975fbf2" -"checksum multiplex 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" -"checksum multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum multiplex 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" +"checksum multistream-select 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" "checksum native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f74dbadc8b43df7864539cedb7bc91345e532fdd913cfdc23ad94f4d2d40fbc0" "checksum net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "3a80f842784ef6c9a958b68b7516bc7e35883c614004dd94959a4dca1b716c09" "checksum nix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "47e49f6982987135c5e9620ab317623e723bd06738fd85377e8d55f57c8b6487" @@ -2375,7 +2472,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ceb8ce7a5e520de349e1fa172baeba4a9e8d5ef06c47471863530bc4972ee1e" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" -"checksum rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum rw-stream-sink 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" "checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" "checksum schannel 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "acece75e0f987c48863a6c792ec8b7d6c4177d4a027f8ccc72f849794f437016" "checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d" @@ -2397,6 +2494,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d" "checksum slug 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f5ff4b43cb07b86c5f9236c92714a22cdf9e5a27a7d85e398e2c9403328cb8" "checksum smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "872c0ff227000041c520cca51e883b858d388ab0ecf646bab76f065cebaec025" +"checksum smallvec 0.6.0 (git+https://github.com/Vurich/rust-smallvec.git?branch=array-zero)" = "" "checksum smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44db0ecb22921ef790d17ae13a3f6d15784183ff5f2a01aa32098c7498d2b4b9" "checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b" "checksum stdweb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef5430c8e36b713e13b48a9f709cc21e046723fe44ce34587b73a830203b533e" @@ -2420,6 +2518,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum tiny-keccak 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "58911ed5eb275a8fd2f1f0418ed360a42f59329864b64e1e95377a9024498c01" "checksum tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "52b4e32d8edbf29501aabb3570f027c6ceb00ccef6538f4bddba0200503e74e8" "checksum tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b9532748772222bf70297ec0e2ad0f17213b4a7dd0e6afb68e0a0768f69f4e4f" +"checksum tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6131e780037787ff1b3f8aad9da83bca02438b72277850dd6ad0d455e0e20efc" "checksum tokio-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "772f4b04e560117fe3b0a53e490c16ddc8ba6ec437015d91fa385564996ed913" "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" @@ -2435,7 +2534,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum untrusted 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70afa43c8c5d23a53a3c39ec9b56232c5badc19f6bb5ad529c1d6448a7241365" "checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" -"checksum varint 0.1.0 (git+https://github.com/libp2p/rust-libp2p)" = "" +"checksum varint 0.1.0 (git+https://github.com/NervosFoundation/rust-libp2p)" = "" "checksum vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9e0a7d8bed3178a8fb112199d466eeca9ed09a14ba8ad67718179b4fd5487d0b" "checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c" "checksum version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6b772017e347561807c1aa192438c5fd74242a670a6cffacc40f2defd1dc069d" diff --git a/Makefile b/Makefile index a8d4f0f866..f11173a473 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ fmt: cargo fmt --all -- --write-mode=diff clippy: - cargo clippy --all -- -D warnings + cargo clippy --all -- -D warnings -D clone_on_ref_ptr ci: fmt clippy test git diff --exit-code Cargo.lock diff --git a/src/adapter.rs b/src/adapter.rs index 17f618d2b6..d2c19fb107 100644 --- a/src/adapter.rs +++ b/src/adapter.rs @@ -97,7 +97,7 @@ impl NetToChainAndPoolAdapter { chain: Arc::downgrade(chain), }); - let subtask = adapter.clone(); + let subtask = Arc::clone(&adapter); thread::spawn(move || { let dur = Duration::from_millis(TIME_STEP); loop { diff --git a/src/cli/run_impl.rs b/src/cli/run_impl.rs index e077a2f485..dd93dd65c9 100644 --- a/src/cli/run_impl.rs +++ b/src/cli/run_impl.rs @@ -26,16 +26,21 @@ pub fn run(config: Config) { let tx_pool = Arc::new(TransactionPool::default()); - let chain_adapter = Arc::new(ChainToNetAndPoolAdapter::new(tx_pool.clone())); + let chain_adapter = Arc::new(ChainToNetAndPoolAdapter::new(Arc::clone(&tx_pool))); + let chain = Arc::new( - Chain::init(store, chain_adapter.clone(), &chain::genesis::genesis_dev()).unwrap(), + Chain::init( + store, + Arc::clone(&chain_adapter), + &chain::genesis::genesis_dev(), + ).unwrap(), ); let kg = Arc::new(config.key_group()); - let net_adapter = NetToChainAndPoolAdapter::new(kg, &chain, tx_pool.clone()); + let net_adapter = NetToChainAndPoolAdapter::new(kg, &chain, Arc::clone(&tx_pool)); - let network = Arc::new(Network::init(net_adapter, config.network).unwrap()); + let network = Arc::new(Network::new(net_adapter, config.network)); chain_adapter.init(&network); @@ -46,10 +51,11 @@ pub fn run(config: Config) { signer_key: bigint::H256::from(&config.signer.signer_private_key[..]), }; + let network_clone = Arc::clone(&network); let _ = thread::Builder::new() .name("network".to_string()) .spawn(move || { - network.start(); + network_clone.start(); }); let _ = thread::Builder::new() @@ -62,6 +68,7 @@ pub fn run(config: Config) { info!(target: "main", "Finishing work, please wait..."); + // network.flush(); logger::flush(); } @@ -69,7 +76,7 @@ fn wait_for_exit() { let exit = Arc::new((Mutex::new(()), Condvar::new())); // Handle possible exits - let e = exit.clone(); + let e = Arc::<(Mutex<()>, Condvar)>::clone(&exit); let _ = ctrlc::set_handler(move || { e.1.notify_all(); }); diff --git a/src/cli/signer.rs b/src/cli/signer.rs index 2b5eb36616..35bb96a110 100644 --- a/src/cli/signer.rs +++ b/src/cli/signer.rs @@ -51,40 +51,26 @@ impl Signer { impl Default for Signer { fn default() -> Self { - use std::str::FromStr; + let (miner_private_key, proof_public_key, proof_public_g) = bls::key_gen(); + + let gen = Generator::new(); + let (signer_private_key, signer_public_key) = gen.random_keypair() + .expect("Generate random secp256k1 keypair"); let key_pairs = vec![ KeyPair { - proof_public_key: ProofPublickey::from_str("037151adfd9b0167d943ad816352bf0a96cfedfa15b60caddda91ad710732cb80cb54d46ce2fa9fc00").unwrap(), - proof_public_g: ProofPublicG::from_str("0ce477d8a5e6b27c9d8ec9e54efbf6f5b3455ffa01899a237d80d463f737f65f0d975a8bb3ceca9e00").unwrap(), - signer_public_key: PublicKey::from_str("8c651d8deaef3119589ab0ba527661d97cb2fd595348ef283b7a14ba252ba493184be105beeb4ef62a20fa93a3d93672dab07381e8f01017ef5124624ddbe2a0").unwrap(), + proof_public_key: ProofPublickey::from_slice(&proof_public_key[..]), + proof_public_g: ProofPublicG::from_slice(&proof_public_g[..]), + signer_public_key: signer_public_key.into(), }, - KeyPair { - proof_public_key: ProofPublickey::from_str("03a02e943dc86d0d09a84f4c9c1d5ce0fbe4337c06fe1975e13fa1a7013f297701818d27400604d101").unwrap(), - proof_public_g: ProofPublicG::from_str("15f3b0f38a316392cb6829b18eb220bf9e40bef301869f275d27d35e176fcfaae839bc387021c7ce01").unwrap(), - signer_public_key: PublicKey::from_str("2cb94bd40d4f9edbeb77f682f095fc68e71a8d639d4afd93470e23a2cfb845e1ec4d0c034913e27eb64fad7c8254db7812252065bfbc7432f38944569e7941d5").unwrap(), - }, - KeyPair { - proof_public_key: ProofPublickey::from_str("133f84a2fba7d7d75c8bef53662ce555c034bdcc059765937f5b5fa3fad7fc5de96929f47285612001").unwrap(), - proof_public_g: ProofPublicG::from_str("004ca4aa1dcafbf4392cf395e8e78f3ebdc880ab0ef4a512f0dd486bf1a6861114f4d835d6dcacf001").unwrap(), - signer_public_key: PublicKey::from_str("aef7c4b07094501fe566859b6b713b541beb4ddf5c1821337d57836095a1eb1371223aa6904a26dbe1ebd74556c1cf1831910c5349a118a771edd6919aed701e").unwrap(), - }, - KeyPair { - proof_public_key: ProofPublickey::from_str("07cafa7797efe36d26bb0af68bf8a55640f57fc811f5ee73bb7d10a2735cf0eb059b7cfb1107fc9d00").unwrap(), - proof_public_g: ProofPublicG::from_str("0318e21e32b26d6310e3609e78cdddfcc817f0f41a3deb02a611d63af17c7246b939360692bfd14900").unwrap(), - signer_public_key: PublicKey::from_str("415a033b4596c0c95542b304ae3241bbc82508cf4425950abb273023931adc37c77f92759e079c81967a5ba65b2d93027eda0e4c89a84f32917c24bf82be57ad").unwrap(), - } ]; - let miner_private_key = H160::from_str("1162b2f150c789aed32e2e0b3081dd6852926865").unwrap(); - let signer_private_key = H256::from_str( - "097c1a2d03b6c8fc270991051553219e34951b656382ca951c4c226d40a3b2d5", - ).unwrap(); + let miner_private_key = H160::from_slice(&miner_private_key[..]); Signer { miner_private_key, - signer_private_key, key_pairs, + signer_private_key: signer_private_key.into(), } } } diff --git a/src/cli/spec.rs b/src/cli/spec.rs index ba89fe85fc..d44fb23bd1 100644 --- a/src/cli/spec.rs +++ b/src/cli/spec.rs @@ -20,13 +20,13 @@ pub struct Spec { impl Default for Spec { fn default() -> Self { let logger = LogConfig { - filter: Some("main=info,miner=info,chain=info".to_string()), + filter: Some("main=info,miner=info,chain=info,network=debug".to_string()), color: true, file: Some("/tmp/nervos0.log".to_string()), }; let network = NetworkConfig { - listen_addr: "/ip4/0.0.0.0/tcp/12300".to_string(), + listen_addr: "/ip4/0.0.0.0/tcp/0".to_string(), bootstrap_nodes: vec![ ( "QmWvoPbu9AgEFLL5UyxpCfhxkLDd9T7zuerjhHiwsnqSh4".to_string(), diff --git a/src/config.rs b/src/config.rs index 31eefdd60d..918f706f91 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,8 +9,9 @@ use network::Config as NetworkConfig; const CONFIG_FILE: &str = "config.toml"; const SIGNER_FILE: &str = "signer.toml"; const RSA_FILE: &str = "rsa.toml"; +const PEERS: &str = "peers.json"; -#[derive(Clone, Debug, Default, PartialEq)] +#[derive(Clone, Debug, PartialEq)] pub struct Config { pub logger: LogConfig, pub signer: Signer, @@ -35,6 +36,7 @@ impl Config { public_key: rsa.pubkey_der, listen_addr: network.listen_addr, bootstrap_nodes: network.bootstrap_nodes, + peer_path: dirs.base.join(PEERS), }; Config { diff --git a/util/crypto/src/secp/privkey.rs b/util/crypto/src/secp/privkey.rs index 5a5f106dc2..50a40da923 100644 --- a/util/crypto/src/secp/privkey.rs +++ b/util/crypto/src/secp/privkey.rs @@ -40,6 +40,12 @@ impl From for Privkey { } } +impl Into for Privkey { + fn into(self) -> H256 { + self.inner + } +} + impl FromStr for Privkey { type Err = Error; fn from_str(s: &str) -> Result { diff --git a/util/crypto/src/secp/pubkey.rs b/util/crypto/src/secp/pubkey.rs index 68059d5137..1b17390dfe 100644 --- a/util/crypto/src/secp/pubkey.rs +++ b/util/crypto/src/secp/pubkey.rs @@ -45,6 +45,12 @@ impl From for Pubkey { } } +impl Into for Pubkey { + fn into(self) -> H512 { + self.inner + } +} + impl ops::Deref for Pubkey { type Target = H512; From 012c2ba3ac4b3002d88e7b83609adf6408d57214 Mon Sep 17 00:00:00 2001 From: quake wang Date: Wed, 4 Apr 2018 16:48:05 +0900 Subject: [PATCH 11/14] feat: Add rpc server --- .travis.yml | 4 +- Cargo.lock | 149 ++++++++++++++++++++++++++++++ Cargo.toml | 4 +- rpc/Cargo.toml | 15 +++ rpc/src/lib.rs | 63 +++++++++++++ src/adapter.rs | 4 +- src/cli/run_impl.rs | 12 ++- src/cli/spec.rs | 20 +++- src/cli/template.rs | 1 + src/cli/templates/config.template | 3 + src/config.rs | 13 ++- src/main.rs | 2 + 12 files changed, 281 insertions(+), 9 deletions(-) create mode 100644 rpc/Cargo.toml create mode 100644 rpc/src/lib.rs diff --git a/.travis.yml b/.travis.yml index f1a4079a9c..ef7820e047 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: rust sudo: true -cache: cargo +cache: + cargo: true + timeout: 1024 env: global: diff --git a/Cargo.lock b/Cargo.lock index b1506e1f90..4ab59252fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -620,6 +620,18 @@ name = "glob" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "globset" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "hash" version = "0.1.0" @@ -709,6 +721,66 @@ name = "itoa" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "jsonrpc-core" +version = "8.0.2" +source = "git+https://github.com/paritytech/jsonrpc#67f86fcb47cf33f6105f5bb63ea50e4018279cea" +dependencies = [ + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "jsonrpc-macros" +version = "8.0.1" +source = "git+https://github.com/paritytech/jsonrpc#67f86fcb47cf33f6105f5bb63ea50e4018279cea" +dependencies = [ + "jsonrpc-core 8.0.2 (git+https://github.com/paritytech/jsonrpc)", + "jsonrpc-pubsub 8.0.1 (git+https://github.com/paritytech/jsonrpc)", + "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "jsonrpc-minihttp-server" +version = "8.0.1" +source = "git+https://github.com/paritytech/jsonrpc#67f86fcb47cf33f6105f5bb63ea50e4018279cea" +dependencies = [ + "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 8.0.2 (git+https://github.com/paritytech/jsonrpc)", + "jsonrpc-server-utils 8.0.1 (git+https://github.com/paritytech/jsonrpc)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-minihttp 0.1.0 (git+https://github.com/tomusdrw/tokio-minihttp)", + "tokio-proto 0.1.0 (git+https://github.com/tomusdrw/tokio-proto)", + "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "jsonrpc-pubsub" +version = "8.0.1" +source = "git+https://github.com/paritytech/jsonrpc#67f86fcb47cf33f6105f5bb63ea50e4018279cea" +dependencies = [ + "jsonrpc-core 8.0.2 (git+https://github.com/paritytech/jsonrpc)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "jsonrpc-server-utils" +version = "8.0.1" +source = "git+https://github.com/paritytech/jsonrpc#67f86fcb47cf33f6105f5bb63ea50e4018279cea" +dependencies = [ + "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "globset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 8.0.2 (git+https://github.com/paritytech/jsonrpc)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -1174,6 +1246,7 @@ dependencies = [ "nervos-miner 0.1.0", "nervos-network 0.1.0", "nervos-pool 0.1.0", + "nervos-rpc 0.1.0", "nervos-time 0.1.0", "nervos-util 0.1.0", "serde 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1283,6 +1356,20 @@ dependencies = [ "nervos-util 0.1.0", ] +[[package]] +name = "nervos-rpc" +version = "0.1.0" +dependencies = [ + "bigint 0.2.3", + "jsonrpc-core 8.0.2 (git+https://github.com/paritytech/jsonrpc)", + "jsonrpc-macros 8.0.1 (git+https://github.com/paritytech/jsonrpc)", + "jsonrpc-minihttp-server 8.0.1 (git+https://github.com/paritytech/jsonrpc)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nervos-core 0.1.0", + "nervos-network 0.1.0", + "serde_json 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "nervos-time" version = "0.1.0" @@ -1851,6 +1938,11 @@ dependencies = [ "unidecode 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "smallvec" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "smallvec" version = "0.5.0" @@ -1950,6 +2042,11 @@ dependencies = [ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "take" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "tempdir" version = "0.3.6" @@ -2077,6 +2174,47 @@ dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-minihttp" +version = "0.1.0" +source = "git+https://github.com/tomusdrw/tokio-minihttp#67a400060bd29e51beaf206c552845255b6f699f" +dependencies = [ + "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-proto 0.1.0 (git+https://github.com/tomusdrw/tokio-proto)", + "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-proto" +version = "0.1.0" +source = "git+https://github.com/tomusdrw/tokio-proto#f6ee08cb594fa2fc1b4178eaaca0855d66e68fd3" +dependencies = [ + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-service" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio-timer" version = "0.1.2" @@ -2376,6 +2514,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" +"checksum globset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "464627f948c3190ae3d04b1bc6d7dca2f785bda0ac01278e6db129ad383dbeb6" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2f407128745b78abc95c0ffbe4e5d37427fdc0d45470710cfef8c44522a2e37" "checksum humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e" @@ -2386,6 +2525,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum integer-encoding 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26746cbc2e680af687e88d717f20ff90079bd10fc984ad57d277cd0e37309fa5" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" +"checksum jsonrpc-core 8.0.2 (git+https://github.com/paritytech/jsonrpc)" = "" +"checksum jsonrpc-macros 8.0.1 (git+https://github.com/paritytech/jsonrpc)" = "" +"checksum jsonrpc-minihttp-server 8.0.1 (git+https://github.com/paritytech/jsonrpc)" = "" +"checksum jsonrpc-pubsub 8.0.1 (git+https://github.com/paritytech/jsonrpc)" = "" +"checksum jsonrpc-server-utils 8.0.1 (git+https://github.com/paritytech/jsonrpc)" = "" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" @@ -2493,6 +2637,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" "checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d" "checksum slug 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f5ff4b43cb07b86c5f9236c92714a22cdf9e5a27a7d85e398e2c9403328cb8" +"checksum smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c8cbcd6df1e117c2210e13ab5109635ad68a929fcbb8964dc965b76cb5ee013" "checksum smallvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "872c0ff227000041c520cca51e883b858d388ab0ecf646bab76f065cebaec025" "checksum smallvec 0.6.0 (git+https://github.com/Vurich/rust-smallvec.git?branch=array-zero)" = "" "checksum smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44db0ecb22921ef790d17ae13a3f6d15784183ff5f2a01aa32098c7498d2b4b9" @@ -2506,6 +2651,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "867cc5c2d7140ae7eaad2ae9e8bf39cb18a67ca651b7834f88d46ca98faadb9c" "checksum syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13ad4762fe52abc9f4008e85c4fb1b1fe3aa91ccb99ff4826a439c7c598e1047" "checksum syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6e0e4dbae163dd98989464c23dd503161b338790640e11537686f2ef0f25c791" +"checksum take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b157868d8ac1f56b64604539990685fa7611d8fa9e5476cf0c02cf34d32917c5" "checksum tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f73eebdb68c14bcb24aef74ea96079830e7fa7b31a6106e42ea7ee887c1e134e" "checksum tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11ce2fe9db64b842314052e2421ac61a73ce41b898dc8e3750398b219c5fc1e0" "checksum tera 0.11.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fc1a35d04c2444875b1319293fbc72c00215ae6220f8c70f9f14fefa5eaae0c6" @@ -2518,6 +2664,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum tiny-keccak 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "58911ed5eb275a8fd2f1f0418ed360a42f59329864b64e1e95377a9024498c01" "checksum tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "52b4e32d8edbf29501aabb3570f027c6ceb00ccef6538f4bddba0200503e74e8" "checksum tokio-io 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b9532748772222bf70297ec0e2ad0f17213b4a7dd0e6afb68e0a0768f69f4e4f" +"checksum tokio-minihttp 0.1.0 (git+https://github.com/tomusdrw/tokio-minihttp)" = "" +"checksum tokio-proto 0.1.0 (git+https://github.com/tomusdrw/tokio-proto)" = "" +"checksum tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" "checksum tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6131e780037787ff1b3f8aad9da83bca02438b72277850dd6ad0d455e0e20efc" "checksum tokio-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "772f4b04e560117fe3b0a53e490c16ddc8ba6ec437015d91fa385564996ed913" "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" diff --git a/Cargo.toml b/Cargo.toml index cdc1ba1f3a..51ab57004c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ nervos-miner = { path = "miner" } nervos-db = { path = "db" } nervos-network = { path = "network"} nervos-pool = { path = "pool"} +nervos-rpc = { path = "rpc"} nervos-time = { path = "util/time"} logger = { path = "util/logger" } bigint = { path = "util/bigint" } @@ -50,5 +51,6 @@ members = [ "chain", "miner", "db", - "pool" + "pool", + "rpc" ] diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml new file mode 100644 index 0000000000..431a4243d2 --- /dev/null +++ b/rpc/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "nervos-rpc" +version = "0.1.0" +authors = ["Nervos Core Dev "] + +[dependencies] +bigint = { path = "../util/bigint" } +nervos-core = { path = "../core" } +nervos-network = { path = "../network" } +jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc" } +jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc" } +jsonrpc-minihttp-server = { git = "https://github.com/paritytech/jsonrpc" } + +serde_json = "1.0" +log = "0.4" diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs new file mode 100644 index 0000000000..352bd4b7f8 --- /dev/null +++ b/rpc/src/lib.rs @@ -0,0 +1,63 @@ +#![feature(box_syntax)] +extern crate bigint; +extern crate jsonrpc_core; +#[macro_use] +extern crate jsonrpc_macros; +extern crate jsonrpc_minihttp_server; +#[macro_use] +extern crate log; +extern crate nervos_core as core; +extern crate nervos_network as network; + +use bigint::H256; +use core::adapter::NetAdapter; +use core::transaction::Transaction; +use jsonrpc_core::{IoHandler, Result}; +use jsonrpc_minihttp_server::ServerBuilder; +use network::{Broadcastable, Network}; +use std::sync::Arc; + +build_rpc_trait! { + pub trait Rpc { + // url -d '{"id": 2, "jsonrpc": "2.0", "method":"send_transaction","params": [{"version":2, "inputs":[], "outputs":[], "grouping":[]}]}' -H 'content-type:application/json' 'http://localhost:3030' + #[rpc(name = "send_transaction")] + fn send_transaction(&self, Transaction) -> Result; + } +} + +struct RpcImpl { + pub network: Arc>, +} +impl Rpc for RpcImpl { + fn send_transaction(&self, tx: Transaction) -> Result { + let result = tx.hash(); + self.network.broadcast(Broadcastable::Transaction(box tx)); + Ok(result) + } +} + +pub struct RpcServer { + pub config: Config, +} +impl RpcServer { + pub fn start(&self, network: Arc>) + where + NA: NetAdapter + 'static, + { + let mut io = IoHandler::new(); + io.extend_with(RpcImpl { network }.to_delegate()); + + let server = ServerBuilder::new(io) + .threads(3) + .start_http(&self.config.listen_addr.parse().unwrap()) + .unwrap(); + + info!(target: "rpc", "Now listening on {:?}", server.address()); + server.wait().unwrap(); + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct Config { + pub listen_addr: String, +} diff --git a/src/adapter.rs b/src/adapter.rs index d2c19fb107..0cd4fe3827 100644 --- a/src/adapter.rs +++ b/src/adapter.rs @@ -7,7 +7,7 @@ use core::transaction::Transaction; use db::cachedb::CacheKeyValueDB; use db::diskdb::RocksKeyValueDB; use db::store::ChainKVStore; -use network::Network; +use network::{Broadcastable, Network}; use pool::{OrphanBlockPool, PendingBlockPool, TransactionPool}; use std::sync::Arc; use std::sync::Weak; @@ -39,7 +39,7 @@ pub struct ChainToNetAndPoolAdapter { impl ChainAdapter for ChainToNetAndPoolAdapter { fn block_accepted(&self, b: &Block) { self.tx_pool.accommodate(b); - upgrade_network(&self.network).broadcast(b); + upgrade_network(&self.network).broadcast(Broadcastable::Block(box b.clone())); } } diff --git a/src/cli/run_impl.rs b/src/cli/run_impl.rs index dd93dd65c9..00e190156e 100644 --- a/src/cli/run_impl.rs +++ b/src/cli/run_impl.rs @@ -11,7 +11,7 @@ use logger; use miner::miner::Miner; use network::Network; use pool::TransactionPool; -use std::path::Path; +use rpc::RpcServer; use std::sync::Arc; use std::thread; use util::{Condvar, Mutex}; @@ -21,7 +21,7 @@ pub fn run(config: Config) { info!(target: "main", "Value for config: {:?}", config); - let db = CacheKeyValueDB::new(RocksKeyValueDB::open(Path::new(&config.db_path))); + let db = CacheKeyValueDB::new(RocksKeyValueDB::open(&config.dirs.db)); let store = ChainKVStore { db: Box::new(db) }; let tx_pool = Arc::new(TransactionPool::default()); @@ -64,6 +64,14 @@ pub fn run(config: Config) { miner.run_loop(); }); + let rpc_server = RpcServer { config: config.rpc }; + let network_clone = Arc::clone(&network); + let _ = thread::Builder::new() + .name("rpc".to_string()) + .spawn(move || { + rpc_server.start(network_clone); + }); + wait_for_exit(); info!(target: "main", "Finishing work, please wait..."); diff --git a/src/cli/spec.rs b/src/cli/spec.rs index d44fb23bd1..4df4e28728 100644 --- a/src/cli/spec.rs +++ b/src/cli/spec.rs @@ -11,16 +11,22 @@ pub struct NetworkConfig { pub bootstrap_nodes: Vec<(String, String)>, } +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct RpcConfig { + pub listen_addr: String, +} + #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct Spec { pub logger: LogConfig, pub network: NetworkConfig, + pub rpc: RpcConfig, } impl Default for Spec { fn default() -> Self { let logger = LogConfig { - filter: Some("main=info,miner=info,chain=info,network=debug".to_string()), + filter: Some("main=info,miner=info,chain=info,network=debug,rpc=info".to_string()), color: true, file: Some("/tmp/nervos0.log".to_string()), }; @@ -35,7 +41,15 @@ impl Default for Spec { ], }; - Spec { logger, network } + let rpc = RpcConfig { + listen_addr: "0.0.0.0:0".to_string(), + }; + + Spec { + logger, + network, + rpc, + } } } @@ -90,6 +104,8 @@ mod tests { [network] listen_addr = "/ip4/0.0.0.0/tcp/0" bootstrap_nodes = [["QmWvoPbu9AgEFLL5UyxpCfhxkLDd9T7zuerjhHiwsnqSh4", "/ip4/127.0.0.1/tcp/12345"]] + [rpc] + listen_addr = "0.0.0.0:0" "#).expect("Spec deserialize."); assert_eq!(true, spec.logger.color); diff --git a/src/cli/template.rs b/src/cli/template.rs index 2675e9a515..215b46dddc 100644 --- a/src/cli/template.rs +++ b/src/cli/template.rs @@ -43,6 +43,7 @@ impl Templates { let mut context = Context::new(); context.add("logger", &spec.logger); context.add("network", &spec.network); + context.add("rpc", &spec.rpc); self.inner .render("config.toml", &context) .expect("Render config") diff --git a/src/cli/templates/config.template b/src/cli/templates/config.template index 8b297b3e37..71c3a7f97e 100644 --- a/src/cli/templates/config.template +++ b/src/cli/templates/config.template @@ -8,3 +8,6 @@ listen_addr = "{{ network.listen_addr }}" bootstrap_nodes = [{% for bootstrap_node in network.bootstrap_nodes %} ["{{bootstrap_node.0}}", "{{bootstrap_node.1}}"] {% endfor %}] + +[rpc] +listen_addr = "{{ rpc.listen_addr }}" diff --git a/src/config.rs b/src/config.rs index 918f706f91..b8d8af40de 100644 --- a/src/config.rs +++ b/src/config.rs @@ -5,6 +5,7 @@ use crypto::rsa::Rsa; use dir::{default_base_path, Directories}; use logger::Config as LogConfig; use network::Config as NetworkConfig; +use rpc::Config as RpcConfig; const CONFIG_FILE: &str = "config.toml"; const SIGNER_FILE: &str = "signer.toml"; @@ -17,6 +18,7 @@ pub struct Config { pub signer: Signer, pub network: NetworkConfig, pub dirs: Directories, + pub rpc: RpcConfig, } impl Config { @@ -29,7 +31,11 @@ impl Config { let rsa = Rsa::load_or_write_default(&dirs.keys.join(RSA_FILE)).expect("load signer"); - let Spec { network, logger } = spec; + let Spec { + network, + logger, + rpc, + } = spec; let network = NetworkConfig { private_key: rsa.privkey_pkcs8, @@ -39,11 +45,16 @@ impl Config { peer_path: dirs.base.join(PEERS), }; + let rpc = RpcConfig { + listen_addr: rpc.listen_addr, + }; + Config { dirs, signer, logger, network, + rpc, } } diff --git a/src/main.rs b/src/main.rs index bac27bad38..bee494e734 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +#![feature(box_syntax)] extern crate bigint; extern crate bls; #[macro_use] @@ -16,6 +17,7 @@ extern crate nervos_db as db; extern crate nervos_miner as miner; extern crate nervos_network as network; extern crate nervos_pool as pool; +extern crate nervos_rpc as rpc; extern crate nervos_time as time; extern crate nervos_util as util; extern crate serde; From a7a2f8f0fd07be38044a42f90e93f945a0a3e7e5 Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 28 Mar 2018 10:46:58 +0800 Subject: [PATCH 12/14] feat(tx): Setup workflow to process block and transaction --- Cargo.lock | 3 + README.md | 29 ++++- chain/src/chain.rs | 58 +++++---- core/src/cell.rs | 242 +++++++++++++++++++++++++++++++++++++ core/src/chain.rs | 24 ++++ core/src/lib.rs | 2 + core/src/transaction.rs | 179 +++++++++++++++------------ db/src/batch.rs | 4 + db/src/diskdb.rs | 20 +++ db/src/lib.rs | 3 + db/src/memorydb.rs | 11 ++ db/src/store.rs | 237 +++++++++++++++++++++++++++++++++--- db/src/transaction_meta.rs | 37 ++++++ default.toml | 2 +- miner/Cargo.toml | 1 + miner/src/lib.rs | 1 + miner/src/miner.rs | 3 + pool/Cargo.toml | 4 + pool/src/lib.rs | 39 +++++- rpc/src/lib.rs | 4 +- src/adapter.rs | 37 +++++- src/cli/run_impl.rs | 8 +- src/cli/spec.rs | 22 +--- 23 files changed, 821 insertions(+), 149 deletions(-) create mode 100644 core/src/cell.rs create mode 100644 core/src/chain.rs create mode 100644 db/src/transaction_meta.rs diff --git a/Cargo.lock b/Cargo.lock index 4ab59252fb..fdbc82fe51 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1312,6 +1312,7 @@ dependencies = [ "nervos-db 0.1.0", "nervos-pool 0.1.0", "nervos-time 0.1.0", + "nervos-util 0.1.0", ] [[package]] @@ -1352,6 +1353,8 @@ name = "nervos-pool" version = "0.1.0" dependencies = [ "bigint 0.2.3", + "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "nervos-core 0.1.0", "nervos-util 0.1.0", ] diff --git a/README.md b/README.md index 9084383cff..568714ab35 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,15 @@ [![TravisCI](https://travis-ci.com/NervosFoundation/nervos.svg?token=y9uR6ygmT3geQaMJ4jpJ&branch=develop)](https://travis-ci.com/NervosFoundation/nervos) ----- +--- ## About Nervos CKB -Nervos CKB is the first Common Knowledge Base to facilitate the creation and storage of [common knowledge](https://en.wikipedia.org/wiki/Common_knowledge_(logic)) of our society. +Nervos CKB is the first Common Knowledge Base to facilitate the creation and storage of [common knowledge]() of our society. Nervos project defines a suite of scalable and interoperable blockchain protocols. Nervos CKB uses those protocols to create a self-evolving distributed network with novel economic model, data model and more. ----- +--- ## Build dependencies @@ -31,19 +31,21 @@ we would like to track `nightly`, report new breakage is welcome. you alse need to get the following packages: * Ubuntu and Debian: + ```shell sudo apt-get install git autoconf flex bison texinfo libtool ``` * OSX: + ```shell brew install autoconf libtool ``` - ----- +--- ## Build from source + ```bash # download Nervos $ git clone https://github.com/NervosFoundation/nervos.git @@ -52,3 +54,20 @@ $ cd nervos # build in release mode $ cargo build --release ``` + +--- + +## Quick Start + +### Start Node + +```shell +target/release/nervos +``` + +### Send Transaction via RPC + +```shell +curl -d '{"id": 2, "jsonrpc": "2.0", "method":"send_transaction","params": [{"version":2, "inputs":[], "outputs":[], "groupings":[]}]}' \ + -H 'content-type:application/json' 'http://localhost:3030' +``` diff --git a/chain/src/chain.rs b/chain/src/chain.rs index d479430fd9..711887d673 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -1,12 +1,14 @@ use bigint::{H256, U256}; use core::adapter::ChainAdapter; use core::block::{Block, Header}; +use core::cell::{CellProvider, CellState}; use core::difficulty::calculate_difficulty; use core::global::{EPOCH_LEN, HEIGHT_SHIFT, MIN_DIFFICULTY, TIME_STEP}; +use core::transaction::OutPoint; use db::store::ChainStore; use rand::{thread_rng, Rng}; use std::sync::Arc; -use util::{Mutex, RwLock}; +use util::RwLock; #[derive(Debug)] pub enum Error { @@ -24,7 +26,6 @@ pub struct Chain { store: CS, adapter: Arc, head_header: RwLock
, - lock: Mutex<()>, } impl Chain { @@ -41,7 +42,6 @@ impl Chain { store, adapter, head_header: RwLock::new(head_header), - lock: Mutex::new(()), }) } @@ -53,6 +53,7 @@ impl Chain { Ok(()) } + // TODO: validate transactions in block fn check_block(&self, h: &Header) -> Result<(), Error> { if self.block_header(&h.hash()).is_some() { return Err(Error::Duplicate); @@ -94,35 +95,15 @@ impl Chain { && rng.gen_range(0, 2) == 0) { info!(target: "chain", "new best block found: {}", b.hash()); - let _guard = self.lock.lock(); - self.update_main_chain(&b.header); self.save_head_header(&b.header); } } - fn update_main_chain(&self, header: &Header) { - self.store.save_block_hash(header.height, &header.hash()); - let mut height = header.height - 1; - let mut hash = header.pre_hash; - - loop { - if Some(hash) == self.block_hash(height) { - break; - } - - self.store.save_block_hash(height, &hash); - - hash = self.block_header(&hash).unwrap().pre_hash; - height -= 1; - } - - self.print_chain(header.height, 10); - } - fn save_head_header(&self, h: &Header) { let mut head_header = self.head_header.write(); *head_header = h.clone(); self.store.save_head_header(h); + self.print_chain(h.height, 10); } pub fn head_header(&self) -> Header { @@ -206,5 +187,34 @@ impl Chain { } info!(target: "chain", "}}"); + + // TODO: remove me when block explorer is available + info!(target: "chain", "Tx in Head Block {{"); + for transaction in self.block_hash(tip) + .and_then(|hash| self.store.get_block_transactions(&hash)) + .expect("invalid block number") + { + info!(target: "chain", " {} => {:?}", transaction.hash(), transaction); + } + info!(target: "chain", "}}"); + } +} + +impl CellProvider for Chain { + fn cell(&self, out_point: &OutPoint) -> CellState { + let index = out_point.index as usize; + if let Some(meta) = self.store.get_transaction_meta(&out_point.hash) { + if index < meta.spent_at.len() { + if !meta.is_spent(index) { + let mut transaction = self.store + .get_transaction(&out_point.hash) + .expect("transaction must exist"); + return CellState::Head(transaction.outputs.swap_remove(index)); + } else { + return CellState::Tail; + } + } + } + CellState::Unknown } } diff --git a/core/src/cell.rs b/core/src/cell.rs new file mode 100644 index 0000000000..e6115ede79 --- /dev/null +++ b/core/src/cell.rs @@ -0,0 +1,242 @@ +use transaction::{CellOutput, OutPoint, Transaction}; + +#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] +pub enum CellState { + /// Cell exists and is the head in its cell chain. + Head(CellOutput), + /// Cell exists and is not the head of its cell chain. + Tail, + /// Cell does not exist. + Unknown, +} + +/// Transaction with resolved input cells. +pub struct ResolvedTransaction { + pub transaction: Transaction, + pub input_cells: Vec, +} + +pub trait CellProvider { + fn cell(&self, out_point: &OutPoint) -> CellState; + + fn resolve_transaction(&self, transaction: Transaction) -> ResolvedTransaction { + let input_cells = transaction + .inputs + .iter() + .map(|input| self.cell(&input.previous_output)) + .collect(); + ResolvedTransaction { + transaction, + input_cells, + } + } + + fn resolve_transaction_unknown_inputs(&self, resolved_transaction: &mut ResolvedTransaction) { + for (input, state) in resolved_transaction + .transaction + .inputs + .iter() + .zip(&mut resolved_transaction.input_cells) + { + if let CellState::Unknown = *state { + *state = self.cell(&input.previous_output); + } + } + } +} + +impl CellState { + pub fn head(&self) -> Option<&CellOutput> { + match *self { + CellState::Head(ref output) => Some(output), + _ => None, + } + } + + pub fn is_head(&self) -> bool { + match *self { + CellState::Head(_) => true, + _ => false, + } + } +} + +impl ResolvedTransaction { + pub fn is_double_spend(&self) -> bool { + self.input_cells.iter().any(|state| match *state { + CellState::Tail => true, + _ => false, + }) + } + + pub fn is_orphan(&self) -> bool { + self.input_cells.iter().any(|state| match *state { + CellState::Unknown => true, + _ => false, + }) + } + + pub fn is_fully_resolved(&self) -> bool { + self.input_cells.iter().all(|state| match *state { + CellState::Head(_) => true, + _ => false, + }) + } + + // TODO: split it + // TODO: tells validation error + pub fn validate(&self, _is_enlarge_transaction: bool) -> bool { + // check inputs + let mut input_cells = Vec::<&CellOutput>::with_capacity(self.input_cells.len()); + for input in &self.input_cells { + match input.head() { + Some(cell) => input_cells.push(cell), + None => { + return false; + } + } + } + + // check capacity balance + // TODO: capacity check is disabled to ease testing. + // if !is_enlarge_transaction { + // let input_capacity: u32 = input_cells.iter().map(|c| c.capacity).sum(); + // let output_capacity: u32 = self.transaction.outputs.iter().map(|c| c.capacity).sum(); + // if output_capacity > input_capacity { + // return false; + // } + // } + + // check groups + let mut inputs_offset = 0; + for group in self.transaction.groups_iter() { + let middle_inputs_offset = inputs_offset + group.transform_inputs.len(); + let new_inputs_offset = middle_inputs_offset + group.destroy_inputs.len(); + + let transform_inputs = &input_cells[inputs_offset..middle_inputs_offset]; + let destroy_inputs = &input_cells[middle_inputs_offset..new_inputs_offset]; + inputs_offset = new_inputs_offset; + + let group_module = if !destroy_inputs.is_empty() { + destroy_inputs[0].module + } else if !group.create_outputs.is_empty() { + group.create_outputs[0].module + } else { + // the first consume or the first transform + transform_inputs + .iter() + .zip(group.transform_outputs) + .find(|op| { + op.0.recipient.is_some() && op.1.data.is_empty() && op.1.recipient.is_none() + }) + .map_or_else(|| transform_inputs[0].module, |op| op.0.module) + }; + + // check module + for (input_cell, input) in destroy_inputs.iter().zip(group.destroy_inputs) { + if input_cell.module != group_module { + return false; + } + if !self.transaction + .check_lock(&input_cell.lock[..], &input.unlock[..]) + { + return false; + } + } + for output in group.create_outputs { + if output.module != group_module { + return false; + } + } + for (input_cell, (input, output)) in transform_inputs + .iter() + .zip(group.transform_inputs.iter().zip(group.transform_outputs)) + { + if input_cell.module != output.module { + return false; + } + if input_cell.module != group_module + && !(input_cell + .recipient + .as_ref() + .map_or(false, |r| r.module == group_module) + && output.data.is_empty() + && output.recipient.is_none()) + { + return false; + } + + if let Some(ref r) = input_cell.recipient { + if input_cell.capacity != output.capacity || input_cell.lock != output.lock { + return false; + } + + if !self.transaction.check_lock(&r.lock[..], &input.unlock[..]) { + return false; + } + } else if !self.transaction + .check_lock(&input_cell.lock[..], &input.unlock[..]) + { + return false; + } + } + } + + // TODO: run checker + + true + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::collections::HashMap; + + struct CellMemoryDb { + cells: HashMap>, + } + impl CellProvider for CellMemoryDb { + fn cell(&self, out_point: &OutPoint) -> CellState { + match self.cells.get(out_point) { + Some(&Some(ref cell_output)) => CellState::Head(cell_output.clone()), + Some(&None) => CellState::Tail, + None => CellState::Unknown, + } + } + } + + #[test] + fn cell_provider_trait_works() { + let mut db = CellMemoryDb { + cells: HashMap::new(), + }; + + let p1 = OutPoint { + hash: 0.into(), + index: 1, + }; + let p2 = OutPoint { + hash: 0.into(), + index: 2, + }; + let p3 = OutPoint { + hash: 0.into(), + index: 3, + }; + let o = CellOutput { + module: 1, + capacity: 2, + data: vec![], + lock: vec![], + recipient: None, + }; + + db.cells.insert(p1.clone(), Some(o.clone())); + db.cells.insert(p2.clone(), None); + + assert_eq!(CellState::Head(o), db.cell(&p1)); + assert_eq!(CellState::Tail, db.cell(&p2)); + assert_eq!(CellState::Unknown, db.cell(&p3)); + } +} diff --git a/core/src/chain.rs b/core/src/chain.rs new file mode 100644 index 0000000000..d7a7060852 --- /dev/null +++ b/core/src/chain.rs @@ -0,0 +1,24 @@ +use bigint::H256; + +#[derive(Debug, Default)] +/// How to move current head to the specific head. +pub struct HeadRoute { + /// The new head hash. + pub head: H256, + + /// The hash of blocks that should be rolled back from newest to oldest. + pub rollback: Vec, + + /// The hash of blocks that should be appended from oldest to newest. + pub append: Vec, +} + +impl HeadRoute { + pub fn new(head: H256) -> HeadRoute { + HeadRoute { + head, + rollback: Vec::new(), + append: Vec::new(), + } + } +} diff --git a/core/src/lib.rs b/core/src/lib.rs index 487b440bde..65ea72aecd 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -12,6 +12,8 @@ extern crate serde; pub mod adapter; pub mod block; +pub mod cell; +pub mod chain; pub mod difficulty; pub mod error; pub mod global; diff --git a/core/src/transaction.rs b/core/src/transaction.rs index 0494be440d..78b9c88fc4 100644 --- a/core/src/transaction.rs +++ b/core/src/transaction.rs @@ -3,10 +3,9 @@ use bigint::H256; use bincode::serialize; use hash::sha3_256; -use std::iter::Zip; use std::slice::Iter; -#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] +#[derive(Clone, Default, Serialize, Deserialize, Eq, PartialEq, Hash, Debug)] pub struct OutPoint { // Hash of Transaction pub hash: H256, @@ -14,13 +13,13 @@ pub struct OutPoint { pub index: u32, } -#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] +#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Debug)] pub struct Recipient { - pub module_id: u32, + pub module: u32, pub lock: Vec, } -#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] +#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Debug)] pub struct CellInput { pub previous_output: OutPoint, // Depends on whether the operation is Transform or Destroy, this is the proof to transform @@ -28,7 +27,7 @@ pub struct CellInput { pub unlock: Vec, } -#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] +#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Debug)] pub struct CellOutput { pub module: u32, pub capacity: u32, @@ -57,14 +56,14 @@ pub struct CellOutput { // Group g2 has following operations: // // - Transform i3 -> o4 -#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] +#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)] pub struct OperationGrouping { pub transform_count: u32, pub destroy_count: u32, pub create_count: u32, } -#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] +#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)] pub struct Transaction { pub version: u32, pub inputs: Vec, @@ -72,59 +71,110 @@ pub struct Transaction { // Number of operations in each group. Sum of the numbers must equal to the size of operations // list. - pub grouping: Vec, -} - -impl Transaction { - pub fn validate(&self) -> bool { - // TODO implement it - true - } - - pub fn hash(&self) -> H256 { - sha3_256(serialize(self).unwrap()).into() - } + pub groupings: Vec, } #[derive(PartialEq, Debug)] pub struct OperationGroup<'a> { - inputs_slice: &'a [CellInput], - outputs_slice: &'a [CellOutput], - grouping: &'a OperationGrouping, + pub transform_inputs: &'a [CellInput], + pub transform_outputs: &'a [CellOutput], + pub create_outputs: &'a [CellOutput], + pub destroy_inputs: &'a [CellInput], } #[derive(Debug)] pub struct OperationGroupIter<'a> { inputs_slice: &'a [CellInput], outputs_slice: &'a [CellOutput], - grouping_iter: Iter<'a, OperationGrouping>, + groupings_iter: Iter<'a, OperationGrouping>, +} + +impl CellOutput { + pub fn bytes_len(&self) -> usize { + 8 + self.data.len() + self.lock.len() + self.recipient.as_ref().map_or(0, |r| r.bytes_len()) + } +} + +impl Recipient { + pub fn bytes_len(&self) -> usize { + 4 + self.lock.len() + } } impl Transaction { - pub fn group_iter(&self) -> OperationGroupIter { + // TODO: split it + // TODO: tells validation error + pub fn validate(&self, is_enlarge_transaction: bool) -> bool { + if is_enlarge_transaction && !(self.inputs.is_empty() && self.outputs.len() == 1) { + return false; + } + + // check outputs capacity + for output in &self.outputs { + if output.bytes_len() > (output.capacity as usize) { + return false; + } + } + + // check grouping + let mut transform_count = 0; + let mut destroy_count = 0; + let mut create_count = 0; + for grouping in &self.groupings { + if grouping.transform_count == 0 && grouping.destroy_count == 0 + && grouping.create_count == 0 + { + return false; + } + transform_count += grouping.transform_count; + destroy_count += grouping.destroy_count; + create_count += grouping.create_count; + } + + if (transform_count + destroy_count) as usize != self.inputs.len() + || (transform_count + create_count) as usize != self.outputs.len() + { + return false; + } + + true + } + + pub fn hash(&self) -> H256 { + sha3_256(serialize(self).unwrap()).into() + } + + pub fn groups_iter(&self) -> OperationGroupIter { OperationGroupIter { inputs_slice: &self.inputs[..], outputs_slice: &self.outputs[..], - grouping_iter: self.grouping.iter(), + groupings_iter: self.groupings.iter(), } } + + pub fn check_lock(&self, unlock: &[u8], lock: &[u8]) -> bool { + // TODO: check using pubkey signature + unlock.is_empty() || !lock.is_empty() + } } impl<'a> Iterator for OperationGroupIter<'a> { type Item = OperationGroup<'a>; fn next(&mut self) -> Option { - match self.grouping_iter.next() { + match self.groupings_iter.next() { Some(grouping) => { + let transform_count = grouping.transform_count as usize; let consumed_inputs_count = (grouping.transform_count + grouping.destroy_count) as usize; let consumed_outputs_count = (grouping.transform_count + grouping.create_count) as usize; let group = OperationGroup { - inputs_slice: &self.inputs_slice[0..consumed_inputs_count], - outputs_slice: &self.outputs_slice[0..consumed_outputs_count], - grouping, + transform_inputs: &self.inputs_slice[0..transform_count], + transform_outputs: &self.outputs_slice[0..transform_count], + destroy_inputs: &self.inputs_slice[transform_count..consumed_inputs_count], + create_outputs: &self.outputs_slice[transform_count..consumed_outputs_count], }; self.inputs_slice = &self.inputs_slice[consumed_inputs_count..]; @@ -135,24 +185,9 @@ impl<'a> Iterator for OperationGroupIter<'a> { None => None, } } -} -impl<'a> OperationGroup<'a> { - pub fn transform_operations(&self) -> Zip, Iter> { - let count = self.grouping.transform_count as usize; - (&self.inputs_slice[0..count]) - .iter() - .zip((&self.outputs_slice[0..count]).iter()) - } - - pub fn destroy_operations(&self) -> Iter { - let start_from = self.grouping.transform_count as usize; - (&self.inputs_slice[start_from..]).iter() - } - - pub fn create_operations(&self) -> Iter { - let start_from = self.grouping.transform_count as usize; - (&self.outputs_slice[start_from..]).iter() + fn size_hint(&self) -> (usize, Option) { + self.groupings_iter.size_hint() } } @@ -181,20 +216,20 @@ mod tests { } #[test] - fn empty_group_iter() { + fn empty_groups_iter() { let tx = Transaction { version: 0, inputs: Vec::new(), outputs: Vec::new(), - grouping: Vec::new(), + groupings: Vec::new(), }; - let mut iter = tx.group_iter(); + let mut iter = tx.groups_iter(); assert_eq!(iter.next(), None); } #[test] - fn group_iter_happy_pass() { + fn groups_iter_happy_pass() { let tx = Transaction { version: 0, inputs: [1u8, 2u8, 3u8].into_iter().map(build_cell_input).collect(), @@ -202,7 +237,7 @@ mod tests { .into_iter() .map(build_cell_output) .collect(), - grouping: vec![ + groupings: vec![ OperationGrouping { transform_count: 1, destroy_count: 1, @@ -216,44 +251,36 @@ mod tests { ], }; - let mut iter = tx.group_iter(); + let mut iter = tx.groups_iter(); if let Some(group) = iter.next() { - let transform_operations: Vec<(&CellInput, &CellOutput)> = - group.transform_operations().collect(); - let destroy_operations: Vec<&CellInput> = group.destroy_operations().collect(); - let create_operations: Vec<&CellOutput> = group.create_operations().collect(); - - assert_eq!(1, transform_operations.len()); + assert_eq!(1, group.transform_inputs.len()); + assert_eq!(1, group.transform_outputs.len()); // i1 -> o1 - assert_eq!(1, transform_operations[0].0.unlock[0]); - assert_eq!(1, transform_operations[0].1.lock[0]); + assert_eq!(1, group.transform_inputs[0].unlock[0]); + assert_eq!(1, group.transform_outputs[0].lock[0]); - assert_eq!(1, destroy_operations.len()); + assert_eq!(1, group.destroy_inputs.len()); // i2 -> x - assert_eq!(2, destroy_operations[0].unlock[0]); + assert_eq!(2, group.destroy_inputs[0].unlock[0]); - assert_eq!(2, create_operations.len()); + assert_eq!(2, group.create_outputs.len()); // x -> o2 - assert_eq!(2, create_operations[0].lock[0]); + assert_eq!(2, group.create_outputs[0].lock[0]); // x -> o3 - assert_eq!(3, create_operations[1].lock[0]); + assert_eq!(3, group.create_outputs[1].lock[0]); } else { panic!("Expect 2 groups, got 0"); } if let Some(group) = iter.next() { - let transform_operations: Vec<(&CellInput, &CellOutput)> = - group.transform_operations().collect(); - let destroy_operations: Vec<&CellInput> = group.destroy_operations().collect(); - let create_operations: Vec<&CellOutput> = group.create_operations().collect(); - - assert_eq!(1, transform_operations.len()); + assert_eq!(1, group.transform_inputs.len()); + assert_eq!(1, group.transform_outputs.len()); // i3 -> o4 - assert_eq!(3, transform_operations[0].0.unlock[0]); - assert_eq!(4, transform_operations[0].1.lock[0]); + assert_eq!(3, group.transform_inputs[0].unlock[0]); + assert_eq!(4, group.transform_outputs[0].lock[0]); - assert_eq!(0, destroy_operations.len()); - assert_eq!(0, create_operations.len()); + assert_eq!(0, group.destroy_inputs.len()); + assert_eq!(0, group.create_outputs.len()); } else { panic!("Expect 2 groups, got 1"); } diff --git a/db/src/batch.rs b/db/src/batch.rs index 17a73af26c..a0650e2974 100644 --- a/db/src/batch.rs +++ b/db/src/batch.rs @@ -1,5 +1,6 @@ use bigint::H256; use core::{block, transaction}; +use transaction_meta::TransactionMeta; #[derive(Debug)] pub enum Operation { @@ -14,6 +15,7 @@ pub enum KeyValue { BlockTransactions(H256, Vec), Meta(&'static str, Vec), Transaction(H256, Box), + TransactionMeta(H256, Box), } #[derive(Debug, PartialEq)] @@ -23,6 +25,7 @@ pub enum Key { BlockTransactions(H256), Meta(&'static str), Transaction(H256), + TransactionMeta(H256), } #[derive(Debug, PartialEq)] @@ -32,6 +35,7 @@ pub enum Value { BlockTransactions(Vec), Meta(Vec), Transaction(Box), + TransactionMeta(Box), } #[derive(Debug)] diff --git a/db/src/diskdb.rs b/db/src/diskdb.rs index 1a92cc8977..71c04e176e 100644 --- a/db/src/diskdb.rs +++ b/db/src/diskdb.rs @@ -10,6 +10,7 @@ const COLUMN_FAMILIES: &[&str] = &[ "block_transactions", "meta", "transaction", + "transaction_meta", ]; pub struct RocksKeyValueDB { @@ -69,6 +70,13 @@ impl KeyValueDB for RocksKeyValueDB { &serialize(&value).unwrap().to_vec(), )?; } + KeyValue::TransactionMeta(key, value) => { + wb.put_cf( + self.db.cf_handle(COLUMN_FAMILIES[5]).unwrap(), + &serialize(&key).unwrap().to_vec(), + &serialize(&value).unwrap().to_vec(), + )?; + } }, Operation::Delete(delete) => match delete { Key::BlockHash(key) => { @@ -101,6 +109,12 @@ impl KeyValueDB for RocksKeyValueDB { &serialize(&key).unwrap().to_vec(), )?; } + Key::TransactionMeta(key) => { + wb.delete_cf( + self.db.cf_handle(COLUMN_FAMILIES[5]).unwrap(), + &serialize(&key).unwrap().to_vec(), + )?; + } }, } } @@ -141,6 +155,12 @@ impl KeyValueDB for RocksKeyValueDB { &serialize(&key).unwrap().to_vec(), ) .map(|v| v.and_then(|ref v| Some(Value::Transaction(deserialize(v).unwrap())))), + Key::TransactionMeta(ref key) => self.db + .get_cf( + self.db.cf_handle(COLUMN_FAMILIES[5]).unwrap(), + &serialize(&key).unwrap().to_vec(), + ) + .map(|v| v.and_then(|ref v| Some(Value::TransactionMeta(deserialize(v).unwrap())))), }; result.map_err(|e| e.into()) } diff --git a/db/src/lib.rs b/db/src/lib.rs index ba974d7681..3b1d6303f4 100644 --- a/db/src/lib.rs +++ b/db/src/lib.rs @@ -5,6 +5,8 @@ extern crate nervos_core as core; extern crate nervos_util as util; extern crate rocksdb; extern crate serde; +#[macro_use] +extern crate serde_derive; pub mod batch; pub mod cachedb; @@ -12,6 +14,7 @@ pub mod diskdb; pub mod kvdb; pub mod memorydb; pub mod store; +pub mod transaction_meta; #[cfg(test)] extern crate tempdir; diff --git a/db/src/memorydb.rs b/db/src/memorydb.rs index 59b4838182..22757b288f 100644 --- a/db/src/memorydb.rs +++ b/db/src/memorydb.rs @@ -4,6 +4,7 @@ use core::block::Header; use core::transaction::Transaction; use kvdb::{KeyValueDB, Result}; use std::collections::HashMap; +use transaction_meta::TransactionMeta; use util::RwLock; #[derive(Default, Debug)] @@ -13,6 +14,7 @@ struct Inner { block_header: HashMap>, block_transactions: HashMap>, transaction: HashMap>, + transaction_meta: HashMap>, } #[derive(Default, Debug)] @@ -40,6 +42,9 @@ impl KeyValueDB for MemoryKeyValueDB { KeyValue::Transaction(key, value) => { db.transaction.insert(key, value); } + KeyValue::TransactionMeta(key, value) => { + db.transaction_meta.insert(key, value); + } }, Operation::Delete(delete) => match delete { Key::BlockHash(key) => { @@ -57,6 +62,9 @@ impl KeyValueDB for MemoryKeyValueDB { Key::Transaction(key) => { db.transaction.remove(&key); } + Key::TransactionMeta(key) => { + db.transaction_meta.remove(&key); + } }, }); Ok(()) @@ -78,6 +86,9 @@ impl KeyValueDB for MemoryKeyValueDB { Key::Transaction(ref key) => db.transaction .get(key) .and_then(|v| Some(Value::Transaction(v.clone()))), + Key::TransactionMeta(ref key) => db.transaction_meta + .get(key) + .and_then(|v| Some(Value::TransactionMeta(v.clone()))), }; Ok(result) } diff --git a/db/src/store.rs b/db/src/store.rs index a77758c6b6..e779673993 100644 --- a/db/src/store.rs +++ b/db/src/store.rs @@ -1,8 +1,11 @@ use batch::{Batch, Key, KeyValue, Value}; use bigint::H256; use core::block::{Block, Header}; +use core::chain::HeadRoute; use core::transaction::Transaction; use kvdb::KeyValueDB; +use std::collections::HashMap; +use transaction_meta::TransactionMeta; const META_HEAD_HEADER_KEY: &str = "HEAD_HEADER"; @@ -12,17 +15,68 @@ pub trait ChainStore: Sync + Send { fn get_block_hash(&self, height: u64) -> Option; fn get_block_transactions(&self, h: &H256) -> Option>; fn get_transaction(&self, h: &H256) -> Option; + fn get_transaction_meta(&self, h: &H256) -> Option; fn save_block(&self, b: &Block); - fn save_block_hash(&self, height: u64, hash: &H256); fn head_header(&self) -> Option
; - fn save_head_header(&self, h: &Header); + fn save_head_header(&self, h: &Header) -> HeadRoute; fn init(&self, genesis: &Block) -> (); + + /// Visits block headers backward to genesis. + fn headers_iter<'a>(&'a self, head: Header) -> ChainStoreBlockIterator<'a, Self> + where + Self: 'a + Sized, + { + ChainStoreBlockIterator { + store: self, + head: Some(head), + } + } +} + +pub struct ChainStoreBlockIterator<'a, T: ChainStore> +where + T: 'a, +{ + store: &'a T, + head: Option
, } pub struct ChainKVStore { pub db: Box, } +impl<'a, T: ChainStore> ChainStoreBlockIterator<'a, T> { + pub fn peek(&self) -> Option<&Header> { + self.head.as_ref() + } +} + +impl<'a, T: ChainStore> Iterator for ChainStoreBlockIterator<'a, T> { + type Item = Header; + + fn next(&mut self) -> Option { + let current_header = self.head.take(); + self.head = match current_header { + Some(ref h) => { + if h.height > 0 { + self.store.get_header(&h.pre_hash) + } else { + None + } + } + None => None, + }; + current_header + } + + fn size_hint(&self) -> (usize, Option) { + match self.head { + Some(ref h) => (1, Some(h.height as usize + 1)), + None => (0, Some(0)), + } + } +} + impl ChainKVStore { fn get(&self, key: &Key) -> Option { self.db.read(key).expect("db operation should be ok") @@ -31,13 +85,169 @@ impl ChainKVStore { fn put(&self, batch: Batch) { self.db.write(batch).expect("db operation should be ok") } + + fn save_block_with_batch(&self, batch: &mut Batch, b: &Block) { + batch.insert(KeyValue::BlockHeader(b.hash(), Box::new(b.header.clone()))); + + let txids = b.transactions + .iter() + .map(|tx| tx.hash()) + .collect::>(); + // TODO: do not save known transactions + for (tx, txid) in b.transactions.iter().zip(txids.iter()) { + batch.insert(KeyValue::Transaction(*txid, Box::new(tx.clone()))); + } + batch.insert(KeyValue::BlockTransactions(b.hash(), txids)); + } + + fn get_transaction_meta_mut_with_meta_table<'a>( + &self, + meta_table: &'a mut HashMap>, + hash: &H256, + ) -> &'a mut Option { + meta_table + .entry(*hash) + .or_insert_with(|| self.get_transaction_meta(hash)) + } + + fn append_block_with_meta_table( + &self, + meta_table: &mut HashMap>, + hash: &H256, + ) { + let height = self.get_header(hash) + .expect("block header must be stored") + .height; + for tx in self.get_block_transactions(hash) + .expect("block transactions must be stored") + { + meta_table.insert(*hash, Some(TransactionMeta::new(height, tx.outputs.len()))); + + for input in &tx.inputs { + let meta = self.get_transaction_meta_mut_with_meta_table( + meta_table, + &input.previous_output.hash, + ).as_mut() + .expect("block transaction input meta must be stored"); + + meta.set_spent(input.previous_output.index as usize, height); + } + } + } + + fn rollback_block_with_meta_table( + &self, + meta_table: &mut HashMap>, + hash: &H256, + ) { + for tx in self.get_block_transactions(hash) + .expect("block transactions must be stored") + .iter() + .rev() + { + meta_table.remove(hash); + + for input in &tx.inputs { + match self.get_transaction_meta_mut_with_meta_table( + meta_table, + &input.previous_output.hash, + ) { + &mut Some(ref mut meta) => { + meta.unset_spent(input.previous_output.index as usize) + } + meta_option => { + // TODO: TX can repear when the former one is fully spent. When rollback block, and + // an input is not found, we must restore the original tx meta. + // + // Here it is assumed that the tx is created in genisis and all outputs are + // spent in genisis + let tx = self.get_transaction(&input.previous_output.hash) + .expect("transaction must be stored"); + let mut meta = TransactionMeta::new(0, tx.outputs.len()); + for h in &mut meta.spent_at { + *h = 0; + } + meta.unset_spent(input.previous_output.index as usize); + *meta_option = Some(meta); + } + } + } + } + } + + fn save_head_header_with_batch(&self, batch: &mut Batch, h: &Header) -> HeadRoute { + let mut route = HeadRoute::new(h.hash()); + let mut append_reversed = Vec::::new(); + + match self.head_header() { + Some(old_head) => { + let mut old_head_height = old_head.height; + let mut old_head_iter = self.headers_iter(old_head); + + while old_head_height > h.height { + let current_old_head = old_head_iter.next().unwrap(); + batch.delete(Key::BlockHash(current_old_head.height)); + route.rollback.push(current_old_head.hash()); + old_head_height -= 1; + } + + let mut new_head_iter = self.headers_iter(h.clone()); + + for _ in old_head_height..h.height { + let current_new_head = new_head_iter.next().unwrap(); + let hash = current_new_head.hash(); + batch.insert(KeyValue::BlockHash(current_new_head.height, hash)); + append_reversed.push(hash); + } + + for (current_old_head, current_new_head) in old_head_iter.zip(new_head_iter) { + let old_hash = current_old_head.hash(); + let new_hash = current_new_head.hash(); + if old_hash == new_hash { + break; + } + + batch.insert(KeyValue::BlockHash(current_new_head.height, new_hash)); + route.rollback.push(old_hash); + append_reversed.push(new_hash); + } + } + None => for header in self.headers_iter(h.clone()) { + let hash = header.hash(); + batch.insert(KeyValue::BlockHash(header.height, hash)); + append_reversed.push(hash); + }, + } + + append_reversed.reverse(); + route.append = append_reversed; + + let mut meta_table = HashMap::>::new(); + for hash in &route.rollback { + self.rollback_block_with_meta_table(&mut meta_table, hash); + } + for hash in &route.append { + self.append_block_with_meta_table(&mut meta_table, hash); + } + for (hash, meta) in meta_table { + match meta { + Some(m) => batch.insert(KeyValue::TransactionMeta(hash, Box::new(m))), + None => batch.delete(Key::TransactionMeta(hash)), + } + } + + batch.insert(KeyValue::Meta(META_HEAD_HEADER_KEY, h.hash().to_vec())); + + route + } } impl ChainStore for ChainKVStore { // TODO error log fn get_block(&self, h: &H256) -> Option { self.get_header(h).and_then(|header| { - let transactions = self.get_block_transactions(h).unwrap(); + let transactions = self.get_block_transactions(h) + .expect("block transactions must be stored"); Some(Block { header, transactions, @@ -47,11 +257,7 @@ impl ChainStore for ChainKVStore { fn save_block(&self, b: &Block) { let mut batch = Batch::default(); - batch.insert(KeyValue::BlockHeader(b.hash(), Box::new(b.header.clone()))); - batch.insert(KeyValue::BlockTransactions( - b.hash(), - b.transactions.iter().map(|tx| tx.hash()).collect(), - )); + self.save_block_with_batch(&mut batch, b); self.put(batch); } @@ -78,10 +284,11 @@ impl ChainStore for ChainKVStore { }) } - fn save_block_hash(&self, height: u64, hash: &H256) { - let mut batch = Batch::default(); - batch.insert(KeyValue::BlockHash(height, *hash)); - self.put(batch); + fn get_transaction_meta(&self, h: &H256) -> Option { + self.get(&Key::TransactionMeta(*h)).and_then(|v| match v { + Value::TransactionMeta(t) => Some(*t), + _ => None, + }) } fn get_block_hash(&self, height: u64) -> Option { @@ -99,16 +306,16 @@ impl ChainStore for ChainKVStore { }) } - fn save_head_header(&self, h: &Header) { + fn save_head_header(&self, h: &Header) -> HeadRoute { let mut batch = Batch::default(); - batch.insert(KeyValue::Meta(META_HEAD_HEADER_KEY, h.hash().to_vec())); + let route = self.save_head_header_with_batch(&mut batch, h); self.put(batch); + route } fn init(&self, genesis: &Block) { self.save_block(genesis); self.save_head_header(&genesis.header); - self.save_block_hash(genesis.header.height, &genesis.hash()); } } diff --git a/db/src/transaction_meta.rs b/db/src/transaction_meta.rs new file mode 100644 index 0000000000..3bb31d0fcb --- /dev/null +++ b/db/src/transaction_meta.rs @@ -0,0 +1,37 @@ +use std::u64::MAX; + +#[derive(Default, Debug, PartialEq, Clone, Serialize, Deserialize)] +pub struct TransactionMeta { + /// Height of the last block containing the transaction. + pub height: u64, + + /// At which height the output is spent. + /// TODO: Use bitvec to save storage space? + /// u64 MAX indicates not spent yet. + pub spent_at: Vec, +} + +impl TransactionMeta { + pub fn new(height: u64, outputs_count: usize) -> TransactionMeta { + TransactionMeta { + height, + spent_at: vec![MAX; outputs_count], + } + } + + pub fn is_fully_spent(&self) -> bool { + self.spent_at.iter().all(|&x| x != MAX) + } + + pub fn is_spent(&self, index: usize) -> bool { + self.spent_at[index] != MAX + } + + pub fn set_spent(&mut self, index: usize, height: u64) { + self.spent_at[index] = height; + } + + pub fn unset_spent(&mut self, index: usize) { + self.spent_at[index] = MAX; + } +} diff --git a/default.toml b/default.toml index 63230848f3..b75c9d5fbc 100644 --- a/default.toml +++ b/default.toml @@ -3,7 +3,7 @@ signer_private_key = "0x097c1a2d03b6c8fc270991051553219e34951b656382ca951c4c226d db_path = ".nervos/db" [logger] file = "/tmp/nervos0.log" -filter = "main=info,miner=info,chain=info" +filter = "main=info,miner=info,chain=info,tx=debug" color = true [[key_pairs]] proof_public_key = "0x037151adfd9b0167d943ad816352bf0a96cfedfa15b60caddda91ad710732cb80cb54d46ce2fa9fc00" diff --git a/miner/Cargo.toml b/miner/Cargo.toml index bd06360b98..4e3a5ab8fa 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -6,6 +6,7 @@ authors = ["Nervos Core Dev "] [dependencies] log = "0.4" bigint = { path = "../util/bigint" } +nervos-util = { path = "../util" } nervos-time = { path = "../util/time" } nervos-core = { path = "../core" } nervos-pool = { path = "../pool" } diff --git a/miner/src/lib.rs b/miner/src/lib.rs index a92da351c1..0cf46d6348 100644 --- a/miner/src/lib.rs +++ b/miner/src/lib.rs @@ -6,5 +6,6 @@ extern crate nervos_core as core; extern crate nervos_db as db; extern crate nervos_pool as pool; extern crate nervos_time as time; +extern crate nervos_util as util; pub mod miner; diff --git a/miner/src/miner.rs b/miner/src/miner.rs index a7c11360cb..3f2c56c400 100644 --- a/miner/src/miner.rs +++ b/miner/src/miner.rs @@ -9,6 +9,7 @@ use pool::TransactionPool; use std::sync::Arc; use std::thread; use time::{now_ms, Duration}; +use util::Mutex; const FREQUENCY: usize = 50; @@ -17,6 +18,7 @@ pub struct Miner { pub tx_pool: Arc, pub miner_key: H160, pub signer_key: H256, + pub lock: Arc>, } impl Miner { @@ -29,6 +31,7 @@ impl Miner { loop { thread::sleep(Duration::from_millis(TIME_STEP / 10)); + let _guard = self.lock.lock(); let time = now_ms(); if time / TIME_STEP <= pre_time / TIME_STEP { continue; diff --git a/pool/Cargo.toml b/pool/Cargo.toml index ed9118ac2b..1156cac71f 100644 --- a/pool/Cargo.toml +++ b/pool/Cargo.toml @@ -4,6 +4,10 @@ version = "0.1.0" authors = ["Nervos Core Dev "] [dependencies] +log = "0.4" nervos-core = { path = "../core" } bigint = { path = "../util/bigint" } nervos-util = { path = "../util" } + +[dev-dependencies] +env_logger = "0.4" diff --git a/pool/src/lib.rs b/pool/src/lib.rs index 48bfa86546..604a5ce8c0 100644 --- a/pool/src/lib.rs +++ b/pool/src/lib.rs @@ -1,10 +1,13 @@ extern crate bigint; +#[macro_use] +extern crate log; extern crate nervos_core as core; extern crate nervos_util as util; use bigint::H256; use core::block::Block; -use core::transaction::Transaction; +use core::cell::{CellProvider, CellState}; +use core::transaction::{OutPoint, Transaction}; use std::collections::{HashMap, HashSet}; use util::RwLock; @@ -16,8 +19,9 @@ pub struct TransactionPool { impl TransactionPool { pub fn add_transaction(&self, tx: Transaction) { let mut pool = self.pool.write(); - pool.insert(tx.hash(), tx); - () + let txid = tx.hash(); + pool.insert(txid, tx); + info!(target: "pool", "inserted tx : {}", txid); } pub fn get_transactions(&self, limit: usize) -> Vec { let pool = self.pool.read(); @@ -25,7 +29,34 @@ impl TransactionPool { } /// Updates the pool with the details of a new block. pub fn accommodate(&self, _block: &Block) { - // TODO implement this + // TODO: pool should known all rollback and appended blocks. + let mut pool = self.pool.write(); + pool.clear(); + } +} + +impl CellProvider for TransactionPool { + fn cell(&self, out_point: &OutPoint) -> CellState { + let pool = self.pool.read(); + + match pool.get(&out_point.hash) { + Some(transaction) => { + if (out_point.index as usize) < transaction.inputs.len() { + // TODO: index by prev output to detect double spend more efficiently. + for (_, spend_transaction) in pool.iter() { + for input in &spend_transaction.inputs { + if &input.previous_output == out_point { + return CellState::Tail; + } + } + } + CellState::Head(transaction.outputs[out_point.index as usize].clone()) + } else { + CellState::Unknown + } + } + None => CellState::Unknown, + } } } diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 352bd4b7f8..99033320ed 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -19,7 +19,7 @@ use std::sync::Arc; build_rpc_trait! { pub trait Rpc { - // url -d '{"id": 2, "jsonrpc": "2.0", "method":"send_transaction","params": [{"version":2, "inputs":[], "outputs":[], "grouping":[]}]}' -H 'content-type:application/json' 'http://localhost:3030' + // curl -d '{"id": 2, "jsonrpc": "2.0", "method":"send_transaction","params": [{"version":2, "inputs":[], "outputs":[], "groupings":[]}]}' -H 'content-type:application/json' 'http://localhost:3030' #[rpc(name = "send_transaction")] fn send_transaction(&self, Transaction) -> Result; } @@ -31,6 +31,8 @@ struct RpcImpl { impl Rpc for RpcImpl { fn send_transaction(&self, tx: Transaction) -> Result { let result = tx.hash(); + self.network.transaction_received(tx.clone()); + // TODO: should only broadcast after validate the transaction self.network.broadcast(Broadcastable::Transaction(box tx)); Ok(result) } diff --git a/src/adapter.rs b/src/adapter.rs index 0cd4fe3827..6f699a7923 100644 --- a/src/adapter.rs +++ b/src/adapter.rs @@ -1,6 +1,7 @@ use chain::chain::Chain; use core::adapter::{ChainAdapter, NetAdapter}; use core::block::Block; +use core::cell::CellProvider; use core::global::TIME_STEP; use core::keygroup::KeyGroup; use core::transaction::Transaction; @@ -13,7 +14,7 @@ use std::sync::Arc; use std::sync::Weak; use std::thread; use time::{now_ms, Duration}; -use util::RwLock; +use util::{Mutex, RwLock}; type NetworkImpl = Network; type ChainImpl = Chain>>; @@ -63,10 +64,12 @@ pub struct NetToChainAndPoolAdapter { pending_pool: Arc, tx_pool: Arc, chain: Weak, + lock: Arc>, } impl NetAdapter for NetToChainAndPoolAdapter { fn block_received(&self, b: Block) { + let _guard = self.lock.lock(); if b.validate(&self.key_group).is_ok() { self.process_block(b); } else { @@ -74,11 +77,37 @@ impl NetAdapter for NetToChainAndPoolAdapter { } } + // TODO: the logic should not be in adapter fn transaction_received(&self, tx: Transaction) { - if tx.validate() { - self.tx_pool.add_transaction(tx) + let _guard = self.lock.lock(); + if tx.validate(false) { + let mut resolved_tx = upgrade_chain(&self.chain).resolve_transaction(tx); + if resolved_tx.is_double_spend() { + debug!(target: "tx", "tx double spends"); + // TODO process double spend tx + return; + } + self.tx_pool + .resolve_transaction_unknown_inputs(&mut resolved_tx); + if resolved_tx.is_double_spend() { + debug!(target: "tx", "tx double spends"); + // TODO process double spend tx + return; + } + if resolved_tx.is_orphan() { + // TODO add to orphan pool + debug!(target: "tx", "tx is orphan"); + } else if resolved_tx.validate(false) { + // TODO check orphan pool + self.tx_pool.add_transaction(resolved_tx.transaction); + debug!(target: "tx", "tx is added to pool"); + } else { + // TODO ban remote peer + debug!(target: "tx", "tx is invalid with resolved inputs"); + } } else { // TODO ban remote peer + debug!(target: "tx", "tx is invalid"); } } } @@ -88,6 +117,7 @@ impl NetToChainAndPoolAdapter { kg: Arc, chain: &Arc, tx_pool: Arc, + lock: Arc>, ) -> Arc { let adapter = Arc::new(NetToChainAndPoolAdapter { tx_pool, @@ -95,6 +125,7 @@ impl NetToChainAndPoolAdapter { orphan_pool: Arc::new(OrphanBlockPool::default()), pending_pool: Arc::new(PendingBlockPool::default()), chain: Arc::downgrade(chain), + lock, }); let subtask = Arc::clone(&adapter); diff --git a/src/cli/run_impl.rs b/src/cli/run_impl.rs index 00e190156e..77bd963de7 100644 --- a/src/cli/run_impl.rs +++ b/src/cli/run_impl.rs @@ -21,6 +21,8 @@ pub fn run(config: Config) { info!(target: "main", "Value for config: {:?}", config); + let lock = Arc::new(Mutex::new(())); + let db = CacheKeyValueDB::new(RocksKeyValueDB::open(&config.dirs.db)); let store = ChainKVStore { db: Box::new(db) }; @@ -38,7 +40,8 @@ pub fn run(config: Config) { let kg = Arc::new(config.key_group()); - let net_adapter = NetToChainAndPoolAdapter::new(kg, &chain, Arc::clone(&tx_pool)); + let net_adapter = + NetToChainAndPoolAdapter::new(kg, &chain, Arc::clone(&tx_pool), Arc::clone(&lock)); let network = Arc::new(Network::new(net_adapter, config.network)); @@ -49,6 +52,7 @@ pub fn run(config: Config) { tx_pool, miner_key: config.signer.miner_private_key, signer_key: bigint::H256::from(&config.signer.signer_private_key[..]), + lock, }; let network_clone = Arc::clone(&network); @@ -64,7 +68,7 @@ pub fn run(config: Config) { miner.run_loop(); }); - let rpc_server = RpcServer { config: config.rpc }; + let rpc_server = RpcServer; let network_clone = Arc::clone(&network); let _ = thread::Builder::new() .name("rpc".to_string()) diff --git a/src/cli/spec.rs b/src/cli/spec.rs index 4df4e28728..448ff84b29 100644 --- a/src/cli/spec.rs +++ b/src/cli/spec.rs @@ -11,22 +11,18 @@ pub struct NetworkConfig { pub bootstrap_nodes: Vec<(String, String)>, } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] -pub struct RpcConfig { - pub listen_addr: String, -} - #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct Spec { pub logger: LogConfig, pub network: NetworkConfig, - pub rpc: RpcConfig, } impl Default for Spec { fn default() -> Self { let logger = LogConfig { - filter: Some("main=info,miner=info,chain=info,network=debug,rpc=info".to_string()), + filter: Some( + "main=info,miner=info,chain=info,network=debug,tx=debug,pool=debug".to_string(), + ), color: true, file: Some("/tmp/nervos0.log".to_string()), }; @@ -41,15 +37,7 @@ impl Default for Spec { ], }; - let rpc = RpcConfig { - listen_addr: "0.0.0.0:0".to_string(), - }; - - Spec { - logger, - network, - rpc, - } + Spec { logger, network } } } @@ -104,8 +92,6 @@ mod tests { [network] listen_addr = "/ip4/0.0.0.0/tcp/0" bootstrap_nodes = [["QmWvoPbu9AgEFLL5UyxpCfhxkLDd9T7zuerjhHiwsnqSh4", "/ip4/127.0.0.1/tcp/12345"]] - [rpc] - listen_addr = "0.0.0.0:0" "#).expect("Spec deserialize."); assert_eq!(true, spec.logger.color); From 290c619f543f6e71f00b64ec2e5d608dcb950100 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 8 Apr 2018 15:26:23 +0800 Subject: [PATCH 13/14] docs(README): instruction to find RPC port --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 568714ab35..7f10af7563 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,8 @@ target/release/nervos ### Send Transaction via RPC +Find RPC port in the log output, the following command assumes 3030 is used: + ```shell curl -d '{"id": 2, "jsonrpc": "2.0", "method":"send_transaction","params": [{"version":2, "inputs":[], "outputs":[], "groupings":[]}]}' \ -H 'content-type:application/json' 'http://localhost:3030' From b732762479127c00f0d1bec66fd3ccad9e97eba4 Mon Sep 17 00:00:00 2001 From: ian Date: Mon, 19 Nov 2018 17:43:35 +0800 Subject: [PATCH 14/14] chore: Resolve merge conflicts --- src/cli/run_impl.rs | 2 +- src/cli/spec.rs | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/cli/run_impl.rs b/src/cli/run_impl.rs index 77bd963de7..6b6d772bde 100644 --- a/src/cli/run_impl.rs +++ b/src/cli/run_impl.rs @@ -68,7 +68,7 @@ pub fn run(config: Config) { miner.run_loop(); }); - let rpc_server = RpcServer; + let rpc_server = RpcServer { config: config.rpc }; let network_clone = Arc::clone(&network); let _ = thread::Builder::new() .name("rpc".to_string()) diff --git a/src/cli/spec.rs b/src/cli/spec.rs index 448ff84b29..4e8a0258cc 100644 --- a/src/cli/spec.rs +++ b/src/cli/spec.rs @@ -11,17 +11,24 @@ pub struct NetworkConfig { pub bootstrap_nodes: Vec<(String, String)>, } +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct RpcConfig { + pub listen_addr: String, +} + #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct Spec { pub logger: LogConfig, pub network: NetworkConfig, + pub rpc: RpcConfig, } impl Default for Spec { fn default() -> Self { let logger = LogConfig { filter: Some( - "main=info,miner=info,chain=info,network=debug,tx=debug,pool=debug".to_string(), + "main=info,miner=info,chain=info,network=debug,tx=debug,pool=debug,rpc=info" + .to_string(), ), color: true, file: Some("/tmp/nervos0.log".to_string()), @@ -37,7 +44,15 @@ impl Default for Spec { ], }; - Spec { logger, network } + let rpc = RpcConfig { + listen_addr: "0.0.0.0:0".to_string(), + }; + + Spec { + logger, + network, + rpc, + } } } @@ -92,6 +107,8 @@ mod tests { [network] listen_addr = "/ip4/0.0.0.0/tcp/0" bootstrap_nodes = [["QmWvoPbu9AgEFLL5UyxpCfhxkLDd9T7zuerjhHiwsnqSh4", "/ip4/127.0.0.1/tcp/12345"]] + [rpc] + listen_addr = "0.0.0.0:0" "#).expect("Spec deserialize."); assert_eq!(true, spec.logger.color);