diff --git a/Cargo.lock b/Cargo.lock index 3b9bcf77..227c4c7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,7 +19,7 @@ dependencies = [ [[package]] name = "abstract-ns" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -127,21 +127,21 @@ dependencies = [ "bitcrypto 0.1.0", "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "primitives 0.1.0", - "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "serialization 0.1.0", ] [[package]] name = "clap" -version = "2.19.0" +version = "2.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "term_size 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -167,7 +167,7 @@ version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -180,6 +180,7 @@ dependencies = [ "elastic-array 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-devtools 1.3.0", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lru-cache 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "primitives 0.1.0", "rocksdb 0.4.5 (git+https://github.com/ethcore/rust-rocksdb)", @@ -231,10 +232,10 @@ version = "0.5.6" source = "git+https://github.com/ethcore/rust-secp256k1#f998f9a8c18227af200f0f7fdadf8a6560d391ff" dependencies = [ "arrayvec 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", - "gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.39 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -264,7 +265,7 @@ dependencies = [ [[package]] name = "gcc" -version = "0.3.38" +version = "0.3.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rayon 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -294,7 +295,7 @@ dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rotor 0.6.3 (git+https://github.com/ethcore/rotor)", - "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "spmc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -330,10 +331,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "jsonrpc-core" version = "4.0.0" -source = "git+https://github.com/ethcore/jsonrpc.git#1500da1b9613a0a17fc0109d825f3ccc60199a53" +source = "git+https://github.com/ethcore/jsonrpc.git#140257f1a726e9190bdaafeb4625b2a5400de4da" dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -342,7 +343,7 @@ dependencies = [ [[package]] name = "jsonrpc-http-server" version = "6.1.1" -source = "git+https://github.com/ethcore/jsonrpc.git#1500da1b9613a0a17fc0109d825f3ccc60199a53" +source = "git+https://github.com/ethcore/jsonrpc.git#140257f1a726e9190bdaafeb4625b2a5400de4da" dependencies = [ "hyper 0.10.0-a.0 (git+https://github.com/ethcore/hyper)", "jsonrpc-core 4.0.0 (git+https://github.com/ethcore/jsonrpc.git)", @@ -350,6 +351,15 @@ dependencies = [ "unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "jsonrpc-macros" +version = "0.1.0" +source = "git+https://github.com/ethcore/jsonrpc.git#140257f1a726e9190bdaafeb4625b2a5400de4da" +dependencies = [ + "jsonrpc-core 4.0.0 (git+https://github.com/ethcore/jsonrpc.git)", + "serde 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -369,7 +379,7 @@ dependencies = [ "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "primitives 0.1.0", "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -389,7 +399,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.17" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "linked-hash-map" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -412,6 +427,14 @@ dependencies = [ "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lru-cache" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "linked-hash-map 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "matches" version = "0.1.4" @@ -422,7 +445,7 @@ name = "memchr" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -464,11 +487,11 @@ dependencies = [ [[package]] name = "mio" version = "0.6.1" -source = "git+https://github.com/ethcore/mio.git#ef182bae193a9c7457cd2cf661fcaffb226e3eef" +source = "git+https://github.com/ethcore/mio.git#15a577039bed3c72f2952459f8ad687a56f63e29" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)", @@ -484,7 +507,7 @@ 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)", "lazycell 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)", @@ -519,7 +542,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 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)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -540,7 +563,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -559,7 +582,7 @@ name = "ns-dns-tokio" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "abstract-ns 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "abstract-ns 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "domain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -575,7 +598,7 @@ name = "num_cpus" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -601,7 +624,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "p2p" version = "0.1.0" dependencies = [ - "abstract-ns 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "abstract-ns 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "bitcrypto 0.1.0", "csv 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -618,17 +641,6 @@ dependencies = [ "tokio-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "parking_lot" -version = "0.2.8" -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.17 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "parking_lot" version = "0.3.6" @@ -644,7 +656,7 @@ version = "0.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.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -657,7 +669,7 @@ dependencies = [ "app_dirs 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "bencher 0.1.0", "chain 0.1.0", - "clap 2.19.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.19.2 (registry+https://github.com/rust-lang/crates.io-index)", "db 0.1.0", "env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "import 0.1.0", @@ -679,7 +691,7 @@ name = "primitives" version = "0.1.0" dependencies = [ "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -721,7 +733,7 @@ name = "rand" version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -730,7 +742,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "deque 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -757,7 +769,7 @@ name = "rocksdb" version = "0.4.5" source = "git+https://github.com/ethcore/rust-rocksdb#64c63ccbe1f62c2e2b39262486f9ba813793af58" dependencies = [ - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "rocksdb-sys 0.3.0 (git+https://github.com/ethcore/rust-rocksdb)", ] @@ -766,8 +778,8 @@ name = "rocksdb-sys" version = "0.3.0" source = "git+https://github.com/ethcore/rust-rocksdb#64c63ccbe1f62c2e2b39262486f9ba813793af58" dependencies = [ - "gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.39 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -790,12 +802,13 @@ dependencies = [ "db 0.1.0", "jsonrpc-core 4.0.0 (git+https://github.com/ethcore/jsonrpc.git)", "jsonrpc-http-server 6.1.1 (git+https://github.com/ethcore/jsonrpc.git)", + "jsonrpc-macros 0.1.0 (git+https://github.com/ethcore/jsonrpc.git)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "miner 0.1.0", "network 0.1.0", "p2p 0.1.0", "primitives 0.1.0", - "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -812,16 +825,16 @@ name = "rust-crypto" version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.39 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-serialize" -version = "0.3.21" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1002,9 +1015,9 @@ name = "syntex_errors" version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_pos 0.44.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1015,7 +1028,7 @@ name = "syntex_pos" version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1024,9 +1037,9 @@ version = "0.44.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_errors 0.44.0 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_pos 0.44.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1048,7 +1061,7 @@ version = "0.2.1" 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.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1068,7 +1081,7 @@ version = "2.0.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.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1085,7 +1098,7 @@ version = "0.1.35" 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.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1124,7 +1137,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-segmentation" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1205,7 +1218,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] -"checksum abstract-ns 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "179c25175ddfb957808aab46c48dd7d0c66a366bff79363813b527447c9f620c" +"checksum abstract-ns 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ebf235e1c1f96a1501b02842111e95b81132df346eee751131779a2adca8090" "checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" "checksum app_dirs 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7d1c0d48a81bbb13043847f957971f4d87c81542d80ece5e84ba3cba4058fd4" @@ -1217,7 +1230,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" -"checksum clap 2.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef87e92396a3d29bf7e611c8a595be35ae90d9cb844a3571425900eaca4f51c8" +"checksum clap 2.19.2 (registry+https://github.com/rust-lang/crates.io-index)" = "305ad043f009db535a110200541d4567b63e172b1fe030313fbb92565da7ed24" "checksum cookie 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d53b80dde876f47f03cda35303e368a79b91c70b0d65ecba5fd5280944a08591" "checksum crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0c5ea215664ca264da8a9d9c3be80d2eaf30923c259d03e870388eb927508f97" "checksum csv 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)" = "266c1815d7ca63a5bd86284043faf91e8c95e943e55ce05dc0ae08e952de18bc" @@ -1229,7 +1242,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum eth-secp256k1 0.5.6 (git+https://github.com/ethcore/rust-secp256k1)" = "" "checksum futures 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bad0a2ac64b227fdc10c254051ae5af542cf19c9328704fd4092f7914196897" "checksum futures-cpupool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bb982bb25cd8fa5da6a8eb3a460354c984ff1113da82bcb4f0b0862b5795db82" -"checksum gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)" = "553f11439bdefe755bf366b264820f1da70f3aaf3924e594b886beb9c831bcf5" +"checksum gcc 0.3.39 (registry+https://github.com/rust-lang/crates.io-index)" = "771e4a97ff6f237cf0f7d5f5102f6e28bb9743814b6198d684da5c58b76c11e0" "checksum heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8c80e194758495a9109566134dc06e42ea0423987d6ceca016edaa90381b3549" "checksum httparse 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a6e7a63e511f9edffbab707141fbb8707d1a3098615fb2adbd5769cdfcc9b17d" "checksum hyper 0.10.0-a.0 (git+https://github.com/ethcore/hyper)" = "" @@ -1237,13 +1250,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum itoa 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae3088ea4baeceb0284ee9eea42f591226e6beaecf65373e41b38d95a1b8e7a1" "checksum jsonrpc-core 4.0.0 (git+https://github.com/ethcore/jsonrpc.git)" = "" "checksum jsonrpc-http-server 6.1.1 (git+https://github.com/ethcore/jsonrpc.git)" = "" +"checksum jsonrpc-macros 0.1.0 (git+https://github.com/ethcore/jsonrpc.git)" = "" "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.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b" "checksum lazycell 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce12306c4739d86ee97c23139f3a34ddf0387bbf181bc7929d287025a8c3ef6b" -"checksum libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "044d1360593a78f5c8e5e710beccdc24ab71d1f01bc19a29bcacdba22e8475d8" +"checksum libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "a51822fc847e7a8101514d1d44e354ba2ffa7d4c194dcab48870740e327cac70" +"checksum linked-hash-map 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bda158e0dabeb97ee8a401f4d17e479d6b891a14de0bba79d5cc2d4d325b5e48" "checksum linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" "checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054" +"checksum lru-cache 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "656fa4dfcb02bcf1063c592ba3ff6a5303ee1f2afe98c8a889e8b1a77c6dfdb7" "checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1" "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" "checksum mime 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b5c93a4bd787ddc6e7833c519b73a50883deb5863d76d9b71eb8216fb7f94e66" @@ -1260,7 +1276,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum odds 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)" = "c3df9b730298cea3a1c3faa90b7e2f9df3a9c400d0936d6015e6165734eefcba" "checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" "checksum owning_ref 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8d91377085359426407a287ab16884a0111ba473aa6844ff01d4ec20ce3d75e7" -"checksum parking_lot 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "968f685642555d2f7e202c48b8b11de80569e9bfea817f7f12d7c61aac62d4e6" "checksum parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e1435e7a2a00dfebededd6c6bdbd54008001e94b4a2aadd6aef0dc4c56317621" "checksum parking_lot_core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb1b97670a2ffadce7c397fb80a3d687c4f3060140b885621ef1653d0e5d5068" "checksum quasi 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)" = "94a532453b931a4483a5b2e40f0fe04aee35b6bc2c0eeec876f1bd2358a134d3" @@ -1275,7 +1290,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rocksdb-sys 0.3.0 (git+https://github.com/ethcore/rust-rocksdb)" = "" "checksum rotor 0.6.3 (git+https://github.com/ethcore/rotor)" = "" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" -"checksum rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)" = "bff9fc1c79f2dec76b253273d07682e94a978bd8f132ded071188122b2af9818" +"checksum rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "237546c689f20bb44980270c73c3b9edd0891c1be49cc1274406134a66d3957b" "checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" "checksum scoped-pool 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "817a3a15e704545ce59ed2b5c60a5d32bda4d7869befb8b36667b658a6c00b43" "checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d" @@ -1305,7 +1320,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "13a5906ca2b98c799f4b1ab4557b76367ebd6ae5ef14930ec841c74aed5f3764" "checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f" "checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172" -"checksum unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b905d0fc2a1f0befd86b0e72e31d1787944efef9d38b9358a9e92a69757f7e3b" +"checksum unicode-segmentation 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c3bc443ded17b11305ffffe6b37e2076f328a5a8cb6aa877b1b98f77699e98b5" "checksum unicode-width 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2d6722facc10989f63ee0e20a83cd4e1714a9ae11529403ac7e0afd069abc39e" "checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb" "checksum url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "48ccf7bd87a81b769cf84ad556e034541fb90e1cd6d4bc375c822ed9500cd9d7" diff --git a/README.md b/README.md index 41b18b54..317d4daa 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ The Parity Bitcoin client ![Graph][graph] -[graph]: https://github.com/ethcore/parity-bitcoin/blob/master/tools/graph.png +[graph]: https://github.com/ethcore/parity-bitcoin/blob/master/tools/graph.svg [travis-image]: https://travis-ci.com/ethcore/parity-bitcoin.svg?token=DMFvZu71iaTbUYx9UypX&branch=master [travis-url]: https://travis-ci.com/ethcore/parity-bitcoin [doc-url]: https://ethcore.github.io/parity-bitcoin/pbtc/index.html diff --git a/db/Cargo.toml b/db/Cargo.toml index c75acc83..dd92e8d1 100644 --- a/db/Cargo.toml +++ b/db/Cargo.toml @@ -15,6 +15,7 @@ parking_lot = "0.3" test-data = { path = "../test-data" } bit-vec = "0.4" log = "0.3" +lru-cache = "0.1.0" [features] dev = [] diff --git a/db/src/indexed_block.rs b/db/src/indexed_block.rs index ad178160..0f06d3bd 100644 --- a/db/src/indexed_block.rs +++ b/db/src/indexed_block.rs @@ -1,158 +1,66 @@ -use chain; use primitives::hash::H256; -use serialization::Serializable; +use chain::{Block, OutPoint, TransactionOutput, merkle_root}; +use serialization::{Serializable, CompactInteger}; +use indexed_header::IndexedBlockHeader; +use indexed_transaction::IndexedTransaction; use PreviousTransactionOutputProvider; -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct IndexedBlock { - header: chain::BlockHeader, - header_hash: H256, - transactions: Vec, - // guaranteed to be the same length as transactions - transaction_hashes: Vec, + pub header: IndexedBlockHeader, + pub transactions: Vec, } impl PreviousTransactionOutputProvider for IndexedBlock { - fn previous_transaction_output(&self, prevout: &chain::OutPoint) -> Option { - self.transaction(&prevout.hash) - .and_then(|tx| tx.outputs.get(prevout.index as usize)) - .cloned() + fn previous_transaction_output(&self, prevout: &OutPoint) -> Option { + let txs: &[_] = &self.transactions; + txs.previous_transaction_output(prevout) } - fn is_spent(&self, _prevout: &chain::OutPoint) -> bool { - // block does not need it to be checked + fn is_spent(&self, _prevout: &OutPoint) -> bool { false } } -impl From for IndexedBlock { - fn from(block: chain::Block) -> Self { - let chain::Block { block_header, transactions } = block; - let header_hash = block_header.hash(); - let hashes = transactions.iter().map(chain::Transaction::hash).collect(); +impl From for IndexedBlock { + fn from(block: Block) -> Self { + let Block { block_header, transactions } = block; IndexedBlock { - header: block_header, - header_hash: header_hash, - transactions: transactions, - transaction_hashes: hashes, + header: block_header.into(), + transactions: transactions.into_iter().map(Into::into).collect(), } } } impl IndexedBlock { - pub fn new(header: chain::BlockHeader, transaction_index: Vec<(H256, chain::Transaction)>) -> Self { - let mut block = IndexedBlock { - header_hash: header.hash(), + pub fn new(header: IndexedBlockHeader, transactions: Vec) -> Self { + IndexedBlock { header: header, - transactions: Vec::with_capacity(transaction_index.len()), - transaction_hashes: Vec::with_capacity(transaction_index.len()), - }; - - for (h256, tx) in transaction_index { - block.transactions.push(tx); - block.transaction_hashes.push(h256); + transactions: transactions, } - - block - } - - pub fn transaction(&self, hash: &H256) -> Option<&chain::Transaction> { - self.transaction_hashes.iter() - .position(|x| x == hash) - .map(|position| &self.transactions[position]) - } - - pub fn transactions(&self) -> IndexedTransactions { - IndexedTransactions { - position: 0, - block: self, - } - } - - pub fn transaction_hashes(&self) -> &[H256] { - &self.transaction_hashes - } - - pub fn header(&self) -> &chain::BlockHeader { - &self.header } pub fn hash(&self) -> &H256 { - &self.header_hash + &self.header.hash } - pub fn transaction_count(&self) -> usize { - self.transaction_hashes.len() - } - - pub fn to_block(&self) -> chain::Block { - chain::Block::new( - self.header.clone(), - self.transactions.clone(), - ) + pub fn to_raw_block(self) -> Block { + Block::new(self.header.raw, self.transactions.into_iter().map(|tx| tx.raw).collect()) } pub fn size(&self) -> usize { - // todo: optimize - self.to_block().serialized_size() + let header_size = self.header.raw.serialized_size(); + let txs_len_size = CompactInteger::from(self.transactions.len()).serialized_size(); + let txs_size = self.transactions.iter().map(|tx| tx.raw.serialized_size()).sum::(); + header_size + txs_len_size + txs_size } pub fn merkle_root(&self) -> H256 { - chain::merkle_root(&self.transaction_hashes) + merkle_root(&self.transactions.iter().map(|tx| tx.hash.clone()).collect::>()) } pub fn is_final(&self, height: u32) -> bool { - self.transactions.iter().all(|t| t.is_final(height, self.header.time)) - } - - pub fn transaction_at(&self, index: usize) -> (&H256, &chain::Transaction) { - (&self.transaction_hashes[index], &self.transactions[index]) - } -} - -pub struct IndexedTransactions<'a> { - position: usize, - block: &'a IndexedBlock, -} - -impl<'a> Iterator for IndexedTransactions<'a> { - type Item = (&'a H256, &'a chain::Transaction); - - fn next(&mut self) -> Option<(&'a H256, &'a chain::Transaction)> { - if self.position >= self.block.transactions.len() { - None - } - else { - let result = Some((&self.block.transaction_hashes[self.position], &self.block.transactions[self.position])); - self.position += 1; - result - } - } -} - -#[cfg(test)] -mod tests { - use test_data; - use super::IndexedBlock; - - #[test] - fn index() { - let block = test_data::block_h1(); - let indexed_block: IndexedBlock = block.clone().into(); - - assert_eq!(*indexed_block.transactions().nth(0).unwrap().0, block.transactions()[0].hash()); - } - - #[test] - fn iter() { - let block = test_data::block_builder() - .header().build() - .transaction().coinbase().output().value(3).build().build() - .transaction().coinbase().output().value(5).build().build() - .build(); - let indexed_block: IndexedBlock = block.clone().into(); - - assert_eq!(*indexed_block.transactions().nth(1).unwrap().0, block.transactions()[1].hash()); + self.transactions.iter().all(|tx| tx.raw.is_final(height, self.header.raw.time)) } } diff --git a/db/src/indexed_header.rs b/db/src/indexed_header.rs new file mode 100644 index 00000000..df117833 --- /dev/null +++ b/db/src/indexed_header.rs @@ -0,0 +1,26 @@ +use primitives::hash::H256; +use chain::BlockHeader; + +#[derive(Debug, Clone)] +pub struct IndexedBlockHeader { + pub hash: H256, + pub raw: BlockHeader, +} + +impl From for IndexedBlockHeader { + fn from(header: BlockHeader) -> Self { + IndexedBlockHeader { + hash: header.hash(), + raw: header, + } + } +} + +impl IndexedBlockHeader { + pub fn new(hash: H256, header: BlockHeader) -> Self { + IndexedBlockHeader { + hash: hash, + raw: header, + } + } +} diff --git a/db/src/indexed_transaction.rs b/db/src/indexed_transaction.rs index 14aaf100..6ac70e2c 100644 --- a/db/src/indexed_transaction.rs +++ b/db/src/indexed_transaction.rs @@ -3,18 +3,26 @@ use primitives::hash::H256; use chain::{Transaction, OutPoint, TransactionOutput}; use PreviousTransactionOutputProvider; -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct IndexedTransaction { - pub transaction: Transaction, pub hash: H256, + pub raw: Transaction, } impl From for IndexedTransaction { - fn from(t: Transaction) -> Self { - let hash = t.hash(); + fn from(tx: Transaction) -> Self { + IndexedTransaction { + hash: tx.hash(), + raw: tx, + } + } +} + +impl IndexedTransaction { + pub fn new(hash: H256, transaction: Transaction) -> Self { IndexedTransaction { - transaction: t, hash: hash, + raw: transaction, } } } @@ -29,7 +37,8 @@ impl<'a> PreviousTransactionOutputProvider for &'a [IndexedTransaction] { fn previous_transaction_output(&self, prevout: &OutPoint) -> Option { self.iter() .find(|tx| tx.hash == prevout.hash) - .map(|tx| tx.transaction.outputs[prevout.index as usize].clone()) + .and_then(|tx| tx.raw.outputs.get(prevout.index as usize)) + .cloned() } fn is_spent(&self, _prevout: &OutPoint) -> bool { diff --git a/db/src/lib.rs b/db/src/lib.rs index 6ee59779..6d8ed2cb 100644 --- a/db/src/lib.rs +++ b/db/src/lib.rs @@ -9,6 +9,7 @@ extern crate chain; extern crate serialization; extern crate bit_vec; #[macro_use] extern crate log; +extern crate lru_cache; #[cfg(test)] extern crate ethcore_devtools as devtools; @@ -28,6 +29,7 @@ mod transaction_meta_provider; mod error; mod update_context; mod indexed_block; +mod indexed_header; mod indexed_transaction; #[derive(Debug, Clone)] @@ -72,8 +74,9 @@ pub use transaction_provider::{TransactionProvider, AsTransactionProvider, Previ pub use transaction_meta_provider::TransactionMetaProvider; pub use block_stapler::{BlockStapler, BlockInsertedChain}; pub use block_provider::{BlockProvider, BlockHeaderProvider, AsBlockHeaderProvider}; -pub use indexed_block::{IndexedBlock, IndexedTransactions}; -pub use indexed_transaction::{IndexedTransaction}; +pub use indexed_block::IndexedBlock; +pub use indexed_header::IndexedBlockHeader; +pub use indexed_transaction::IndexedTransaction; #[cfg(feature="dev")] pub use test_storage::TestStorage; diff --git a/db/src/storage.rs b/db/src/storage.rs index bd675d25..d6efc175 100644 --- a/db/src/storage.rs +++ b/db/src/storage.rs @@ -6,12 +6,13 @@ use kvdb::{Database, DatabaseConfig}; use byteorder::{LittleEndian, ByteOrder}; use primitives::hash::H256; use primitives::bytes::Bytes; -use super::{BlockRef, BestBlock, BlockLocation, IndexedBlock, IndexedTransactions}; +use super::{BlockRef, BestBlock, BlockLocation, IndexedBlock}; use serialization::{serialize, deserialize}; use chain; use parking_lot::RwLock; -use transaction_meta::TransactionMeta; +use lru_cache::LruCache; +use transaction_meta::TransactionMeta; use error::{Error, ConsistencyError, MetaError}; use update_context::UpdateContext; use block_provider::{BlockProvider, BlockHeaderProvider, AsBlockHeaderProvider}; @@ -19,6 +20,9 @@ use transaction_provider::TransactionProvider; use transaction_meta_provider::TransactionMetaProvider; use block_stapler::{BlockStapler, BlockInsertedChain, Reorganization}; +use indexed_header::IndexedBlockHeader; +use indexed_transaction::IndexedTransaction; + pub const COL_COUNT: u32 = 10; pub const COL_META: u32 = 0; pub const COL_BLOCK_HASHES: u32 = 1; @@ -36,6 +40,7 @@ const DB_VERSION: u32 = 1; // TODO: check how bitcoin core deals with long forks const MAX_FORK_ROUTE_PRESET: usize = 2048; +const TRANSACTION_CACHE_SIZE: usize = 524288; /// Blockchain storage interface pub trait Store : BlockProvider + BlockStapler + TransactionProvider + TransactionMetaProvider + AsBlockHeaderProvider { @@ -50,6 +55,8 @@ pub trait Store : BlockProvider + BlockStapler + TransactionProvider + Transacti pub struct Storage { database: Database, best_block: RwLock>, + transaction_cache: RwLock>, + meta_cache: RwLock>, } const KEY_VERSION: &'static[u8] = b"version"; @@ -83,6 +90,8 @@ impl Storage { let storage = Storage { database: db, best_block: RwLock::default(), + transaction_cache: RwLock::new(LruCache::new(TRANSACTION_CACHE_SIZE)), + meta_cache: RwLock::new(LruCache::new(TRANSACTION_CACHE_SIZE)), }; match storage.read_meta_u32(KEY_VERSION) { @@ -166,32 +175,34 @@ impl Storage { fn block_by_hash(&self, h: &H256) -> Option { self.block_header_by_hash(h).map(|header| { let tx_hashes = self.block_transaction_hashes_by_hash(h); - let txs = tx_hashes.iter() - .map(|tx_hash| self.transaction(tx_hash).expect("Missing transaction, possible db corruption")) + let txs = tx_hashes.into_iter() + .map(|tx_hash| { + let tx = self.transaction(&tx_hash).expect("Missing transaction, possible db corruption"); + IndexedTransaction::new(tx_hash, tx) + }) .collect::>(); - let tx_index = tx_hashes.into_iter().zip(txs.into_iter()).collect(); - IndexedBlock::new(header, tx_index) + IndexedBlock::new(IndexedBlockHeader::new(h.clone(), header), txs) }) } /// update transactions metadata in the specified database transaction - fn update_transactions_meta(&self, context: &mut UpdateContext, number: u32, accepted_txs: &mut IndexedTransactions) + fn update_transactions_meta(&self, context: &mut UpdateContext, number: u32, accepted_txs: &[IndexedTransaction]) -> Result<(), Error> { - if let Some((accepted_hash, accepted_tx)) = accepted_txs.next() { + if let Some(tx) = accepted_txs.first() { context.meta.insert( - accepted_hash.clone(), - TransactionMeta::new_coinbase(number, accepted_tx.outputs.len()) + tx.hash.clone(), + TransactionMeta::new_coinbase(number, tx.raw.outputs.len()) ); } - for (accepted_hash, accepted_tx) in accepted_txs { + for tx in accepted_txs.iter().skip(1) { context.meta.insert( - accepted_hash.clone(), - TransactionMeta::new(number, accepted_tx.outputs.len()) + tx.hash.clone(), + TransactionMeta::new(number, tx.raw.outputs.len()) ); - for input in &accepted_tx.inputs { + for input in &tx.raw.inputs { use std::collections::hash_map::Entry; match context.meta.entry(input.previous_output.hash.clone()) { @@ -239,8 +250,9 @@ impl Storage { let tx = self.transaction(tx_hash) .expect("Transaction in the saved block should exist as a separate entity indefinitely"); - // remove meta + // remove meta & meta cache context.db_transaction.delete(Some(COL_TRANSACTIONS_META), &**tx_hash); + self.meta_cache.write().remove(&tx_hash); // coinbase transaction does not have inputs if tx_hash_num == 0 { @@ -295,7 +307,7 @@ impl Storage { self.read_meta_u32(KEY_BEST_BLOCK_NUMBER) } - fn _best_hash(&self) -> Option { + fn best_hash(&self) -> Option { self.get(COL_META, KEY_BEST_BLOCK_HASH).map(|val| H256::from(&**val)) } @@ -303,7 +315,7 @@ impl Storage { trace!(target: "db", "Canonizing block {}", hash.to_reversed_str()); let block = try!(self.block_by_hash(hash).ok_or(Error::unknown_hash(hash))); - try!(self.update_transactions_meta(context, at_height, &mut block.transactions())); + try!(self.update_transactions_meta(context, at_height, &block.transactions)); // only canonical blocks are allowed to wield a number context.db_transaction.put(Some(COL_BLOCK_HASHES), &u32_key(at_height), &**hash); @@ -397,6 +409,14 @@ impl Storage { best_number -= 1; result.push(next); } + + } + + pub fn difficulty(&self) -> f64 { + self.best_hash() + .and_then(|h| self.block_header_by_hash(&h)) + .map(|header| header.bits.to_f64()) + .unwrap_or(1.0f64) } } @@ -470,7 +490,7 @@ impl BlockStapler for Storage { let block_hash = block.hash(); let mut new_best_hash = match best_block.as_ref().map(|bb| &bb.hash) { - Some(best_hash) if &block.header().previous_header_hash != best_hash => best_hash.clone(), + Some(best_hash) if &block.header.raw.previous_header_hash != best_hash => best_hash.clone(), _ => block_hash.clone(), }; @@ -482,14 +502,14 @@ impl BlockStapler for Storage { None => 0, }; - let tx_space = block.transaction_count() * 32; + let tx_space = block.transactions.len() * 32; let mut tx_refs = Vec::with_capacity(tx_space); - for (tx_hash, tx) in block.transactions() { - tx_refs.extend(&**tx_hash); + for tx in &block.transactions { + tx_refs.extend(&*tx.hash); context.db_transaction.put( Some(COL_TRANSACTIONS), - &**tx_hash, - &serialize(tx), + &*tx.hash, + &serialize(&tx.raw), ); } context.db_transaction.put(Some(COL_BLOCK_TRANSACTIONS), &**block_hash, &tx_refs); @@ -497,12 +517,12 @@ impl BlockStapler for Storage { context.db_transaction.put( Some(COL_BLOCK_HEADERS), &**block_hash, - &serialize(block.header()) + &serialize(&block.header.raw) ); // the block is continuing the main chain let result = if best_block.as_ref().map(|b| b.number) != Some(new_best_number) { - try!(self.update_transactions_meta(&mut context, new_best_number, &mut block.transactions())); + try!(self.update_transactions_meta(&mut context, new_best_number, &block.transactions)); context.db_transaction.write_u32(Some(COL_META), KEY_BEST_BLOCK_NUMBER, new_best_number); // updating main chain height reference @@ -516,14 +536,14 @@ impl BlockStapler for Storage { // but can cause reorganization here // this can canonize the block parent if block parent + this block is longer than the main chain else { - match self.maybe_reorganize(&mut context, &block.header().previous_header_hash) { + match self.maybe_reorganize(&mut context, &block.header.raw.previous_header_hash) { Ok(Some(mut reorg)) => { // if so, we have new best main chain block new_best_number = reorg.height + 1; new_best_hash = block_hash.clone(); // and we canonize it also by provisioning transactions - try!(self.update_transactions_meta(&mut context, new_best_number, &mut block.transactions())); + try!(self.update_transactions_meta(&mut context, new_best_number, &block.transactions)); context.db_transaction.write_u32(Some(COL_META), KEY_BEST_BLOCK_NUMBER, new_best_number); context.db_transaction.put(Some(COL_BLOCK_HASHES), &u32_key(new_best_number), &*new_best_hash); context.db_transaction.write_u32(Some(COL_BLOCK_NUMBERS), &*new_best_hash, new_best_number); @@ -585,7 +605,11 @@ impl BlockStapler for Storage { // we always update best hash even if it is not changed context.db_transaction.put(Some(COL_META), KEY_BEST_BLOCK_HASH, &*new_best_hash); - // write accumulated transactions meta + // write accumulated transactions meta and update cache + { + let mut cache = self.meta_cache.write(); + for (hash, meta) in context.meta.iter() { cache.insert(hash.clone(), meta.clone()); } + } try!(context.apply(&self.database)); trace!(target: "db", "Best block now ({}, {})", &new_best_hash.to_reversed_str(), &new_best_number); @@ -625,18 +649,57 @@ impl TransactionProvider for Storage { } fn transaction(&self, hash: &H256) -> Option { - self.transaction_bytes(hash).map(|tx_bytes| { - deserialize(tx_bytes.as_ref()).expect("Failed to deserialize transaction: db corrupted?") - }) + let mut cache = self.transaction_cache.write(); + + let (tx, is_cached) = { + let cached_transaction = cache.get_mut(hash); + match cached_transaction { + None => { + ( + self.transaction_bytes(hash).map(|tx_bytes| { + let tx: chain::Transaction = deserialize(tx_bytes.as_ref()) + .expect("Failed to deserialize transaction: db corrupted?"); + tx + }), + false + ) + }, + Some(tx) => (Some(tx.clone()), true) + } + }; + + match tx { + Some(ref tx) => { if !is_cached { cache.insert(hash.clone(), tx.clone()); } } + None => {} + }; + + tx } } impl TransactionMetaProvider for Storage { fn transaction_meta(&self, hash: &H256) -> Option { - self.get(COL_TRANSACTIONS_META, &**hash).map(|val| - TransactionMeta::from_bytes(&val).expect("Invalid transaction metadata: db corrupted?") - ) + let mut cache = self.meta_cache.write(); + + let (meta, is_cached) = { + let cached_meta = cache.get_mut(hash); + match cached_meta { + None => { + (self.get(COL_TRANSACTIONS_META, &**hash).map(|val| + TransactionMeta::from_bytes(&val).expect("Invalid transaction metadata: db corrupted?") + ), false) + }, + Some(meta) => (Some(meta.clone()), true) + } + }; + + match meta { + Some(ref meta) => { if !is_cached { cache.insert(hash.clone(), meta.clone()); } } + None => {} + }; + + meta } } @@ -667,6 +730,7 @@ mod tests { use chain::Block; use super::super::{BlockRef, BlockLocation}; use test_data; + use primitives::Compact; #[test] fn open_store() { @@ -1195,6 +1259,7 @@ mod tests { store.decanonize_block(&mut update_context, &block_hash) .expect("Decanonizing block #1 which was just inserted should not fail"); update_context.apply(&store.database).unwrap(); + store.meta_cache.write().clear(); let genesis_meta = store.transaction_meta(&genesis_coinbase) .expect("Transaction meta for the genesis coinbase transaction should exist"); @@ -1226,6 +1291,27 @@ mod tests { assert_eq!(inserted_chain, BlockInsertedChain::Main, "h1 should become main chain"); } + #[test] + fn difficulty() { + let path = RandomTempPath::create_dir(); + let store = Storage::new(path.as_path()).unwrap(); + + let genesis = test_data::genesis(); + store.insert_block(&genesis) + .expect("Genesis should be inserted with no issues"); + + assert_eq!(1f64, store.difficulty(), "There should be minimum 1 difficulty for just the genesis block"); + + let block = test_data::block_builder() + .header().parent(genesis.hash()).bits(Compact::new(0x1b0404cb)).build() + .transaction().coinbase().build() + .build(); + store.insert_block(&block) + .expect("Nest block with just nbits should be inserted with no issues"); + + assert_eq!(16307.420938523994f64, store.difficulty(), "There should be minimum updated difficulty for new best block"); + } + #[test] fn chain_for_side() { diff --git a/db/src/test_storage.rs b/db/src/test_storage.rs index 8fdd9d9e..d95af684 100644 --- a/db/src/test_storage.rs +++ b/db/src/test_storage.rs @@ -126,7 +126,7 @@ impl BlockProvider for TestStorage { impl BlockStapler for TestStorage { /// insert pre-processed block in the storage fn insert_indexed_block(&self, block: &IndexedBlock) -> Result { - self.insert_block(&block.to_block()) + self.insert_block(&block.clone().to_raw_block()) } fn insert_block(&self, block: &chain::Block) -> Result { diff --git a/miner/src/block_assembler.rs b/miner/src/block_assembler.rs index 9d29b83a..de9a76c7 100644 --- a/miner/src/block_assembler.rs +++ b/miner/src/block_assembler.rs @@ -183,20 +183,17 @@ impl BlockAssembler { let size_step = block_size.decide(transaction_size); let sigops_step = sigops.decide(sigops_count); - let transaction = IndexedTransaction { - transaction: entry.transaction.clone(), - hash: entry.hash.clone(), - }; - match size_step.and(sigops_step) { NextStep::Append => { + let tx = IndexedTransaction::new(entry.hash.clone(), entry.transaction.clone()); // miner_fee is i64, but we can safely cast it to u64 // memory pool should restrict miner fee to be positive *coinbase_value += entry.miner_fee as u64; - transactions.push(transaction); + transactions.push(tx); }, NextStep::FinishAndAppend => { - transactions.push(transaction); + let tx = IndexedTransaction::new(entry.hash.clone(), entry.transaction.clone()); + transactions.push(tx); break; }, NextStep::Ignore => (), diff --git a/primitives/src/compact.rs b/primitives/src/compact.rs index 5769b334..3cff70e3 100644 --- a/primitives/src/compact.rs +++ b/primitives/src/compact.rs @@ -76,6 +76,14 @@ impl Compact { assert!(size < 256); Compact(compact | (size << 24) as u32) } + + pub fn to_f64(&self) -> f64 { + let max_body = f64::from(0x00ffff).ln(); + let scaland = f64::from(256).ln(); + let ln1 = f64::from(self.0 & 0x00ffffff).ln(); + let s1 = scaland * f64::from(0x1d - ((self.0 & 0xff000000) >> 24)); + (max_body - ln1 + s1).exp() + } } #[cfg(test)] @@ -113,6 +121,11 @@ mod tests { let compact = Compact::new(0x05009234); let compact2 = Compact::from_u256(compact.to_u256().unwrap()); assert_eq!(compact, compact2); + } + #[test] + fn difficulty() { + let nbits = Compact::new(0x1b0404cb); + assert_eq!(nbits.to_f64(), 16307.420938523994f64); } } diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 14e0ed9f..358c4c19 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -13,3 +13,4 @@ pub use rustc_serialize::hex; pub use uint::U256; pub use hash::{H160, H256}; pub use bytes::Bytes; +pub use compact::Compact; diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 3176c3ba..4f499e29 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -14,7 +14,9 @@ rustc-serialize = "0.3" tokio-core = "0.1.1" serde_macros = { version = "0.8.0", optional = true } jsonrpc-core = { git = "https://github.com/ethcore/jsonrpc.git" } +jsonrpc-macros = { git = "https://github.com/ethcore/jsonrpc.git" } jsonrpc-http-server = { git = "https://github.com/ethcore/jsonrpc.git" } + sync = { path = "../sync" } serialization = { path = "../serialization" } chain = { path = "../chain" } diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index b312a7ee..0088da5c 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -6,6 +6,8 @@ extern crate rustc_serialize; extern crate serde; extern crate serde_json; extern crate jsonrpc_core; +#[macro_use] +extern crate jsonrpc_macros; extern crate jsonrpc_http_server; extern crate tokio_core; extern crate sync; diff --git a/rpc/src/v1/helpers/auto_args.rs b/rpc/src/v1/helpers/auto_args.rs deleted file mode 100644 index f60f7425..00000000 --- a/rpc/src/v1/helpers/auto_args.rs +++ /dev/null @@ -1,294 +0,0 @@ -// because we reuse the type names as idents in the macros as a dirty hack to -// work around `concat_idents!` being unstable. -#![allow(non_snake_case)] - -///! Automatically serialize and deserialize parameters around a strongly-typed function. - -use super::errors; - -use jsonrpc_core::{Error, Params, Value, from_params, to_value}; -use serde::{Serialize, Deserialize}; - -/// Auto-generates an RPC trait from trait definition. -/// -/// This just copies out all the methods, docs, and adds another -/// function `to_delegate` which will automatically wrap each strongly-typed -/// function in a wrapper which handles parameter and output type serialization. -/// -/// RPC functions may come in a couple forms: async and synchronous. -/// These are parsed with the custom `#[rpc]` attribute, which must follow -/// documentation. -/// -/// ## The #[rpc] attribute -/// -/// Valid forms: -/// - `#[rpc(name = "name_here")]` (a synchronous rpc function which should be bound to the given name) -/// - `#[rpc(async, name = "name_here")]` (an async rpc function which should be bound to the given name) -/// -/// Synchronous function format: -/// `fn foo(&self, Param1, Param2, Param3) -> Out`. -/// -/// Asynchronous RPC functions must come in this form: -/// `fn foo(&self, Param1, Param2, Param3, Ready); -/// -/// Anything else will be rejected by the code generator. -macro_rules! build_rpc_trait { - // entry-point. todo: make another for traits w/ bounds. - ( - $(#[$t_attr: meta])* - pub trait $name: ident { - $( - $( #[doc=$m_doc:expr] )* - #[ rpc( $($t:tt)* ) ] - fn $m_name: ident ( $($p: tt)* ) $( -> Result<$out: ty, Error> )* ; - )* - } - ) => { - $(#[$t_attr])* - pub trait $name: Sized + Send + Sync + 'static { - $( - $(#[doc=$m_doc])* - fn $m_name ( $($p)* ) $( -> Result<$out, Error> )* ; - )* - - /// Transform this into an `IoDelegate`, automatically wrapping - /// the parameters. - fn to_delegate(self) -> ::jsonrpc_core::IoDelegate { - let mut del = ::jsonrpc_core::IoDelegate::new(self.into()); - $( - build_rpc_trait!(WRAP del => - ( $($t)* ) - fn $m_name ( $($p)* ) $( -> Result<$out, Error> )* - ); - )* - del - } - } - }; - - ( WRAP $del: expr => - (name = $name: expr) - fn $method: ident (&self $(, $param: ty)*) -> Result<$out: ty, Error> - ) => { - $del.add_method($name, move |base, params| { - (Self::$method as fn(&_ $(, $param)*) -> Result<$out, Error>).wrap_rpc(base, params) - }) - }; - - ( WRAP $del: expr => - (async, name = $name: expr) - fn $method: ident (&self, Ready<$out: ty> $(, $param: ty)*) - ) => { - $del.add_async_method($name, move |base, params, ready| { - (Self::$method as fn(&_, Ready<$out> $(, $param)*)).wrap_rpc(base, params, ready) - }) - }; -} - -/// A wrapper type without an implementation of `Deserialize` -/// which allows a special implementation of `Wrap` for functions -/// that take a trailing default parameter. -pub struct Trailing(pub T); - -/// A wrapper type for `jsonrpc_core`'s weakly-typed `Ready` struct. -pub struct Ready { - inner: ::jsonrpc_core::Ready, - _marker: ::std::marker::PhantomData, -} - -impl From<::jsonrpc_core::Ready> for Ready { - fn from(ready: ::jsonrpc_core::Ready) -> Self { - Ready { inner: ready, _marker: ::std::marker::PhantomData } - } -} - -impl Ready { - /// Respond withthe asynchronous result. - pub fn ready(self, result: Result) { - self.inner.ready(result.map(to_value)) - } -} - -/// Wrapper trait for synchronous RPC functions. -pub trait Wrap { - fn wrap_rpc(&self, base: &B, params: Params) -> Result; -} - -/// Wrapper trait for asynchronous RPC functions. -pub trait WrapAsync { - fn wrap_rpc(&self, base: &B, params: Params, ready: ::jsonrpc_core::Ready); -} - -// special impl for no parameters. -impl Wrap for fn(&B) -> Result - where B: Send + Sync + 'static, OUT: Serialize -{ - fn wrap_rpc(&self, base: &B, params: Params) -> Result { - ::v1::helpers::params::expect_no_params(params) - .and_then(|()| (self)(base)) - .map(to_value) - } -} - -impl WrapAsync for fn(&B, Ready) - where B: Send + Sync + 'static, OUT: Serialize -{ - fn wrap_rpc(&self, base: &B, params: Params, ready: ::jsonrpc_core::Ready) { - match ::v1::helpers::params::expect_no_params(params) { - Ok(()) => (self)(base, ready.into()), - Err(e) => ready.ready(Err(e)), - } - } -} - -// creates a wrapper implementation which deserializes the parameters, -// calls the function with concrete type, and serializes the output. -macro_rules! wrap { - ($($x: ident),+) => { - - // synchronous implementation - impl < - BASE: Send + Sync + 'static, - OUT: Serialize, - $($x: Deserialize,)+ - > Wrap for fn(&BASE, $($x,)+) -> Result { - fn wrap_rpc(&self, base: &BASE, params: Params) -> Result { - from_params::<($($x,)+)>(params).and_then(|($($x,)+)| { - (self)(base, $($x,)+) - }).map(to_value) - } - } - - // asynchronous implementation - impl < - BASE: Send + Sync + 'static, - OUT: Serialize, - $($x: Deserialize,)+ - > WrapAsync for fn(&BASE, Ready, $($x,)+ ) { - fn wrap_rpc(&self, base: &BASE, params: Params, ready: ::jsonrpc_core::Ready) { - match from_params::<($($x,)+)>(params) { - Ok(($($x,)+)) => (self)(base, ready.into(), $($x,)+), - Err(e) => ready.ready(Err(e)), - } - } - } - } -} - -// special impl for no parameters other than block parameter. -impl Wrap for fn(&B, Trailing) -> Result - where B: Send + Sync + 'static, OUT: Serialize, T: Default + Deserialize -{ - fn wrap_rpc(&self, base: &B, params: Params) -> Result { - let len = match params { - Params::Array(ref v) => v.len(), - Params::None => 0, - _ => return Err(errors::invalid_params("not an array", "")), - }; - - let (id,) = match len { - 0 => (T::default(),), - 1 => try!(from_params::<(T,)>(params)), - _ => return Err(Error::invalid_params()), - }; - - (self)(base, Trailing(id)).map(to_value) - } -} - -impl WrapAsync for fn(&B, Ready, Trailing) - where B: Send + Sync + 'static, OUT: Serialize, T: Default + Deserialize -{ - fn wrap_rpc(&self, base: &B, params: Params, ready: ::jsonrpc_core::Ready) { - let len = match params { - Params::Array(ref v) => v.len(), - Params::None => 0, - _ => return ready.ready(Err(errors::invalid_params("not an array", ""))), - }; - - let id = match len { - 0 => Ok((T::default(),)), - 1 => from_params::<(T,)>(params), - _ => Err(Error::invalid_params()), - }; - - match id { - Ok((id,)) => (self)(base, ready.into(), Trailing(id)), - Err(e) => ready.ready(Err(e)), - } - } -} - -// similar to `wrap!`, but handles a single default trailing parameter -// accepts an additional argument indicating the number of non-trailing parameters. -macro_rules! wrap_with_trailing { - ($num: expr, $($x: ident),+) => { - // synchronous implementation - impl < - BASE: Send + Sync + 'static, - OUT: Serialize, - $($x: Deserialize,)+ - TRAILING: Default + Deserialize, - > Wrap for fn(&BASE, $($x,)+ Trailing) -> Result { - fn wrap_rpc(&self, base: &BASE, params: Params) -> Result { - let len = match params { - Params::Array(ref v) => v.len(), - Params::None => 0, - _ => return Err(errors::invalid_params("not an array", "")), - }; - - let params = match len - $num { - 0 => from_params::<($($x,)+)>(params) - .map(|($($x,)+)| ($($x,)+ TRAILING::default())), - 1 => from_params::<($($x,)+ TRAILING)>(params) - .map(|($($x,)+ id)| ($($x,)+ id)), - _ => Err(Error::invalid_params()), - }; - - let ($($x,)+ id) = try!(params); - (self)(base, $($x,)+ Trailing(id)).map(to_value) - } - } - - // asynchronous implementation - impl < - BASE: Send + Sync + 'static, - OUT: Serialize, - $($x: Deserialize,)+ - TRAILING: Default + Deserialize, - > WrapAsync for fn(&BASE, Ready, $($x,)+ Trailing) { - fn wrap_rpc(&self, base: &BASE, params: Params, ready: ::jsonrpc_core::Ready) { - let len = match params { - Params::Array(ref v) => v.len(), - Params::None => 0, - _ => return ready.ready(Err(errors::invalid_params("not an array", ""))), - }; - - let params = match len - $num { - 0 => from_params::<($($x,)+)>(params) - .map(|($($x,)+)| ($($x,)+ TRAILING::default())), - 1 => from_params::<($($x,)+ TRAILING)>(params) - .map(|($($x,)+ id)| ($($x,)+ id)), - _ => Err(Error::invalid_params()), - }; - - match params { - Ok(($($x,)+ id)) => (self)(base, ready.into(), $($x,)+ Trailing(id)), - Err(e) => ready.ready(Err(e)) - } - } - } - } -} - -wrap!(A, B, C, D, E); -wrap!(A, B, C, D); -wrap!(A, B, C); -wrap!(A, B); -wrap!(A); - -wrap_with_trailing!(5, A, B, C, D, E); -wrap_with_trailing!(4, A, B, C, D); -wrap_with_trailing!(3, A, B, C); -wrap_with_trailing!(2, A, B); -wrap_with_trailing!(1, A); diff --git a/rpc/src/v1/helpers/errors.rs b/rpc/src/v1/helpers/errors.rs index 3c510a49..c575d6c3 100644 --- a/rpc/src/v1/helpers/errors.rs +++ b/rpc/src/v1/helpers/errors.rs @@ -6,22 +6,9 @@ mod codes { pub const BLOCK_NOT_FOUND: i64 = -32099; } - -macro_rules! rpc_unimplemented { - () => (Err(::v1::helpers::errors::unimplemented(None))) -} - use std::fmt; use jsonrpc_core::{Error, ErrorCode, Value}; -pub fn unimplemented(details: Option) -> Error { - Error { - code: ErrorCode::InternalError, - message: "This request is not implemented yet. Please create an issue on Github repo.".into(), - data: details.map(Value::String), - } -} - pub fn invalid_params(param: &str, details: T) -> Error { Error { code: ErrorCode::InvalidParams, diff --git a/rpc/src/v1/helpers/mod.rs b/rpc/src/v1/helpers/mod.rs index d2f54233..629e98fb 100644 --- a/rpc/src/v1/helpers/mod.rs +++ b/rpc/src/v1/helpers/mod.rs @@ -1,5 +1 @@ -#[macro_use] -pub mod auto_args; -#[macro_use] pub mod errors; -mod params; diff --git a/rpc/src/v1/helpers/params.rs b/rpc/src/v1/helpers/params.rs deleted file mode 100644 index c0ea9c10..00000000 --- a/rpc/src/v1/helpers/params.rs +++ /dev/null @@ -1,11 +0,0 @@ -///! Parameters parsing helpers - -use jsonrpc_core::{Error, Params}; -use v1::helpers::errors; - -pub fn expect_no_params(params: Params) -> Result<(), Error> { - match params { - Params::None => Ok(()), - p => Err(errors::invalid_params("No parameters were expected", p)), - } -} diff --git a/rpc/src/v1/traits/miner.rs b/rpc/src/v1/traits/miner.rs index 32d371e9..c3c47194 100644 --- a/rpc/src/v1/traits/miner.rs +++ b/rpc/src/v1/traits/miner.rs @@ -1,6 +1,5 @@ use jsonrpc_core::Error; -use v1::helpers::auto_args::Wrap; use v1::types::{BlockTemplate, BlockTemplateRequest}; build_rpc_trait! { diff --git a/rpc/src/v1/traits/raw.rs b/rpc/src/v1/traits/raw.rs index 3295353b..3406083c 100644 --- a/rpc/src/v1/traits/raw.rs +++ b/rpc/src/v1/traits/raw.rs @@ -1,6 +1,5 @@ use jsonrpc_core::Error; -use v1::helpers::auto_args::Wrap; use v1::types::RawTransaction; use v1::types::H256; diff --git a/rpc/src/v1/types/block_template.rs b/rpc/src/v1/types/block_template.rs index cc7b598e..dac43b48 100644 --- a/rpc/src/v1/types/block_template.rs +++ b/rpc/src/v1/types/block_template.rs @@ -99,7 +99,7 @@ impl From for BlockTemplate { impl From for BlockTemplateTransaction { fn from(transaction: db::IndexedTransaction) -> Self { use ser::serialize; - let serialize = serialize(&transaction.transaction); + let serialize = serialize(&transaction.raw); BlockTemplateTransaction { data: RawTransaction::new(Vec::from((*serialize).clone())), ..Default::default() diff --git a/sync/src/blocks_writer.rs b/sync/src/blocks_writer.rs index a3c7985e..489fcdba 100644 --- a/sync/src/blocks_writer.rs +++ b/sync/src/blocks_writer.rs @@ -48,7 +48,7 @@ impl BlocksWriter { return Ok(()); } // verify && insert only if parent block is already in the storage - if !self.storage.contains_block(db::BlockRef::Hash(indexed_block.header().previous_header_hash.clone())) { + if !self.storage.contains_block(db::BlockRef::Hash(indexed_block.header.raw.previous_header_hash.clone())) { self.orphaned_blocks_pool.insert_orphaned_block(indexed_block.hash().clone(), indexed_block); // we can't hold many orphaned blocks in memory during import if self.orphaned_blocks_pool.len() > MAX_ORPHANED_BLOCKS { diff --git a/sync/src/compact_block_builder.rs b/sync/src/compact_block_builder.rs index 78d54b61..3084f337 100644 --- a/sync/src/compact_block_builder.rs +++ b/sync/src/compact_block_builder.rs @@ -15,27 +15,27 @@ pub fn build_compact_block(block: IndexedBlock, prefilled_transactions_indexes: let nonce: u64 = thread_rng().gen(); let prefilled_transactions_len = prefilled_transactions_indexes.len(); - let mut short_ids: Vec = Vec::with_capacity(block.transaction_count() - prefilled_transactions_len); + let mut short_ids: Vec = Vec::with_capacity(block.transactions.len() - prefilled_transactions_len); let mut prefilled_transactions: Vec = Vec::with_capacity(prefilled_transactions_len); let mut prefilled_transactions_size: usize = 0; - let (key0, key1) = short_transaction_id_keys(nonce, block.header()); - for (transaction_index, (transaction_hash, transaction)) in block.transactions().enumerate() { - let transaction_size = transaction.serialized_size(); + let (key0, key1) = short_transaction_id_keys(nonce, &block.header.raw); + for (transaction_index, transaction) in block.transactions.into_iter().enumerate() { + let transaction_size = transaction.raw.serialized_size(); if prefilled_transactions_size + transaction_size < MAX_COMPACT_BLOCK_PREFILLED_SIZE && prefilled_transactions_indexes.contains(&transaction_index) { prefilled_transactions_size += transaction_size; prefilled_transactions.push(PrefilledTransaction { index: transaction_index, - transaction: transaction.clone(), + transaction: transaction.raw, }) } else { - short_ids.push(short_transaction_id(key0, key1, transaction_hash)); + short_ids.push(short_transaction_id(key0, key1, &transaction.hash)); } } BlockHeaderAndIDs { - header: block.header().clone(), + header: block.header.raw, nonce: nonce, short_ids: short_ids, prefilled_transactions: prefilled_transactions, diff --git a/sync/src/orphan_blocks_pool.rs b/sync/src/orphan_blocks_pool.rs index 702a539b..4e2e3dab 100644 --- a/sync/src/orphan_blocks_pool.rs +++ b/sync/src/orphan_blocks_pool.rs @@ -42,7 +42,7 @@ impl OrphanBlocksPool { /// Insert orphaned block, for which we have already requested its parent block pub fn insert_orphaned_block(&mut self, hash: H256, block: IndexedBlock) { self.orphaned_blocks - .entry(block.header().previous_header_hash.clone()) + .entry(block.header.raw.previous_header_hash.clone()) .or_insert_with(HashMap::new) .insert(hash, block); } diff --git a/sync/src/orphan_transactions_pool.rs b/sync/src/orphan_transactions_pool.rs index 03e7583e..162830ec 100644 --- a/sync/src/orphan_transactions_pool.rs +++ b/sync/src/orphan_transactions_pool.rs @@ -76,7 +76,7 @@ impl OrphanTransactionsPool { let child_entry = self.by_hash.get_mut(child).expect("every entry in by_parent.values() has corresponding entry in by_hash.keys()"); child_entry.remove_known_parent(&hash) }; - + if all_parents_are_known { removed_orphans_hashes.push(child.clone()); removed_orphans.push((child.clone(), self.by_hash.remove(child).expect("checked couple of lines above").transaction)); diff --git a/sync/src/synchronization_chain.rs b/sync/src/synchronization_chain.rs index 0e049481..b40e51ae 100644 --- a/sync/src/synchronization_chain.rs +++ b/sync/src/synchronization_chain.rs @@ -352,7 +352,7 @@ impl Chain { /// Insert new best block to storage pub fn insert_best_block(&mut self, hash: H256, block: &IndexedBlock) -> Result { - let is_appending_to_main_branch = self.best_storage_block.hash == block.header().previous_header_hash; + let is_appending_to_main_branch = self.best_storage_block.hash == block.header.raw.previous_header_hash; // insert to storage let storage_insertion = try!(self.storage.insert_indexed_block(&block)); @@ -371,10 +371,10 @@ impl Chain { // all transactions from this block were accepted // => delete accepted transactions from verification queue and from the memory pool // + also remove transactions which spent outputs which have been spent by transactions from the block - for (tx_hash, tx) in block.transactions() { - self.memory_pool.remove_by_hash(tx_hash); - self.verifying_transactions.remove(tx_hash); - for tx_input in &tx.inputs { + for tx in &block.transactions { + self.memory_pool.remove_by_hash(&tx.hash); + self.verifying_transactions.remove(&tx.hash); + for tx_input in &tx.raw.inputs { self.memory_pool.remove_by_prevout(&tx_input.previous_output); } } @@ -398,7 +398,7 @@ impl Chain { // all transactions from this block were accepted // + all transactions from previous blocks of this fork were accepted // => delete accepted transactions from verification queue and from the memory pool - let this_block_transactions_hashes: Vec = block.transaction_hashes().iter().cloned().collect(); + let this_block_transactions_hashes = block.transactions.iter().map(|tx| tx.hash.clone()).collect::>(); let mut canonized_blocks_hashes: Vec = Vec::new(); let mut new_main_blocks_transactions_hashes: Vec = Vec::new(); while let Some(canonized_block_hash) = reorganization.pop_canonized() { diff --git a/sync/src/synchronization_client.rs b/sync/src/synchronization_client.rs index 7e64eb3d..0392c02d 100644 --- a/sync/src/synchronization_client.rs +++ b/sync/src/synchronization_client.rs @@ -593,9 +593,9 @@ impl ClientCore for SynchronizationClientCore where T: TaskExecutor { None => notfound.push(item), Some(block) => { let indexed_block: IndexedBlock = block.into(); - let prefilled_transactions_indexes = indexed_block.transactions().enumerate() + let prefilled_transactions_indexes = indexed_block.transactions.iter().enumerate() // we do not filter by fee rate here, because it only reasonable for non-mined transactions - .filter(|&(_, (h, t))| filter.filter_transaction(h, t, None)) + .filter(|&(_, tx)| filter.filter_transaction(&tx.hash, &tx.raw, None)) .map(|(idx, _)| idx) .collect(); let compact_block = types::CompactBlock { @@ -1314,9 +1314,9 @@ impl SynchronizationClientCore where T: TaskExecutor { let block_header_and_ids: Vec<_> = indexed_blocks.into_iter() .filter_map(|b| if self.peers.filter(peer_index).filter_block(&b.hash()) { - let prefilled_transactions_indexes = b.transactions().enumerate() + let prefilled_transactions_indexes = b.transactions.iter().enumerate() // we do not filter by fee rate here, because it only reasonable for non-mined transactions - .filter(|&(_, (h, t))| self.peers.filter_mut(peer_index).filter_transaction(h, t, None)) + .filter(|&(_, tx)| self.peers.filter_mut(peer_index).filter_transaction(&tx.hash, &tx.raw, None)) .map(|(idx, _)| idx) .collect(); Some(build_compact_block(b, prefilled_transactions_indexes)) @@ -1484,7 +1484,7 @@ impl SynchronizationClientCore where T: TaskExecutor { } // check parent block state - let parent_block_state = chain.block_state(&block.header().previous_header_hash); + let parent_block_state = chain.block_state(&block.header.raw.previous_header_hash); match parent_block_state { BlockState::Unknown | BlockState::DeadEnd => { if parent_block_state == BlockState::DeadEnd { @@ -1528,7 +1528,7 @@ impl SynchronizationClientCore where T: TaskExecutor { let blocks_hashes_to_forget: Vec<_> = blocks_to_verify.iter().map(|t| t.0.clone()).collect(); chain.forget_blocks_leave_header(&blocks_hashes_to_forget); // remember that we are verifying these blocks - let blocks_headers_to_verify: Vec<_> = blocks_to_verify.iter().map(|&(ref h, ref b)| (h.clone(), b.header().clone())).collect(); + let blocks_headers_to_verify: Vec<_> = blocks_to_verify.iter().map(|&(ref h, ref b)| (h.clone(), b.header.raw.clone())).collect(); chain.verify_blocks(blocks_headers_to_verify); // remember that we are verifying block from this peer for verifying_block_hash in blocks_to_verify.iter().map(|&(ref h, _)| h.clone()) { diff --git a/tools/draw_graph.sh b/tools/draw_graph.sh index 653d98e8..2eed5ac6 100755 --- a/tools/draw_graph.sh +++ b/tools/draw_graph.sh @@ -10,7 +10,11 @@ cargo update -p pbtc # And draw dependencies graph using cargo graph cargo graph --build-shape box --build-line-style dashed > tools/graph.dot -dot -Tpng > tools/graph.png tools/graph.dot + +# Let's fix graph ratio +patch tools/graph.dot tools/graph_ratio.diff + +dot -Tsvg > tools/graph.svg tools/graph.dot # Finally let's bring back old Cargo.toml file patch Cargo.toml tools/workspace.diff diff --git a/tools/graph.dot b/tools/graph.dot index c9bf010a..8682d1e0 100644 --- a/tools/graph.dot +++ b/tools/graph.dot @@ -1,4 +1,6 @@ digraph dependencies { + ratio=1.0; + size="5,5"; N0[label="pbtc",shape=box]; N1[label="app_dirs",shape=box]; N2[label="bencher",shape=box]; @@ -14,88 +16,124 @@ digraph dependencies { N12[label="miner",shape=box]; N13[label="network",shape=box]; N14[label="p2p",shape=box]; - N15[label="script",shape=box]; - N16[label="sync",shape=box]; - N17[label="verification",shape=box]; - N18[label="abstract-ns",shape=box]; - N19[label="futures",shape=box]; - N20[label="quick-error",shape=box]; - N21[label="rand",shape=box]; - N22[label="aho-corasick",shape=box]; - N23[label="memchr",shape=box]; - N24[label="ansi_term",shape=box]; - N25[label="ole32-sys",shape=box]; - N26[label="shell32-sys",shape=box]; - N27[label="winapi",shape=box]; - N28[label="xdg",shape=box]; - N29[label="arrayvec",shape=box]; - N30[label="nodrop",shape=box]; - N31[label="odds",shape=box]; - N32[label="base58",shape=box]; - N33[label="ethcore-devtools",shape=box]; - N34[label="primitives",shape=box]; - N35[label="test-data",shape=box]; - N36[label="time",shape=box]; - N37[label="bit-vec",shape=box]; - N38[label="bitcrypto",shape=box]; - N39[label="rust-crypto",shape=box]; - N40[label="siphasher",shape=box]; - N41[label="bitflags v0.4.0",shape=box]; - N42[label="bitflags v0.7.0",shape=box]; - N43[label="byteorder",shape=box]; - N44[label="cfg-if",shape=box]; - N45[label="heapsize",shape=box]; - N46[label="rustc-serialize",shape=box]; - N47[label="serialization",shape=box]; - N48[label="libc",shape=box]; - N49[label="strsim",shape=box]; - N50[label="term_size",shape=box]; - N51[label="unicode-segmentation",shape=box]; - N52[label="unicode-width",shape=box]; - N53[label="vec_map",shape=box]; - N54[label="yaml-rust",shape=box]; - N55[label="crossbeam",shape=box]; - N56[label="csv",shape=box]; - N57[label="elastic-array",shape=box]; - N58[label="parking_lot",shape=box]; - N59[label="rocksdb",shape=box]; - N60[label="deque",shape=box]; - N61[label="domain",shape=box]; - N62[label="tokio-core",shape=box]; - N63[label="regex",shape=box]; - N64[label="eth-secp256k1",shape=box]; - N65[label="gcc",shape=box]; - N66[label="futures-cpupool",shape=box]; - N67[label="num_cpus",shape=box]; - N68[label="rayon",shape=box]; - N69[label="kernel32-sys",shape=box]; - N70[label="winapi-build",shape=box]; - N71[label="lazy_static",shape=box]; - N72[label="lazycell",shape=box]; - N73[label="linked-hash-map",shape=box]; - N74[label="mio",shape=box]; - N75[label="miow",shape=box]; - N76[label="net2",shape=box]; - N77[label="nix",shape=box]; - N78[label="slab",shape=box]; - N79[label="ws2_32-sys",shape=box]; - N80[label="murmur3",shape=box]; - N81[label="rustc_version",shape=box]; - N82[label="semver",shape=box]; - N83[label="void",shape=box]; - N84[label="ns-dns-tokio",shape=box]; - N85[label="owning_ref",shape=box]; - N86[label="parking_lot_core",shape=box]; - N87[label="smallvec",shape=box]; - N88[label="regex-syntax",shape=box]; - N89[label="thread_local",shape=box]; - N90[label="utf8-ranges",shape=box]; - N91[label="rocksdb-sys",shape=box]; - N92[label="scoped-pool",shape=box]; - N93[label="scopeguard",shape=box]; - N94[label="variance",shape=box]; - N95[label="scoped-tls",shape=box]; - N96[label="thread-id",shape=box]; + N15[label="rpc",shape=box]; + N16[label="script",shape=box]; + N17[label="sync",shape=box]; + N18[label="verification",shape=box]; + N19[label="abstract-ns",shape=box]; + N20[label="futures",shape=box]; + N21[label="quick-error",shape=box]; + N22[label="rand",shape=box]; + N23[label="aho-corasick",shape=box]; + N24[label="memchr",shape=box]; + N25[label="ansi_term",shape=box]; + N26[label="ole32-sys",shape=box]; + N27[label="shell32-sys",shape=box]; + N28[label="winapi",shape=box]; + N29[label="xdg",shape=box]; + N30[label="arrayvec",shape=box]; + N31[label="nodrop",shape=box]; + N32[label="odds",shape=box]; + N33[label="aster",shape=box]; + N34[label="syntex_syntax",shape=box]; + N35[label="base58",shape=box]; + N36[label="ethcore-devtools",shape=box]; + N37[label="primitives",shape=box]; + N38[label="test-data",shape=box]; + N39[label="time",shape=box]; + N40[label="bit-vec",shape=box]; + N41[label="bitcrypto",shape=box]; + N42[label="rust-crypto",shape=box]; + N43[label="siphasher",shape=box]; + N44[label="bitflags v0.4.0",shape=box]; + N45[label="bitflags v0.7.0",shape=box]; + N46[label="byteorder",shape=box]; + N47[label="cfg-if",shape=box]; + N48[label="heapsize",shape=box]; + N49[label="rustc-serialize",shape=box]; + N50[label="serialization",shape=box]; + N51[label="libc",shape=box]; + N52[label="strsim",shape=box]; + N53[label="term_size",shape=box]; + N54[label="unicode-segmentation",shape=box]; + N55[label="unicode-width",shape=box]; + N56[label="vec_map",shape=box]; + N57[label="yaml-rust",shape=box]; + N58[label="cookie",shape=box]; + N59[label="url",shape=box]; + N60[label="crossbeam",shape=box]; + N61[label="csv",shape=box]; + N62[label="elastic-array",shape=box]; + N63[label="lru-cache",shape=box]; + N64[label="parking_lot v0.3.6",shape=box]; + N65[label="rocksdb",shape=box]; + N66[label="deque",shape=box]; + N67[label="domain",shape=box]; + N68[label="tokio-core",shape=box]; + N69[label="dtoa",shape=box]; + N70[label="regex",shape=box]; + N71[label="eth-secp256k1",shape=box]; + N72[label="gcc",shape=box]; + N73[label="futures-cpupool",shape=box]; + N74[label="num_cpus",shape=box]; + N75[label="rayon",shape=box]; + N76[label="kernel32-sys",shape=box]; + N77[label="httparse",shape=box]; + N78[label="hyper",shape=box]; + N79[label="language-tags",shape=box]; + N80[label="mime",shape=box]; + N81[label="rotor",shape=box]; + N82[label="spmc",shape=box]; + N83[label="unicase",shape=box]; + N84[label="vecio",shape=box]; + N85[label="idna",shape=box]; + N86[label="matches",shape=box]; + N87[label="unicode-bidi",shape=box]; + N88[label="unicode-normalization",shape=box]; + N89[label="itoa",shape=box]; + N90[label="jsonrpc-core",shape=box]; + N91[label="parking_lot v0.2.8",shape=box]; + N92[label="serde",shape=box]; + N93[label="serde_codegen",shape=box]; + N94[label="serde_json",shape=box]; + N95[label="jsonrpc-http-server",shape=box]; + N96[label="winapi-build",shape=box]; + N97[label="lazy_static",shape=box]; + N98[label="lazycell",shape=box]; + N99[label="linked-hash-map v0.2.1",shape=box]; + N100[label="linked-hash-map v0.3.0",shape=box]; + N101[label="mio",shape=box]; + N102[label="miow",shape=box]; + N103[label="net2",shape=box]; + N104[label="nix",shape=box]; + N105[label="slab",shape=box]; + N106[label="ws2_32-sys",shape=box]; + N107[label="murmur3",shape=box]; + N108[label="rustc_version",shape=box]; + N109[label="semver",shape=box]; + N110[label="void",shape=box]; + N111[label="ns-dns-tokio",shape=box]; + N112[label="num-traits",shape=box]; + N113[label="owning_ref",shape=box]; + N114[label="smallvec",shape=box]; + N115[label="parking_lot_core",shape=box]; + N116[label="quasi",shape=box]; + N117[label="syntex_errors",shape=box]; + N118[label="quasi_codegen",shape=box]; + N119[label="syntex",shape=box]; + N120[label="regex-syntax",shape=box]; + N121[label="thread_local",shape=box]; + N122[label="utf8-ranges",shape=box]; + N123[label="rocksdb-sys",shape=box]; + N124[label="scoped-pool",shape=box]; + N125[label="scopeguard",shape=box]; + N126[label="variance",shape=box]; + N127[label="scoped-tls",shape=box]; + N128[label="serde_codegen_internals",shape=box]; + N129[label="syntex_pos",shape=box]; + N130[label="term",shape=box]; + N131[label="unicode-xid",shape=box]; + N132[label="thread-id",shape=box]; N0 -> N1[label="",style=dashed]; N0 -> N2[label="",style=dashed]; N0 -> N3[label="",style=dashed]; @@ -113,252 +151,355 @@ digraph dependencies { N0 -> N15[label="",style=dashed]; N0 -> N16[label="",style=dashed]; N0 -> N17[label="",style=dashed]; - N1 -> N25[label="",style=dashed]; + N0 -> N18[label="",style=dashed]; N1 -> N26[label="",style=dashed]; N1 -> N27[label="",style=dashed]; N1 -> N28[label="",style=dashed]; + N1 -> N29[label="",style=dashed]; N2 -> N3[label="",style=dashed]; N2 -> N5[label="",style=dashed]; - N2 -> N17[label="",style=dashed]; - N2 -> N33[label="",style=dashed]; - N2 -> N34[label="",style=dashed]; - N2 -> N35[label="",style=dashed]; + N2 -> N18[label="",style=dashed]; N2 -> N36[label="",style=dashed]; - N3 -> N34[label="",style=dashed]; - N3 -> N38[label="",style=dashed]; - N3 -> N45[label="",style=dashed]; - N3 -> N46[label="",style=dashed]; - N3 -> N47[label="",style=dashed]; - N4 -> N24[label="",style=dashed]; - N4 -> N42[label="",style=dashed]; - N4 -> N48[label="",style=dashed]; - N4 -> N49[label="",style=dashed]; - N4 -> N50[label="",style=dashed]; + N2 -> N37[label="",style=dashed]; + N2 -> N38[label="",style=dashed]; + N2 -> N39[label="",style=dashed]; + N3 -> N37[label="",style=dashed]; + N3 -> N41[label="",style=dashed]; + N3 -> N48[label="",style=dashed]; + N3 -> N49[label="",style=dashed]; + N3 -> N50[label="",style=dashed]; + N4 -> N25[label="",style=dashed]; + N4 -> N45[label="",style=dashed]; N4 -> N51[label="",style=dashed]; N4 -> N52[label="",style=dashed]; N4 -> N53[label="",style=dashed]; N4 -> N54[label="",style=dashed]; + N4 -> N55[label="",style=dashed]; + N4 -> N56[label="",style=dashed]; + N4 -> N57[label="",style=dashed]; N5 -> N3[label="",style=dashed]; N5 -> N9[label="",style=dashed]; - N5 -> N33[label="",style=dashed]; - N5 -> N34[label="",style=dashed]; - N5 -> N35[label="",style=dashed]; + N5 -> N36[label="",style=dashed]; N5 -> N37[label="",style=dashed]; - N5 -> N43[label="",style=dashed]; - N5 -> N47[label="",style=dashed]; - N5 -> N57[label="",style=dashed]; - N5 -> N58[label="",style=dashed]; - N5 -> N59[label="",style=dashed]; + N5 -> N38[label="",style=dashed]; + N5 -> N40[label="",style=dashed]; + N5 -> N46[label="",style=dashed]; + N5 -> N50[label="",style=dashed]; + N5 -> N62[label="",style=dashed]; + N5 -> N63[label="",style=dashed]; + N5 -> N64[label="",style=dashed]; + N5 -> N65[label="",style=dashed]; N6 -> N9[label="",style=dashed]; - N6 -> N63[label="",style=dashed]; + N6 -> N70[label="",style=dashed]; N7 -> N3[label="",style=dashed]; N7 -> N9[label="",style=dashed]; - N7 -> N34[label="",style=dashed]; - N7 -> N47[label="",style=dashed]; - N8 -> N21[label="",style=dashed]; - N8 -> N32[label="",style=dashed]; - N8 -> N34[label="",style=dashed]; - N8 -> N38[label="",style=dashed]; - N8 -> N46[label="",style=dashed]; - N8 -> N64[label="",style=dashed]; + N7 -> N37[label="",style=dashed]; + N7 -> N50[label="",style=dashed]; + N8 -> N22[label="",style=dashed]; + N8 -> N35[label="",style=dashed]; + N8 -> N37[label="",style=dashed]; + N8 -> N41[label="",style=dashed]; + N8 -> N49[label="",style=dashed]; N8 -> N71[label="",style=dashed]; + N8 -> N97[label="",style=dashed]; N10 -> N6[label="",style=dashed]; N10 -> N9[label="",style=dashed]; - N10 -> N24[label="",style=dashed]; - N10 -> N36[label="",style=dashed]; + N10 -> N25[label="",style=dashed]; + N10 -> N39[label="",style=dashed]; N11 -> N3[label="",style=dashed]; N11 -> N13[label="",style=dashed]; - N11 -> N34[label="",style=dashed]; - N11 -> N38[label="",style=dashed]; - N11 -> N43[label="",style=dashed]; - N11 -> N47[label="",style=dashed]; + N11 -> N37[label="",style=dashed]; + N11 -> N41[label="",style=dashed]; + N11 -> N46[label="",style=dashed]; + N11 -> N50[label="",style=dashed]; N12 -> N3[label="",style=dashed]; N12 -> N5[label="",style=dashed]; - N12 -> N34[label="",style=dashed]; - N12 -> N35[label="",style=dashed]; - N12 -> N45[label="",style=dashed]; - N12 -> N47[label="",style=dashed]; + N12 -> N13[label="",style=dashed]; + N12 -> N18[label="",style=dashed]; + N12 -> N37[label="",style=dashed]; + N12 -> N38[label="",style=dashed]; + N12 -> N41[label="",style=dashed]; + N12 -> N46[label="",style=dashed]; + N12 -> N48[label="",style=dashed]; + N12 -> N50[label="",style=dashed]; N13 -> N3[label="",style=dashed]; - N13 -> N34[label="",style=dashed]; - N13 -> N47[label="",style=dashed]; + N13 -> N37[label="",style=dashed]; + N13 -> N50[label="",style=dashed]; N14 -> N9[label="",style=dashed]; N14 -> N11[label="",style=dashed]; N14 -> N13[label="",style=dashed]; - N14 -> N18[label="",style=dashed]; N14 -> N19[label="",style=dashed]; - N14 -> N21[label="",style=dashed]; - N14 -> N34[label="",style=dashed]; - N14 -> N36[label="",style=dashed]; - N14 -> N38[label="",style=dashed]; - N14 -> N47[label="",style=dashed]; - N14 -> N56[label="",style=dashed]; - N14 -> N58[label="",style=dashed]; - N14 -> N62[label="",style=dashed]; - N14 -> N66[label="",style=dashed]; - N14 -> N84[label="",style=dashed]; + N14 -> N20[label="",style=dashed]; + N14 -> N22[label="",style=dashed]; + N14 -> N37[label="",style=dashed]; + N14 -> N39[label="",style=dashed]; + N14 -> N41[label="",style=dashed]; + N14 -> N50[label="",style=dashed]; + N14 -> N61[label="",style=dashed]; + N14 -> N64[label="",style=dashed]; + N14 -> N68[label="",style=dashed]; + N14 -> N73[label="",style=dashed]; + N14 -> N111[label="",style=dashed]; N15 -> N3[label="",style=dashed]; - N15 -> N8[label="",style=dashed]; + N15 -> N5[label="",style=dashed]; N15 -> N9[label="",style=dashed]; - N15 -> N34[label="",style=dashed]; + N15 -> N12[label="",style=dashed]; + N15 -> N13[label="",style=dashed]; + N15 -> N14[label="",style=dashed]; + N15 -> N17[label="",style=dashed]; + N15 -> N37[label="",style=dashed]; N15 -> N38[label="",style=dashed]; - N15 -> N47[label="",style=dashed]; + N15 -> N49[label="",style=dashed]; + N15 -> N50[label="",style=dashed]; + N15 -> N68[label="",style=dashed]; + N15 -> N90[label="",style=dashed]; + N15 -> N92[label="",style=dashed]; + N15 -> N93[label="",style=dashed]; + N15 -> N94[label="",style=dashed]; + N15 -> N95[label="",style=dashed]; N16 -> N3[label="",style=dashed]; - N16 -> N5[label="",style=dashed]; + N16 -> N8[label="",style=dashed]; N16 -> N9[label="",style=dashed]; - N16 -> N11[label="",style=dashed]; - N16 -> N12[label="",style=dashed]; - N16 -> N13[label="",style=dashed]; - N16 -> N14[label="",style=dashed]; - N16 -> N15[label="",style=dashed]; - N16 -> N17[label="",style=dashed]; - N16 -> N19[label="",style=dashed]; - N16 -> N21[label="",style=dashed]; - N16 -> N33[label="",style=dashed]; - N16 -> N34[label="",style=dashed]; - N16 -> N35[label="",style=dashed]; - N16 -> N36[label="",style=dashed]; N16 -> N37[label="",style=dashed]; - N16 -> N38[label="",style=dashed]; - N16 -> N43[label="",style=dashed]; - N16 -> N47[label="",style=dashed]; - N16 -> N58[label="",style=dashed]; - N16 -> N62[label="",style=dashed]; - N16 -> N66[label="",style=dashed]; - N16 -> N73[label="",style=dashed]; - N16 -> N80[label="",style=dashed]; + N16 -> N41[label="",style=dashed]; + N16 -> N50[label="",style=dashed]; N17 -> N3[label="",style=dashed]; N17 -> N5[label="",style=dashed]; N17 -> N9[label="",style=dashed]; + N17 -> N11[label="",style=dashed]; + N17 -> N12[label="",style=dashed]; N17 -> N13[label="",style=dashed]; - N17 -> N15[label="",style=dashed]; - N17 -> N33[label="",style=dashed]; - N17 -> N34[label="",style=dashed]; - N17 -> N35[label="",style=dashed]; + N17 -> N14[label="",style=dashed]; + N17 -> N16[label="",style=dashed]; + N17 -> N18[label="",style=dashed]; + N17 -> N20[label="",style=dashed]; + N17 -> N22[label="",style=dashed]; N17 -> N36[label="",style=dashed]; - N17 -> N43[label="",style=dashed]; - N17 -> N47[label="",style=dashed]; - N17 -> N58[label="",style=dashed]; + N17 -> N37[label="",style=dashed]; + N17 -> N38[label="",style=dashed]; + N17 -> N39[label="",style=dashed]; + N17 -> N40[label="",style=dashed]; + N17 -> N41[label="",style=dashed]; + N17 -> N46[label="",style=dashed]; + N17 -> N50[label="",style=dashed]; + N17 -> N64[label="",style=dashed]; + N17 -> N68[label="",style=dashed]; N17 -> N73[label="",style=dashed]; - N17 -> N92[label="",style=dashed]; - N18 -> N19[label="",style=dashed]; - N18 -> N20[label="",style=dashed]; - N18 -> N21[label="",style=dashed]; - N19 -> N9[label="",style=dashed]; - N21 -> N48[label="",style=dashed]; - N22 -> N23[label="",style=dashed]; - N23 -> N48[label="",style=dashed]; - N25 -> N27[label="",style=dashed]; - N25 -> N70[label="",style=dashed]; - N26 -> N27[label="",style=dashed]; - N26 -> N70[label="",style=dashed]; - N29 -> N30[label=""]; - N29 -> N31[label=""]; + N17 -> N100[label="",style=dashed]; + N17 -> N107[label="",style=dashed]; + N18 -> N3[label="",style=dashed]; + N18 -> N5[label="",style=dashed]; + N18 -> N9[label="",style=dashed]; + N18 -> N13[label="",style=dashed]; + N18 -> N16[label="",style=dashed]; + N18 -> N36[label="",style=dashed]; + N18 -> N37[label="",style=dashed]; + N18 -> N38[label="",style=dashed]; + N18 -> N39[label="",style=dashed]; + N18 -> N46[label="",style=dashed]; + N18 -> N50[label="",style=dashed]; + N18 -> N64[label="",style=dashed]; + N18 -> N124[label="",style=dashed]; + N19 -> N20[label="",style=dashed]; + N19 -> N21[label="",style=dashed]; + N19 -> N22[label="",style=dashed]; + N20 -> N9[label="",style=dashed]; + N22 -> N51[label="",style=dashed]; + N23 -> N24[label="",style=dashed]; + N24 -> N51[label="",style=dashed]; + N26 -> N28[label="",style=dashed]; + N26 -> N96[label="",style=dashed]; + N27 -> N28[label="",style=dashed]; + N27 -> N96[label="",style=dashed]; N30 -> N31[label=""]; - N33 -> N21[label="",style=dashed]; + N30 -> N32[label=""]; + N31 -> N32[label=""]; + N33 -> N34[label="",style=dashed]; + N34 -> N9[label="",style=dashed]; N34 -> N45[label="",style=dashed]; - N34 -> N46[label="",style=dashed]; - N34 -> N81[label="",style=dashed]; - N35 -> N3[label="",style=dashed]; - N35 -> N34[label="",style=dashed]; - N35 -> N36[label="",style=dashed]; - N35 -> N47[label="",style=dashed]; - N36 -> N27[label="",style=dashed]; - N36 -> N48[label="",style=dashed]; - N36 -> N69[label="",style=dashed]; - N38 -> N34[label="",style=dashed]; + N34 -> N49[label="",style=dashed]; + N34 -> N51[label="",style=dashed]; + N34 -> N117[label="",style=dashed]; + N34 -> N129[label="",style=dashed]; + N34 -> N130[label="",style=dashed]; + N34 -> N131[label="",style=dashed]; + N36 -> N22[label="",style=dashed]; + N37 -> N48[label="",style=dashed]; + N37 -> N49[label="",style=dashed]; + N37 -> N108[label="",style=dashed]; + N38 -> N3[label="",style=dashed]; + N38 -> N37[label="",style=dashed]; N38 -> N39[label="",style=dashed]; - N38 -> N40[label="",style=dashed]; - N39 -> N21[label="",style=dashed]; - N39 -> N36[label="",style=dashed]; - N39 -> N46[label="",style=dashed]; - N39 -> N48[label="",style=dashed]; - N39 -> N65[label="",style=dashed]; - N45 -> N69[label="",style=dashed]; - N47 -> N34[label="",style=dashed]; - N47 -> N43[label="",style=dashed]; - N50 -> N27[label="",style=dashed]; - N50 -> N48[label="",style=dashed]; - N50 -> N69[label="",style=dashed]; - N56 -> N43[label="",style=dashed]; - N56 -> N46[label="",style=dashed]; - N58 -> N85[label="",style=dashed]; - N58 -> N86[label="",style=dashed]; - N59 -> N48[label="",style=dashed]; - N59 -> N91[label="",style=dashed]; - N60 -> N21[label="",style=dashed]; - N61 -> N19[label="",style=dashed]; - N61 -> N21[label="",style=dashed]; - N61 -> N43[label="",style=dashed]; - N61 -> N62[label="",style=dashed]; - N62 -> N9[label="",style=dashed]; - N62 -> N19[label="",style=dashed]; - N62 -> N74[label="",style=dashed]; - N62 -> N78[label="",style=dashed]; - N62 -> N95[label="",style=dashed]; - N63 -> N22[label="",style=dashed]; - N63 -> N23[label="",style=dashed]; - N63 -> N88[label="",style=dashed]; - N63 -> N89[label="",style=dashed]; - N63 -> N90[label="",style=dashed]; - N64 -> N21[label="",style=dashed]; - N64 -> N29[label="",style=dashed]; - N64 -> N46[label="",style=dashed]; - N64 -> N48[label="",style=dashed]; - N64 -> N65[label="",style=dashed]; - N65 -> N68[label="",style=dashed]; - N66 -> N19[label="",style=dashed]; - N66 -> N55[label="",style=dashed]; - N66 -> N67[label="",style=dashed]; - N67 -> N48[label="",style=dashed]; - N68 -> N21[label="",style=dashed]; - N68 -> N48[label="",style=dashed]; - N68 -> N60[label="",style=dashed]; - N68 -> N67[label="",style=dashed]; - N69 -> N27[label="",style=dashed]; - N69 -> N70[label="",style=dashed]; - N74 -> N9[label="",style=dashed]; - N74 -> N27[label="",style=dashed]; - N74 -> N48[label="",style=dashed]; - N74 -> N69[label="",style=dashed]; - N74 -> N72[label="",style=dashed]; - N74 -> N75[label="",style=dashed]; - N74 -> N76[label="",style=dashed]; - N74 -> N77[label="",style=dashed]; - N74 -> N78[label="",style=dashed]; - N75 -> N27[label="",style=dashed]; - N75 -> N69[label="",style=dashed]; - N75 -> N76[label="",style=dashed]; - N75 -> N79[label="",style=dashed]; - N76 -> N27[label="",style=dashed]; - N76 -> N44[label="",style=dashed]; - N76 -> N48[label="",style=dashed]; - N76 -> N69[label="",style=dashed]; - N76 -> N79[label="",style=dashed]; - N77 -> N41[label="",style=dashed]; - N77 -> N44[label="",style=dashed]; - N77 -> N48[label="",style=dashed]; - N77 -> N81[label="",style=dashed]; - N77 -> N82[label="",style=dashed]; - N77 -> N83[label="",style=dashed]; - N79 -> N27[label="",style=dashed]; - N79 -> N70[label="",style=dashed]; - N80 -> N43[label="",style=dashed]; - N81 -> N82[label="",style=dashed]; - N84 -> N18[label="",style=dashed]; - N84 -> N19[label="",style=dashed]; - N84 -> N61[label="",style=dashed]; - N84 -> N62[label="",style=dashed]; - N86 -> N21[label="",style=dashed]; - N86 -> N27[label="",style=dashed]; - N86 -> N48[label="",style=dashed]; - N86 -> N69[label="",style=dashed]; - N86 -> N87[label="",style=dashed]; - N89 -> N96[label="",style=dashed]; - N91 -> N48[label="",style=dashed]; - N91 -> N65[label="",style=dashed]; - N92 -> N55[label="",style=dashed]; - N92 -> N93[label="",style=dashed]; - N92 -> N94[label="",style=dashed]; - N96 -> N48[label="",style=dashed]; - N96 -> N69[label="",style=dashed]; + N38 -> N50[label="",style=dashed]; + N39 -> N28[label="",style=dashed]; + N39 -> N51[label="",style=dashed]; + N39 -> N76[label="",style=dashed]; + N41 -> N37[label="",style=dashed]; + N41 -> N42[label="",style=dashed]; + N41 -> N43[label="",style=dashed]; + N42 -> N22[label="",style=dashed]; + N42 -> N39[label="",style=dashed]; + N42 -> N49[label="",style=dashed]; + N42 -> N51[label="",style=dashed]; + N42 -> N72[label="",style=dashed]; + N48 -> N76[label="",style=dashed]; + N50 -> N37[label="",style=dashed]; + N50 -> N46[label="",style=dashed]; + N53 -> N28[label="",style=dashed]; + N53 -> N51[label="",style=dashed]; + N53 -> N76[label="",style=dashed]; + N58 -> N39[label=""]; + N58 -> N59[label=""]; + N59 -> N85[label=""]; + N59 -> N86[label=""]; + N61 -> N46[label="",style=dashed]; + N61 -> N49[label="",style=dashed]; + N63 -> N99[label="",style=dashed]; + N64 -> N113[label="",style=dashed]; + N64 -> N115[label="",style=dashed]; + N65 -> N51[label="",style=dashed]; + N65 -> N123[label="",style=dashed]; + N66 -> N22[label="",style=dashed]; + N67 -> N20[label="",style=dashed]; + N67 -> N22[label="",style=dashed]; + N67 -> N46[label="",style=dashed]; + N67 -> N68[label="",style=dashed]; + N68 -> N9[label="",style=dashed]; + N68 -> N20[label="",style=dashed]; + N68 -> N101[label="",style=dashed]; + N68 -> N105[label="",style=dashed]; + N68 -> N127[label="",style=dashed]; + N70 -> N23[label="",style=dashed]; + N70 -> N24[label="",style=dashed]; + N70 -> N120[label="",style=dashed]; + N70 -> N121[label="",style=dashed]; + N70 -> N122[label="",style=dashed]; + N71 -> N22[label="",style=dashed]; + N71 -> N30[label="",style=dashed]; + N71 -> N49[label="",style=dashed]; + N71 -> N51[label="",style=dashed]; + N71 -> N72[label="",style=dashed]; + N72 -> N75[label="",style=dashed]; + N73 -> N20[label="",style=dashed]; + N73 -> N60[label="",style=dashed]; + N73 -> N74[label="",style=dashed]; + N74 -> N51[label="",style=dashed]; + N75 -> N22[label="",style=dashed]; + N75 -> N51[label="",style=dashed]; + N75 -> N66[label="",style=dashed]; + N75 -> N74[label="",style=dashed]; + N76 -> N28[label="",style=dashed]; + N76 -> N96[label="",style=dashed]; + N78 -> N9[label="",style=dashed]; + N78 -> N39[label="",style=dashed]; + N78 -> N49[label="",style=dashed]; + N78 -> N58[label=""]; + N78 -> N59[label=""]; + N78 -> N77[label=""]; + N78 -> N79[label=""]; + N78 -> N80[label=""]; + N78 -> N81[label=""]; + N78 -> N82[label=""]; + N78 -> N83[label="",style=dashed]; + N78 -> N84[label=""]; + N80 -> N9[label=""]; + N81 -> N9[label=""]; + N81 -> N21[label=""]; + N81 -> N101[label=""]; + N81 -> N105[label=""]; + N81 -> N110[label=""]; + N83 -> N108[label="",style=dashed]; + N84 -> N28[label=""]; + N84 -> N106[label=""]; + N85 -> N86[label=""]; + N85 -> N87[label=""]; + N85 -> N88[label=""]; + N87 -> N86[label=""]; + N90 -> N9[label="",style=dashed]; + N90 -> N91[label="",style=dashed]; + N90 -> N92[label="",style=dashed]; + N90 -> N93[label="",style=dashed]; + N90 -> N94[label="",style=dashed]; + N91 -> N28[label="",style=dashed]; + N91 -> N51[label="",style=dashed]; + N91 -> N76[label="",style=dashed]; + N91 -> N114[label="",style=dashed]; + N93 -> N33[label="",style=dashed]; + N93 -> N34[label="",style=dashed]; + N93 -> N116[label="",style=dashed]; + N93 -> N118[label="",style=dashed]; + N93 -> N119[label="",style=dashed]; + N93 -> N128[label="",style=dashed]; + N94 -> N69[label="",style=dashed]; + N94 -> N89[label="",style=dashed]; + N94 -> N92[label="",style=dashed]; + N94 -> N112[label="",style=dashed]; + N95 -> N9[label="",style=dashed]; + N95 -> N78[label="",style=dashed]; + N95 -> N83[label="",style=dashed]; + N95 -> N90[label="",style=dashed]; + N101 -> N9[label="",style=dashed]; + N101 -> N28[label="",style=dashed]; + N101 -> N51[label="",style=dashed]; + N101 -> N76[label="",style=dashed]; + N101 -> N98[label="",style=dashed]; + N101 -> N102[label="",style=dashed]; + N101 -> N103[label="",style=dashed]; + N101 -> N104[label="",style=dashed]; + N101 -> N105[label="",style=dashed]; + N102 -> N28[label="",style=dashed]; + N102 -> N76[label="",style=dashed]; + N102 -> N103[label="",style=dashed]; + N102 -> N106[label="",style=dashed]; + N103 -> N28[label="",style=dashed]; + N103 -> N47[label="",style=dashed]; + N103 -> N51[label="",style=dashed]; + N103 -> N76[label="",style=dashed]; + N103 -> N106[label="",style=dashed]; + N104 -> N44[label="",style=dashed]; + N104 -> N47[label="",style=dashed]; + N104 -> N51[label="",style=dashed]; + N104 -> N108[label="",style=dashed]; + N104 -> N109[label="",style=dashed]; + N104 -> N110[label="",style=dashed]; + N106 -> N28[label="",style=dashed]; + N106 -> N96[label="",style=dashed]; + N107 -> N46[label="",style=dashed]; + N108 -> N109[label="",style=dashed]; + N111 -> N19[label="",style=dashed]; + N111 -> N20[label="",style=dashed]; + N111 -> N67[label="",style=dashed]; + N111 -> N68[label="",style=dashed]; + N115 -> N22[label="",style=dashed]; + N115 -> N28[label="",style=dashed]; + N115 -> N51[label="",style=dashed]; + N115 -> N76[label="",style=dashed]; + N115 -> N114[label="",style=dashed]; + N116 -> N34[label="",style=dashed]; + N116 -> N117[label="",style=dashed]; + N117 -> N9[label="",style=dashed]; + N117 -> N49[label="",style=dashed]; + N117 -> N51[label="",style=dashed]; + N117 -> N129[label="",style=dashed]; + N117 -> N130[label="",style=dashed]; + N117 -> N131[label="",style=dashed]; + N118 -> N33[label="",style=dashed]; + N118 -> N34[label="",style=dashed]; + N118 -> N117[label="",style=dashed]; + N118 -> N119[label="",style=dashed]; + N119 -> N34[label="",style=dashed]; + N119 -> N117[label="",style=dashed]; + N121 -> N132[label="",style=dashed]; + N123 -> N51[label="",style=dashed]; + N123 -> N72[label="",style=dashed]; + N124 -> N60[label="",style=dashed]; + N124 -> N125[label="",style=dashed]; + N124 -> N126[label="",style=dashed]; + N128 -> N34[label="",style=dashed]; + N128 -> N117[label="",style=dashed]; + N129 -> N49[label="",style=dashed]; + N130 -> N28[label="",style=dashed]; + N130 -> N76[label="",style=dashed]; + N132 -> N51[label="",style=dashed]; + N132 -> N76[label="",style=dashed]; } diff --git a/tools/graph.png b/tools/graph.png deleted file mode 100644 index 22683f50..00000000 Binary files a/tools/graph.png and /dev/null differ diff --git a/tools/graph.svg b/tools/graph.svg new file mode 100644 index 00000000..ea2f3c78 --- /dev/null +++ b/tools/graph.svg @@ -0,0 +1,2518 @@ + + + + + + +dependencies + + +N0 + +pbtc + + +N1 + +app_dirs + + +N0->N1 + + + + +N2 + +bencher + + +N0->N2 + + + + +N3 + +chain + + +N0->N3 + + + + +N4 + +clap + + +N0->N4 + + + + +N5 + +db + + +N0->N5 + + + + +N6 + +env_logger + + +N0->N6 + + + + +N7 + +import + + +N0->N7 + + + + +N8 + +keys + + +N0->N8 + + + + +N9 + +log + + +N0->N9 + + + + +N10 + +logs + + +N0->N10 + + + + +N11 + +message + + +N0->N11 + + + + +N12 + +miner + + +N0->N12 + + + + +N13 + +network + + +N0->N13 + + + + +N14 + +p2p + + +N0->N14 + + + + +N15 + +rpc + + +N0->N15 + + + + +N16 + +script + + +N0->N16 + + + + +N17 + +sync + + +N0->N17 + + + + +N18 + +verification + + +N0->N18 + + + + +N26 + +ole32-sys + + +N1->N26 + + + + +N27 + +shell32-sys + + +N1->N27 + + + + +N28 + +winapi + + +N1->N28 + + + + +N29 + +xdg + + +N1->N29 + + + + +N2->N3 + + + + +N2->N5 + + + + +N2->N18 + + + + +N36 + +ethcore-devtools + + +N2->N36 + + + + +N37 + +primitives + + +N2->N37 + + + + +N38 + +test-data + + +N2->N38 + + + + +N39 + +time + + +N2->N39 + + + + +N3->N37 + + + + +N41 + +bitcrypto + + +N3->N41 + + + + +N48 + +heapsize + + +N3->N48 + + + + +N49 + +rustc-serialize + + +N3->N49 + + + + +N50 + +serialization + + +N3->N50 + + + + +N25 + +ansi_term + + +N4->N25 + + + + +N45 + +bitflags v0.7.0 + + +N4->N45 + + + + +N51 + +libc + + +N4->N51 + + + + +N52 + +strsim + + +N4->N52 + + + + +N53 + +term_size + + +N4->N53 + + + + +N54 + +unicode-segmentation + + +N4->N54 + + + + +N55 + +unicode-width + + +N4->N55 + + + + +N56 + +vec_map + + +N4->N56 + + + + +N57 + +yaml-rust + + +N4->N57 + + + + +N5->N3 + + + + +N5->N9 + + + + +N5->N36 + + + + +N5->N37 + + + + +N5->N38 + + + + +N40 + +bit-vec + + +N5->N40 + + + + +N46 + +byteorder + + +N5->N46 + + + + +N5->N50 + + + + +N62 + +elastic-array + + +N5->N62 + + + + +N63 + +lru-cache + + +N5->N63 + + + + +N64 + +parking_lot v0.3.6 + + +N5->N64 + + + + +N65 + +rocksdb + + +N5->N65 + + + + +N6->N9 + + + + +N70 + +regex + + +N6->N70 + + + + +N7->N3 + + + + +N7->N9 + + + + +N7->N37 + + + + +N7->N50 + + + + +N22 + +rand + + +N8->N22 + + + + +N35 + +base58 + + +N8->N35 + + + + +N8->N37 + + + + +N8->N41 + + + + +N8->N49 + + + + +N71 + +eth-secp256k1 + + +N8->N71 + + + + +N97 + +lazy_static + + +N8->N97 + + + + +N10->N6 + + + + +N10->N9 + + + + +N10->N25 + + + + +N10->N39 + + + + +N11->N3 + + + + +N11->N13 + + + + +N11->N37 + + + + +N11->N41 + + + + +N11->N46 + + + + +N11->N50 + + + + +N12->N3 + + + + +N12->N5 + + + + +N12->N13 + + + + +N12->N18 + + + + +N12->N37 + + + + +N12->N38 + + + + +N12->N41 + + + + +N12->N46 + + + + +N12->N48 + + + + +N12->N50 + + + + +N13->N3 + + + + +N13->N37 + + + + +N13->N50 + + + + +N14->N9 + + + + +N14->N11 + + + + +N14->N13 + + + + +N19 + +abstract-ns + + +N14->N19 + + + + +N20 + +futures + + +N14->N20 + + + + +N14->N22 + + + + +N14->N37 + + + + +N14->N39 + + + + +N14->N41 + + + + +N14->N50 + + + + +N61 + +csv + + +N14->N61 + + + + +N14->N64 + + + + +N68 + +tokio-core + + +N14->N68 + + + + +N73 + +futures-cpupool + + +N14->N73 + + + + +N111 + +ns-dns-tokio + + +N14->N111 + + + + +N15->N3 + + + + +N15->N5 + + + + +N15->N9 + + + + +N15->N12 + + + + +N15->N13 + + + + +N15->N14 + + + + +N15->N17 + + + + +N15->N37 + + + + +N15->N38 + + + + +N15->N49 + + + + +N15->N50 + + + + +N15->N68 + + + + +N90 + +jsonrpc-core + + +N15->N90 + + + + +N92 + +serde + + +N15->N92 + + + + +N93 + +serde_codegen + + +N15->N93 + + + + +N94 + +serde_json + + +N15->N94 + + + + +N95 + +jsonrpc-http-server + + +N15->N95 + + + + +N16->N3 + + + + +N16->N8 + + + + +N16->N9 + + + + +N16->N37 + + + + +N16->N41 + + + + +N16->N50 + + + + +N17->N3 + + + + +N17->N5 + + + + +N17->N9 + + + + +N17->N11 + + + + +N17->N12 + + + + +N17->N13 + + + + +N17->N14 + + + + +N17->N16 + + + + +N17->N18 + + + + +N17->N20 + + + + +N17->N22 + + + + +N17->N36 + + + + +N17->N37 + + + + +N17->N38 + + + + +N17->N39 + + + + +N17->N40 + + + + +N17->N41 + + + + +N17->N46 + + + + +N17->N50 + + + + +N17->N64 + + + + +N17->N68 + + + + +N17->N73 + + + + +N100 + +linked-hash-map v0.3.0 + + +N17->N100 + + + + +N107 + +murmur3 + + +N17->N107 + + + + +N18->N3 + + + + +N18->N5 + + + + +N18->N9 + + + + +N18->N13 + + + + +N18->N16 + + + + +N18->N36 + + + + +N18->N37 + + + + +N18->N38 + + + + +N18->N39 + + + + +N18->N46 + + + + +N18->N50 + + + + +N18->N64 + + + + +N124 + +scoped-pool + + +N18->N124 + + + + +N19->N20 + + + + +N21 + +quick-error + + +N19->N21 + + + + +N19->N22 + + + + +N20->N9 + + + + +N22->N51 + + + + +N23 + +aho-corasick + + +N24 + +memchr + + +N23->N24 + + + + +N24->N51 + + + + +N26->N28 + + + + +N96 + +winapi-build + + +N26->N96 + + + + +N27->N28 + + + + +N27->N96 + + + + +N30 + +arrayvec + + +N31 + +nodrop + + +N30->N31 + + + + +N32 + +odds + + +N30->N32 + + + + +N31->N32 + + + + +N33 + +aster + + +N34 + +syntex_syntax + + +N33->N34 + + + + +N34->N9 + + + + +N34->N45 + + + + +N34->N49 + + + + +N34->N51 + + + + +N117 + +syntex_errors + + +N34->N117 + + + + +N129 + +syntex_pos + + +N34->N129 + + + + +N130 + +term + + +N34->N130 + + + + +N131 + +unicode-xid + + +N34->N131 + + + + +N36->N22 + + + + +N37->N48 + + + + +N37->N49 + + + + +N108 + +rustc_version + + +N37->N108 + + + + +N38->N3 + + + + +N38->N37 + + + + +N38->N39 + + + + +N38->N50 + + + + +N39->N28 + + + + +N39->N51 + + + + +N76 + +kernel32-sys + + +N39->N76 + + + + +N41->N37 + + + + +N42 + +rust-crypto + + +N41->N42 + + + + +N43 + +siphasher + + +N41->N43 + + + + +N42->N22 + + + + +N42->N39 + + + + +N42->N49 + + + + +N42->N51 + + + + +N72 + +gcc + + +N42->N72 + + + + +N44 + +bitflags v0.4.0 + + +N47 + +cfg-if + + +N48->N76 + + + + +N50->N37 + + + + +N50->N46 + + + + +N53->N28 + + + + +N53->N51 + + + + +N53->N76 + + + + +N58 + +cookie + + +N58->N39 + + + + +N59 + +url + + +N58->N59 + + + + +N85 + +idna + + +N59->N85 + + + + +N86 + +matches + + +N59->N86 + + + + +N60 + +crossbeam + + +N61->N46 + + + + +N61->N49 + + + + +N99 + +linked-hash-map v0.2.1 + + +N63->N99 + + + + +N113 + +owning_ref + + +N64->N113 + + + + +N115 + +parking_lot_core + + +N64->N115 + + + + +N65->N51 + + + + +N123 + +rocksdb-sys + + +N65->N123 + + + + +N66 + +deque + + +N66->N22 + + + + +N67 + +domain + + +N67->N20 + + + + +N67->N22 + + + + +N67->N46 + + + + +N67->N68 + + + + +N68->N9 + + + + +N68->N20 + + + + +N101 + +mio + + +N68->N101 + + + + +N105 + +slab + + +N68->N105 + + + + +N127 + +scoped-tls + + +N68->N127 + + + + +N69 + +dtoa + + +N70->N23 + + + + +N70->N24 + + + + +N120 + +regex-syntax + + +N70->N120 + + + + +N121 + +thread_local + + +N70->N121 + + + + +N122 + +utf8-ranges + + +N70->N122 + + + + +N71->N22 + + + + +N71->N30 + + + + +N71->N49 + + + + +N71->N51 + + + + +N71->N72 + + + + +N75 + +rayon + + +N72->N75 + + + + +N73->N20 + + + + +N73->N60 + + + + +N74 + +num_cpus + + +N73->N74 + + + + +N74->N51 + + + + +N75->N22 + + + + +N75->N51 + + + + +N75->N66 + + + + +N75->N74 + + + + +N76->N28 + + + + +N76->N96 + + + + +N77 + +httparse + + +N78 + +hyper + + +N78->N9 + + + + +N78->N39 + + + + +N78->N49 + + + + +N78->N58 + + + + +N78->N59 + + + + +N78->N77 + + + + +N79 + +language-tags + + +N78->N79 + + + + +N80 + +mime + + +N78->N80 + + + + +N81 + +rotor + + +N78->N81 + + + + +N82 + +spmc + + +N78->N82 + + + + +N83 + +unicase + + +N78->N83 + + + + +N84 + +vecio + + +N78->N84 + + + + +N80->N9 + + + + +N81->N9 + + + + +N81->N21 + + + + +N81->N101 + + + + +N81->N105 + + + + +N110 + +void + + +N81->N110 + + + + +N83->N108 + + + + +N84->N28 + + + + +N106 + +ws2_32-sys + + +N84->N106 + + + + +N85->N86 + + + + +N87 + +unicode-bidi + + +N85->N87 + + + + +N88 + +unicode-normalization + + +N85->N88 + + + + +N87->N86 + + + + +N89 + +itoa + + +N90->N9 + + + + +N91 + +parking_lot v0.2.8 + + +N90->N91 + + + + +N90->N92 + + + + +N90->N93 + + + + +N90->N94 + + + + +N91->N28 + + + + +N91->N51 + + + + +N91->N76 + + + + +N114 + +smallvec + + +N91->N114 + + + + +N93->N33 + + + + +N93->N34 + + + + +N116 + +quasi + + +N93->N116 + + + + +N118 + +quasi_codegen + + +N93->N118 + + + + +N119 + +syntex + + +N93->N119 + + + + +N128 + +serde_codegen_internals + + +N93->N128 + + + + +N94->N69 + + + + +N94->N89 + + + + +N94->N92 + + + + +N112 + +num-traits + + +N94->N112 + + + + +N95->N9 + + + + +N95->N78 + + + + +N95->N83 + + + + +N95->N90 + + + + +N98 + +lazycell + + +N101->N9 + + + + +N101->N28 + + + + +N101->N51 + + + + +N101->N76 + + + + +N101->N98 + + + + +N102 + +miow + + +N101->N102 + + + + +N103 + +net2 + + +N101->N103 + + + + +N104 + +nix + + +N101->N104 + + + + +N101->N105 + + + + +N102->N28 + + + + +N102->N76 + + + + +N102->N103 + + + + +N102->N106 + + + + +N103->N28 + + + + +N103->N47 + + + + +N103->N51 + + + + +N103->N76 + + + + +N103->N106 + + + + +N104->N44 + + + + +N104->N47 + + + + +N104->N51 + + + + +N104->N108 + + + + +N109 + +semver + + +N104->N109 + + + + +N104->N110 + + + + +N106->N28 + + + + +N106->N96 + + + + +N107->N46 + + + + +N108->N109 + + + + +N111->N19 + + + + +N111->N20 + + + + +N111->N67 + + + + +N111->N68 + + + + +N115->N22 + + + + +N115->N28 + + + + +N115->N51 + + + + +N115->N76 + + + + +N115->N114 + + + + +N116->N34 + + + + +N116->N117 + + + + +N117->N9 + + + + +N117->N49 + + + + +N117->N51 + + + + +N117->N129 + + + + +N117->N130 + + + + +N117->N131 + + + + +N118->N33 + + + + +N118->N34 + + + + +N118->N117 + + + + +N118->N119 + + + + +N119->N34 + + + + +N119->N117 + + + + +N132 + +thread-id + + +N121->N132 + + + + +N123->N51 + + + + +N123->N72 + + + + +N124->N60 + + + + +N125 + +scopeguard + + +N124->N125 + + + + +N126 + +variance + + +N124->N126 + + + + +N128->N34 + + + + +N128->N117 + + + + +N129->N49 + + + + +N130->N28 + + + + +N130->N76 + + + + +N132->N51 + + + + +N132->N76 + + + + + diff --git a/tools/graph_ratio.diff b/tools/graph_ratio.diff new file mode 100644 index 00000000..b276fdaf --- /dev/null +++ b/tools/graph_ratio.diff @@ -0,0 +1,11 @@ +diff --git tools/graph.dot tools/graph.dot +index f842267..1a831d2 100644 +--- tools/graph.dot ++++ tools/graph.dot +@@ -1,4 +1,6 @@ + digraph dependencies { ++ ratio=1.0; ++ size="5,5"; + N0[label="pbtc",shape=box]; + N1[label="app_dirs",shape=box]; + N2[label="bencher",shape=box]; diff --git a/verification/src/chain_verifier.rs b/verification/src/chain_verifier.rs index bbc04314..90477a87 100644 --- a/verification/src/chain_verifier.rs +++ b/verification/src/chain_verifier.rs @@ -14,8 +14,8 @@ const COINBASE_MATURITY: u32 = 100; // 2 hours pub const MAX_BLOCK_SIZE: usize = 1_000_000; pub const MAX_BLOCK_SIGOPS: usize = 20_000; -const TRANSACTIONS_VERIFY_THREADS: usize = 4; -const TRANSACTIONS_VERIFY_PARALLEL_THRESHOLD: usize = 16; +const TRANSACTIONS_VERIFY_THREADS: usize = 8; +const TRANSACTIONS_VERIFY_PARALLEL_THRESHOLD: usize = 32; #[derive(PartialEq, Debug)] /// Block verification chain @@ -78,8 +78,8 @@ impl ChainVerifier { // strict pay-to-script-hash signature operations count toward block // signature operations limit is enforced with BIP16 let store = StoreWithUnretainedOutputs::new(&self.store, block); - let bip16_active = self.verify_p2sh(block.header().time); - block.transactions().map(|(_, tx)| transaction_sigops(tx, &store, bip16_active)).sum() + let bip16_active = self.verify_p2sh(block.header.raw.time); + block.transactions.iter().map(|tx| transaction_sigops(&tx.raw, &store, bip16_active)).sum() } fn ordered_verify(&self, block: &db::IndexedBlock, at_height: u32) -> Result<(), Error> { @@ -98,28 +98,24 @@ impl ChainVerifier { //if let Some(work) = self.work_required(block, at_height) { if at_height != 0 && !self.skip_pow { let work = utils::work_required( - block.header().previous_header_hash.clone(), - block.header().time, + block.header.raw.previous_header_hash.clone(), + block.header.raw.time, at_height, self.store.as_block_header_provider(), self.network ); - if !self.skip_pow && work != block.header().bits { + if !self.skip_pow && work != block.header.raw.bits { trace!(target: "verification", "pow verification error at height: {}", at_height); - trace!(target: "verification", "expected work: {:?}, got {:?}", work, block.header().bits); + trace!(target: "verification", "expected work: {:?}, got {:?}", work, block.header.raw.bits); return Err(Error::Difficulty); } } - let coinbase_spends = block.transactions() - .nth(0) - .expect("block emptyness should be checked at this point") - .1 - .total_spends(); + let coinbase_spends = block.transactions[0].raw.total_spends(); // bip30 - for (tx_index, (tx_hash, _)) in block.transactions().enumerate() { - if let Some(meta) = self.store.transaction_meta(tx_hash) { + for (tx_index, tx) in block.transactions.iter().enumerate() { + if let Some(meta) = self.store.transaction_meta(&tx.hash) { if !meta.is_fully_spent() && !self.consensus_params.is_bip30_exception(&block_hash, at_height) { return Err(Error::Transaction(tx_index, TransactionError::UnspentTransactionWithTheSameHash)); } @@ -128,9 +124,9 @@ impl ChainVerifier { let unretained_store = StoreWithUnretainedOutputs::new(&self.store, block); let mut total_unspent = 0u64; - for (tx_index, (_, tx)) in block.transactions().enumerate().skip(1) { + for (tx_index, tx) in block.transactions.iter().enumerate().skip(1) { let mut total_claimed: u64 = 0; - for input in &tx.inputs { + for input in &tx.raw.inputs { // Coinbase maturity check if let Some(previous_meta) = self.store.transaction_meta(&input.previous_output.hash) { // check if it exists only @@ -147,7 +143,7 @@ impl ChainVerifier { total_claimed += previous_output.value; } - let total_spends = tx.total_spends(); + let total_spends = tx.raw.total_spends(); if total_claimed < total_spends { return Err(Error::Transaction(tx_index, TransactionError::Overspend)); @@ -265,12 +261,12 @@ impl ChainVerifier { let hash = block.hash(); // There should be at least 1 transaction - if block.transaction_count() == 0 { + if block.transactions.is_empty() { return Err(Error::Empty); } // block header checks - try!(self.verify_block_header(self.store.as_block_header_provider(), &hash, block.header())); + try!(self.verify_block_header(self.store.as_block_header_provider(), &hash, &block.header.raw)); // todo: serialized_size function is at least suboptimal let size = block.size(); @@ -279,11 +275,11 @@ impl ChainVerifier { } // verify merkle root - if block.merkle_root() != block.header().merkle_root_hash { + if block.merkle_root() != block.header.raw.merkle_root_hash { return Err(Error::MerkleRoot); } - let first_tx = block.transactions().nth(0).expect("transaction count is checked above to be greater than 0").1; + let first_tx = &block.transactions[0].raw; // check first transaction is a coinbase transaction if !first_tx.is_coinbase() { return Err(Error::Coinbase) @@ -295,19 +291,19 @@ impl ChainVerifier { return Err(Error::CoinbaseSignatureLength(coinbase_script_len)); } - let location = match self.store.accepted_location(block.header()) { + let location = match self.store.accepted_location(&block.header.raw) { Some(location) => location, None => return Ok(Chain::Orphan), }; - if block.transaction_count() > TRANSACTIONS_VERIFY_PARALLEL_THRESHOLD { + if block.transactions.len() > TRANSACTIONS_VERIFY_PARALLEL_THRESHOLD { // todo: might use on-stack vector (smallvec/elastic array) let mut transaction_tasks: Vec = Vec::with_capacity(TRANSACTIONS_VERIFY_THREADS); let mut last = 0; for num_task in 0..TRANSACTIONS_VERIFY_THREADS { let from = last; - last = ::std::cmp::max(1, block.transaction_count() / TRANSACTIONS_VERIFY_THREADS); - if num_task == TRANSACTIONS_VERIFY_THREADS - 1 { last = block.transaction_count(); }; + last = from + ::std::cmp::max(1, block.transactions.len() / TRANSACTIONS_VERIFY_THREADS); + if num_task == TRANSACTIONS_VERIFY_THREADS - 1 { last = block.transactions.len(); }; transaction_tasks.push(Task::new(block, location.height(), from, last)); } @@ -325,8 +321,8 @@ impl ChainVerifier { } } else { - for (index, (_, tx)) in block.transactions().enumerate() { - if let Err(tx_err) = self.verify_transaction(block, location.height(), block.header().time, tx, index) { + for (index, tx) in block.transactions.iter().enumerate() { + if let Err(tx_err) = self.verify_transaction(block, location.height(), block.header.raw.time, &tx.raw, index) { return Err(Error::Transaction(index, tx_err)); } } @@ -372,7 +368,7 @@ impl Verify for ChainVerifier { trace!( target: "verification", "Block {} (transactions: {}) verification finished. Result {:?}", block.hash().to_reversed_str(), - block.transaction_count(), + block.transactions.len(), result, ); result diff --git a/verification/src/task.rs b/verification/src/task.rs index 0a7d8bb3..f13c070d 100644 --- a/verification/src/task.rs +++ b/verification/src/task.rs @@ -25,7 +25,7 @@ impl<'a> Task<'a> { pub fn progress(&mut self, verifier: &ChainVerifier) { for index in self.from..self.to { - if let Err(e) = verifier.verify_transaction(self.block, self.block_height, self.block.header().time, self.block.transaction_at(index).1, index) { + if let Err(e) = verifier.verify_transaction(self.block, self.block_height, self.block.header.raw.time, &self.block.transactions[index].raw, index) { self.result = Err((index, e)) } }