diff --git a/.gitignore b/.gitignore index 01259d892..44cdbf52d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .grin* node* !node_clients +!node_clients.rs target Cargo.lock *.iml diff --git a/.travis.yml b/.travis.yml index 8ea1d7e03..a28731a9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,8 @@ env: matrix: include: + - os: linux + env: TEST_SUITE=. - os: linux env: TEST_SUITE=servers - os: linux diff --git a/Cargo.lock b/Cargo.lock index c85e4cffc..91db98ade 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,7 +170,7 @@ dependencies = [ "git2 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -235,7 +235,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -304,8 +304,11 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "croaring" @@ -349,7 +352,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-epoch 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -359,7 +362,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -372,7 +375,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "crossbeam-utils" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -430,7 +433,7 @@ dependencies = [ "owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "signal-hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "xi-unicode 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -589,7 +592,7 @@ name = "flate2" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crc32fast 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crc32fast 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide_c_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -699,7 +702,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -719,15 +722,15 @@ dependencies = [ "grin_store 0.4.2", "grin_util 0.4.2", "http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.12.16 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.17 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-rustls 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustls 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -755,8 +758,8 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -770,9 +773,9 @@ dependencies = [ "grin_wallet 0.4.2", "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -794,8 +797,8 @@ dependencies = [ "num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -814,8 +817,8 @@ dependencies = [ "pbkdf2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "ripemd160 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -838,8 +841,8 @@ dependencies = [ "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -855,13 +858,13 @@ dependencies = [ "grin_util 0.4.2", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "grin_secp256k1zkp" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", @@ -869,7 +872,7 @@ dependencies = [ "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -883,7 +886,6 @@ dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "grin_api 0.4.2", "grin_chain 0.4.2", - "grin_config 0.4.2", "grin_core 0.4.2", "grin_keychain 0.4.2", "grin_p2p 0.4.2", @@ -892,15 +894,15 @@ dependencies = [ "grin_util 0.4.2", "grin_wallet 0.4.2", "http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.12.16 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.17 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-staticfile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -914,6 +916,7 @@ dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "grin_core 0.4.2", "grin_util 0.4.2", "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", @@ -921,8 +924,8 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -932,14 +935,14 @@ dependencies = [ "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "grin_secp256k1zkp 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "grin_secp256k1zkp 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log4rs 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "zip 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -961,13 +964,13 @@ dependencies = [ "grin_keychain 0.4.2", "grin_store 0.4.2", "grin_util 0.4.2", - "hyper 0.12.16 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.17 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "prettytable-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -979,7 +982,7 @@ dependencies = [ [[package]] name = "h2" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1033,13 +1036,13 @@ dependencies = [ [[package]] name = "hyper" -version = "0.12.16" +version = "0.12.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "h2 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "h2 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1065,7 +1068,7 @@ dependencies = [ "ct-logs 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.12.16 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.17 (registry+https://github.com/rust-lang/crates.io-index)", "rustls 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1083,7 +1086,7 @@ dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.12.16 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.17 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1095,7 +1098,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.12.16 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.17 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1144,8 +1147,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1165,7 +1168,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazycell" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1180,7 +1183,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "crc32fast 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crc32fast 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1267,7 +1270,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1289,9 +1292,9 @@ dependencies = [ "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log-mdc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", "thread-id 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1405,7 +1408,7 @@ dependencies = [ "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazycell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2000,14 +2003,14 @@ dependencies = [ "encoding_rs 0.8.13 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.12.16 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.17 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-tls 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "libflate 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2164,7 +2167,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2173,12 +2176,12 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ordered-float 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2193,7 +2196,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2203,7 +2206,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2214,7 +2217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2496,7 +2499,7 @@ name = "tokio-reactor" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2556,7 +2559,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2569,7 +2572,7 @@ name = "tokio-timer" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2608,10 +2611,10 @@ dependencies = [ [[package]] name = "toml" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2729,7 +2732,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2938,7 +2941,7 @@ dependencies = [ "checksum core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980" "checksum core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa" "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" -"checksum crc32fast 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e0e685559fa8bccfa46afd0f876047ee5d87c536d71d0c2b3a08cc9e880f73eb" +"checksum crc32fast 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e91d5240c6975ef33aeb5f148f35275c25eda8e8a5f95abe421978b05b8bf192" "checksum croaring 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a2c82431f150237fc25ef9ece26ccbcc8325118f44a538b48449a7639cb6e9cf" "checksum croaring-sys 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "d36e44ca368664098be5d03576da36edd3e2c728df553f13f89cb25fbc3792c5" "checksum crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24ce9782d4d5c53674646a6a4c1863a21a8fc0cb649b3c94dfc16e45071dea19" @@ -2946,7 +2949,7 @@ dependencies = [ "checksum crossbeam-deque 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4fe1b6f945f824c7a25afe44f62e25d714c0cc523f8e99d8db5cd1026e1269d3" "checksum crossbeam-epoch 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2449aaa4ec7ef96e5fb24db16024b935df718e9ae1cec0a1e68feeca2efca7b8" "checksum crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015" -"checksum crossbeam-utils 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c55913cc2799171a550e307918c0a360e8c16004820291bf3b638969b4a01816" +"checksum crossbeam-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e07fc155212827475223f0bcfae57e945e694fc90950ddf3f6695bbfd5555c72" "checksum crypto-mac 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7afa06d05a046c7a47c3a849907ec303504608c927f4e85f7bfff22b7180d971" "checksum csv 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7ef22b37c7a51c564a365892c012dc0271221fdcc64c69b19ba4d6fa8bd96d9c" "checksum ct-logs 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "95a4bf5107667e12bf6ce31a3a5066d67acc88942b6742117a41198734aaccaa" @@ -2982,14 +2985,14 @@ dependencies = [ "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" "checksum git2 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "591f8be1674b421644b6c030969520bc3fa12114d2eb467471982ed3e9584e71" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" -"checksum grin_secp256k1zkp 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "42fd2759f1fb49fcbbf74fc9a818a0a32be49622395e82d88a26bba42a9bdd71" -"checksum h2 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "7dd33bafe2e6370e6c8eb0cf1b8c5f93390b90acde7e9b03723f166b28b648ed" +"checksum grin_secp256k1zkp 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aea95f8b846440f6a9caf0fd4c22c91c124f2a896d69d781f7dc0fa88e33b0ff" +"checksum h2 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "1ac030ae20dee464c5d0f36544d8b914a6bc606da44a57e052d2b0f5dae129e0" "checksum hmac 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "733e1b3ac906631ca01ebb577e9bb0f5e37a454032b9036b5eaea4013ed6f99a" "checksum http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "02096a6d2c55e63f7fcb800690e4f889a25f6ec342e3adb4594e293b625215ab" "checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" "checksum humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" -"checksum hyper 0.12.16 (registry+https://github.com/rust-lang/crates.io-index)" = "0aeedb8ca5f0f96be00f84073c6d0d5f962ecad020ef543dff99a7c12717a60e" +"checksum hyper 0.12.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c49a75385d35ff5e9202755f09beb0b878a05c4c363fcc52b23eeb5dcb6782cc" "checksum hyper-rustls 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "68f2aa6b1681795bf4da8063f718cd23145aa0c9a5143d9787b345aa60d38ee4" "checksum hyper-staticfile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4080cb44b9c1e4c6dfd6f7ee85a9c3439777ec9c59df32f944836d3de58ac35e" "checksum hyper-tls 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "32cd73f14ad370d3b4d4b7dce08f69b81536c82e39fcc89731930fe5788cd661" @@ -3001,7 +3004,7 @@ dependencies = [ "checksum jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ddf83704f4e79979a424d1082dd2c1e52683058056c9280efa19ac5f6bc9033c" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" -"checksum lazycell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddba4c30a78328befecec92fc94970e53b3ae385827d28620f0f5bb2493081e0" +"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)" = "10923947f84a519a45c8fefb7dd1b3e8c08747993381adee176d7a82b4195311" "checksum libflate 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "bff3ac7d6f23730d3b533c35ed75eef638167634476a499feef16c428d74b57b" "checksum libgit2-sys 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4916b5addc78ec36cc309acfcdf0b9f9d97ab7b84083118b248709c5b7029356" @@ -3113,9 +3116,9 @@ dependencies = [ "checksum security-framework-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab01dfbe5756785b5b4d46e0289e5a18071dfa9a7c2b24213ea00b9ef9b665bf" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "15c141fc7027dd265a47c090bf864cf62b42c4d228bbcf4e51a0c9e2b0d3f7ef" +"checksum serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)" = "c91eb5b0190ae87b4e2e39cbba6e3bed3ac6186935fe265f0426156c4c49961b" "checksum serde-value 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7a663f873dedc4eac1a559d4c6bc0d0b2c34dc5ac4702e105014b8281489e44f" -"checksum serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "225de307c6302bec3898c51ca302fc94a7a1697ef0845fcee6448f33c032249c" +"checksum serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)" = "477b13b646f5b5b56fc95bedfc3b550d12141ce84f466f6c44b9a17589923885" "checksum serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "c37ccd6be3ed1fdf419ee848f7c758eb31b054d7cd3ae3600e3bae0adf569811" "checksum serde_urlencoded 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d48f9f99cd749a2de71d29da5f948de7f2764cc5a9d7f3c97e3514d4ee6eabf2" "checksum serde_yaml 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0887a8e097a69559b56aa2526bf7aff7c3048cf627dff781f0b56a6001534593" @@ -3157,7 +3160,7 @@ dependencies = [ "checksum tokio-timer 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "4f37f0111d76cc5da132fe9bc0590b9b9cfd079bc7e75ac3846278430a299ff8" "checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92" "checksum tokio-uds 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "99ce87382f6c1a24b513a72c048b2c8efe66cb5161c9061d00bee510f08dc168" -"checksum toml 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "19782e145d5abefb03758958f06ea35f7b1d8421b534140e0238fd3d0bfd66e3" +"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6" diff --git a/Cargo.toml b/Cargo.toml index 8a9fc7881..198a69593 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ keywords = [ "crypto", "grin", "mimblewimble" ] readme = "README.md" exclude = ["**/*.grin", "**/*.grin2"] build = "src/build/build.rs" +edition = "2018" [workspace] members = ["api", "chain", "config", "core", "keychain", "p2p", "servers", "store", "util", "pool", "wallet"] diff --git a/api/Cargo.toml b/api/Cargo.toml index 16a12ae99..61a691024 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -7,6 +7,7 @@ license = "Apache-2.0" repository = "https://github.com/mimblewimble/grin" keywords = [ "crypto", "grin", "mimblewimble" ] workspace = ".." +edition = "2018" [dependencies] failure = "0.1.1" diff --git a/api/src/auth.rs b/api/src/auth.rs index 84a48248e..5b2b2f8da 100644 --- a/api/src/auth.rs +++ b/api/src/auth.rs @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +use crate::router::{Handler, HandlerObj, ResponseFuture}; use futures::future::ok; use hyper::header::{HeaderValue, AUTHORIZATION, WWW_AUTHENTICATE}; use hyper::{Body, Request, Response, StatusCode}; use ring::constant_time::verify_slices_are_equal; -use router::{Handler, HandlerObj, ResponseFuture}; // Basic Authentication Middleware pub struct BasicAuthMiddleware { @@ -37,12 +37,14 @@ impl Handler for BasicAuthMiddleware { fn call( &self, req: Request, - mut handlers: Box>, + mut handlers: Box>, ) -> ResponseFuture { - if req.headers().contains_key(AUTHORIZATION) && verify_slices_are_equal( - req.headers()[AUTHORIZATION].as_bytes(), - &self.api_basic_auth.as_bytes(), - ).is_ok() + if req.headers().contains_key(AUTHORIZATION) + && verify_slices_are_equal( + req.headers()[AUTHORIZATION].as_bytes(), + &self.api_basic_auth.as_bytes(), + ) + .is_ok() { handlers.next().unwrap().call(req, handlers) } else { @@ -58,7 +60,8 @@ fn unauthorized_response(basic_realm: &str) -> ResponseFuture { .header( WWW_AUTHENTICATE, HeaderValue::from_str(basic_realm).unwrap(), - ).body(Body::empty()) + ) + .body(Body::empty()) .unwrap(); Box::new(ok(response)) } diff --git a/api/src/client.rs b/api/src/client.rs index b6bac3b33..bc176924c 100644 --- a/api/src/client.rs +++ b/api/src/client.rs @@ -14,22 +14,20 @@ //! High level JSON/HTTP client API +use crate::rest::{Error, ErrorKind}; +use crate::util::to_base64; use failure::{Fail, ResultExt}; +use futures::future::{err, ok, Either}; use http::uri::{InvalidUri, Uri}; use hyper::header::{ACCEPT, AUTHORIZATION, USER_AGENT}; use hyper::rt::{Future, Stream}; use hyper::{Body, Client, Request}; +use hyper_rustls; use serde::{Deserialize, Serialize}; use serde_json; - -use futures::future::{err, ok, Either}; -use hyper_rustls; use tokio::runtime::Runtime; -use rest::{Error, ErrorKind}; -use util::to_base64; - -pub type ClientResponseFuture = Box + Send>; +pub type ClientResponseFuture = Box + Send>; /// Helper function to easily issue a HTTP GET request against a given URL that /// returns a JSON object. Handles request building, JSON deserialization and @@ -143,7 +141,8 @@ fn build_request<'a>( .body(match body { None => Body::empty(), Some(json) => json.into(), - }).map_err(|e| { + }) + .map_err(|e| { ErrorKind::RequestError(format!("Bad request {} {}: {}", method, url, e)).into() }) } @@ -185,7 +184,7 @@ where })) } -fn send_request_async(req: Request) -> Box + Send> { +fn send_request_async(req: Request) -> Box + Send> { let https = hyper_rustls::HttpsConnector::new(1); let client = Client::builder().build::<_, Body>(https); Box::new( @@ -196,14 +195,16 @@ fn send_request_async(req: Request) -> Box diff --git a/api/src/handlers/chain_api.rs b/api/src/handlers/chain_api.rs index 17560cc47..150de6821 100644 --- a/api/src/handlers/chain_api.rs +++ b/api/src/handlers/chain_api.rs @@ -13,18 +13,18 @@ // limitations under the License. use super::utils::{get_output, w}; -use chain; -use core::core::hash::Hashed; +use crate::chain; +use crate::core::core::hash::Hashed; +use crate::rest::*; +use crate::router::{Handler, ResponseFuture}; +use crate::types::*; +use crate::util; +use crate::util::secp::pedersen::Commitment; +use crate::web::*; use hyper::{Body, Request, StatusCode}; -use rest::*; -use router::{Handler, ResponseFuture}; use std::collections::HashMap; use std::sync::Weak; -use types::*; use url::form_urlencoded; -use util; -use util::secp::pedersen::Commitment; -use web::*; /// Chain handler. Get the head details. /// GET /v1/chain diff --git a/api/src/handlers/peers_api.rs b/api/src/handlers/peers_api.rs index 5ca27fb8c..c700b54b1 100644 --- a/api/src/handlers/peers_api.rs +++ b/api/src/handlers/peers_api.rs @@ -13,12 +13,12 @@ // limitations under the License. use super::utils::w; +use crate::p2p; +use crate::p2p::types::{PeerInfoDisplay, ReasonForBan}; +use crate::router::{Handler, ResponseFuture}; +use crate::web::*; use hyper::{Body, Request, StatusCode}; -use p2p; -use p2p::types::{PeerInfoDisplay, ReasonForBan}; -use router::{Handler, ResponseFuture}; use std::sync::Weak; -use web::*; pub struct PeersAllHandler { pub peers: Weak, diff --git a/api/src/handlers/pool_api.rs b/api/src/handlers/pool_api.rs index 2628323ee..f96d3685e 100644 --- a/api/src/handlers/pool_api.rs +++ b/api/src/handlers/pool_api.rs @@ -13,22 +13,22 @@ // limitations under the License. use super::utils::w; -use core::core::hash::Hashed; -use core::core::Transaction; -use core::ser; +use crate::core::core::hash::Hashed; +use crate::core::core::Transaction; +use crate::core::ser; +use crate::pool; +use crate::rest::*; +use crate::router::{Handler, ResponseFuture}; +use crate::types::*; +use crate::util; +use crate::util::RwLock; +use crate::web::*; use futures::future::ok; use futures::Future; use hyper::{Body, Request, StatusCode}; -use pool; -use rest::*; -use router::{Handler, ResponseFuture}; use std::collections::HashMap; use std::sync::Weak; -use types::*; use url::form_urlencoded; -use util; -use util::RwLock; -use web::*; /// Get basic information about the transaction pool. /// GET /v1/pool @@ -60,7 +60,7 @@ pub struct PoolPushHandler { } impl PoolPushHandler { - fn update_pool(&self, req: Request) -> Box + Send> { + fn update_pool(&self, req: Request) -> Box + Send> { let params = match req.uri().query() { Some(query_string) => form_urlencoded::parse(query_string.as_bytes()) .into_owned() diff --git a/api/src/handlers/server_api.rs b/api/src/handlers/server_api.rs index e7fc5cd6f..42a829a65 100644 --- a/api/src/handlers/server_api.rs +++ b/api/src/handlers/server_api.rs @@ -13,14 +13,14 @@ // limitations under the License. use super::utils::w; -use chain; +use crate::chain; +use crate::p2p; +use crate::rest::*; +use crate::router::{Handler, ResponseFuture}; +use crate::types::*; +use crate::web::*; use hyper::{Body, Request}; -use p2p; -use rest::*; -use router::{Handler, ResponseFuture}; use std::sync::Weak; -use types::*; -use web::*; // RESTful index of available api endpoints // GET /v1/ diff --git a/api/src/handlers/transactions_api.rs b/api/src/handlers/transactions_api.rs index bbd01a483..6dc879855 100644 --- a/api/src/handlers/transactions_api.rs +++ b/api/src/handlers/transactions_api.rs @@ -13,18 +13,18 @@ // limitations under the License. use super::utils::w; -use chain; +use crate::chain; +use crate::rest::*; +use crate::router::{Handler, ResponseFuture}; +use crate::types::*; +use crate::util; +use crate::util::secp::pedersen::Commitment; +use crate::web::*; use failure::ResultExt; use hyper::{Body, Request, StatusCode}; -use rest::*; -use router::{Handler, ResponseFuture}; use std::collections::HashMap; use std::sync::Weak; -use types::*; use url::form_urlencoded; -use util; -use util::secp::pedersen::Commitment; -use web::*; // Sum tree handler. Retrieve the roots: // GET /v1/txhashset/roots diff --git a/api/src/handlers/utils.rs b/api/src/handlers/utils.rs index 41e864bbf..2e2bc01e3 100644 --- a/api/src/handlers/utils.rs +++ b/api/src/handlers/utils.rs @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -use chain; -use core::core::{OutputFeatures, OutputIdentifier}; +use crate::chain; +use crate::core::core::{OutputFeatures, OutputIdentifier}; +use crate::rest::*; +use crate::types::*; +use crate::util; +use crate::util::secp::pedersen::Commitment; use failure::ResultExt; -use rest::*; use std::sync::{Arc, Weak}; -use types::*; -use util; -use util::secp::pedersen::Commitment; // All handlers use `Weak` references instead of `Arc` to avoid cycles that // can never be destroyed. These 2 functions are simple helpers to reduce the diff --git a/api/src/lib.rs b/api/src/lib.rs index cde0399ef..72816796b 100644 --- a/api/src/lib.rs +++ b/api/src/lib.rs @@ -12,36 +12,31 @@ // See the License for the specific language governing permissions and // limitations under the License. -extern crate grin_chain as chain; -extern crate grin_core as core; -extern crate grin_p2p as p2p; -extern crate grin_pool as pool; -extern crate grin_store as store; -extern crate grin_util as util; -extern crate url; +use grin_chain as chain; +use grin_core as core; +use grin_p2p as p2p; +use grin_pool as pool; -extern crate failure; +use grin_util as util; + +use failure; #[macro_use] extern crate failure_derive; -extern crate hyper; +use hyper; #[macro_use] extern crate lazy_static; -extern crate regex; -extern crate ring; -extern crate serde; + +use serde; #[macro_use] extern crate serde_derive; -extern crate serde_json; +use serde_json; #[macro_use] extern crate log; -extern crate futures; -extern crate http; -extern crate hyper_rustls; -extern crate rustls; -extern crate tokio; -extern crate tokio_core; -extern crate tokio_rustls; -extern crate tokio_tcp; + +use hyper_rustls; +use rustls; + +use tokio_tcp; pub mod auth; pub mod client; @@ -51,9 +46,9 @@ mod router; mod types; mod web; -pub use auth::BasicAuthMiddleware; -pub use handlers::start_rest_apis; -pub use rest::*; -pub use router::*; -pub use types::*; -pub use web::*; +pub use crate::auth::BasicAuthMiddleware; +pub use crate::handlers::start_rest_apis; +pub use crate::rest::*; +pub use crate::router::*; +pub use crate::types::*; +pub use crate::web::*; diff --git a/api/src/rest.rs b/api/src/rest.rs index 0badb975d..fa26ef64a 100644 --- a/api/src/rest.rs +++ b/api/src/rest.rs @@ -18,12 +18,12 @@ //! To use it, just have your service(s) implement the ApiEndpoint trait and //! register them on a ApiServer. +use crate::router::{Handler, HandlerObj, ResponseFuture, Router}; use failure::{Backtrace, Context, Fail, ResultExt}; use futures::sync::oneshot; use futures::Stream; use hyper::rt::Future; use hyper::{rt, Body, Request, Server}; -use router::{Handler, HandlerObj, ResponseFuture, Router}; use rustls; use rustls::internal::pemfile; use std::fmt::{self, Display}; @@ -55,7 +55,7 @@ pub enum ErrorKind { } impl Fail for Error { - fn cause(&self) -> Option<&Fail> { + fn cause(&self) -> Option<&dyn Fail> { self.inner.cause() } @@ -65,7 +65,7 @@ impl Fail for Error { } impl Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { Display::fmt(&self.inner, f) } } @@ -196,7 +196,8 @@ impl ApiServer { .map_err(|e| eprintln!("HTTP API server error: {}", e)); rt::run(server); - }).map_err(|_| ErrorKind::Internal("failed to spawn API thread".to_string()).into()) + }) + .map_err(|_| ErrorKind::Internal("failed to spawn API thread".to_string()).into()) } /// Starts the TLS ApiServer at the provided address. @@ -228,13 +229,15 @@ impl ApiServer { error!("accept_async failed: {}", e); Ok(None) } - }).filter_map(|x| x); + }) + .filter_map(|x| x); let server = Server::builder(tls) .serve(router) .map_err(|e| eprintln!("HTTP API server error: {}", e)); rt::run(server); - }).map_err(|_| ErrorKind::Internal("failed to spawn API thread".to_string()).into()) + }) + .map_err(|_| ErrorKind::Internal("failed to spawn API thread".to_string()).into()) } /// Stops the API server, it panics in case of error @@ -258,7 +261,7 @@ impl Handler for LoggingMiddleware { fn call( &self, req: Request, - mut handlers: Box>, + mut handlers: Box>, ) -> ResponseFuture { debug!("REST call: {} {}", req.method(), req.uri().path()); handlers.next().unwrap().call(req, handlers) diff --git a/api/src/router.rs b/api/src/router.rs index 5f24b033b..ad94a726b 100644 --- a/api/src/router.rs +++ b/api/src/router.rs @@ -26,7 +26,7 @@ lazy_static! { static ref WILDCARD_STOP_HASH: u64 = calculate_hash(&"**"); } -pub type ResponseFuture = Box, Error = hyper::Error> + Send>; +pub type ResponseFuture = Box, Error = hyper::Error> + Send>; pub trait Handler { fn get(&self, _req: Request) -> ResponseFuture { @@ -68,7 +68,7 @@ pub trait Handler { fn call( &self, req: Request, - mut _handlers: Box>, + mut _handlers: Box>, ) -> ResponseFuture { match req.method() { &Method::GET => self.get(req), @@ -105,7 +105,7 @@ struct NodeId(usize); const MAX_CHILDREN: usize = 16; -pub type HandlerObj = Arc; +pub type HandlerObj = Arc; #[derive(Clone)] pub struct Node { @@ -147,7 +147,8 @@ impl Router { .find(|&id| { let node_key = self.node(*id).key; node_key == key || node_key == *WILDCARD_HASH || node_key == *WILDCARD_STOP_HASH - }).cloned() + }) + .cloned() } fn add_empty_node(&mut self, parent: NodeId, key: u64) -> NodeId { @@ -225,7 +226,7 @@ impl NewService for Router { type Error = hyper::Error; type InitError = hyper::Error; type Service = Router; - type Future = Box + Send>; + type Future = Box + Send>; fn new_service(&self) -> Self::Future { Box::new(future::ok(self.clone())) } diff --git a/api/src/types.rs b/api/src/types.rs index 379cfc923..2024d07fb 100644 --- a/api/src/types.rs +++ b/api/src/types.rs @@ -14,17 +14,17 @@ use std::sync::Arc; -use chain; -use core::core::hash::Hashed; -use core::core::merkle_proof::MerkleProof; -use core::{core, ser}; -use p2p; +use crate::chain; +use crate::core::core::hash::Hashed; +use crate::core::core::merkle_proof::MerkleProof; +use crate::core::{core, ser}; +use crate::p2p; +use crate::util; +use crate::util::secp::pedersen; use serde; use serde::de::MapAccess; use serde::ser::SerializeStruct; use std::fmt; -use util; -use util::secp::pedersen; macro_rules! no_dup { ($field:ident) => { @@ -210,7 +210,7 @@ struct PrintableCommitmentVisitor; impl<'de> serde::de::Visitor<'de> for PrintableCommitmentVisitor { type Value = PrintableCommitment; - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str("a Pedersen commitment") } @@ -361,7 +361,7 @@ impl<'de> serde::de::Deserialize<'de> for OutputPrintable { impl<'de> serde::de::Visitor<'de> for OutputPrintableVisitor { type Value = OutputPrintable; - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str("a print able Output") } @@ -571,7 +571,8 @@ impl BlockPrintable { Some(&block.header), include_proof, ) - }).collect(); + }) + .collect(); let kernels = block .kernels() .iter() diff --git a/api/src/web.rs b/api/src/web.rs index c7f487979..10eebcbb2 100644 --- a/api/src/web.rs +++ b/api/src/web.rs @@ -1,14 +1,14 @@ +use crate::rest::*; +use crate::router::ResponseFuture; use futures::future::{err, ok}; use futures::{Future, Stream}; use hyper::{Body, Request, Response, StatusCode}; -use rest::*; -use router::ResponseFuture; use serde::{Deserialize, Serialize}; use serde_json; use std::fmt::Debug; /// Parse request body -pub fn parse_body(req: Request) -> Box + Send> +pub fn parse_body(req: Request) -> Box + Send> where for<'de> T: Deserialize<'de> + Send + 'static, { diff --git a/api/tests/rest.rs b/api/tests/rest.rs index e6e564819..641ce3d2e 100644 --- a/api/tests/rest.rs +++ b/api/tests/rest.rs @@ -1,8 +1,7 @@ -extern crate grin_api as api; -extern crate grin_util as util; -extern crate hyper; +use grin_api as api; +use grin_util as util; -use api::*; +use crate::api::*; use hyper::{Body, Request}; use std::net::SocketAddr; use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; @@ -41,7 +40,7 @@ impl Handler for CounterMiddleware { fn call( &self, req: Request, - mut handlers: Box>, + mut handlers: Box>, ) -> ResponseFuture { self.counter.fetch_add(1, Ordering::SeqCst); handlers.next().unwrap().call(req, handlers) diff --git a/chain/Cargo.toml b/chain/Cargo.toml index b1a305961..ebb7b4d9a 100644 --- a/chain/Cargo.toml +++ b/chain/Cargo.toml @@ -7,6 +7,7 @@ license = "Apache-2.0" repository = "https://github.com/mimblewimble/grin" keywords = [ "crypto", "grin", "mimblewimble" ] workspace = ".." +edition = "2018" [dependencies] bitflags = "1" diff --git a/chain/src/chain.rs b/chain/src/chain.rs index f2563ec07..a9e115924 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -15,32 +15,30 @@ //! Facade and handler for the rest of the blockchain implementation //! and mostly the chain pipeline. +use crate::core::core::hash::{Hash, Hashed, ZERO_HASH}; +use crate::core::core::merkle_proof::MerkleProof; +use crate::core::core::verifier_cache::VerifierCache; +use crate::core::core::{ + Block, BlockHeader, BlockSums, Committed, Output, OutputIdentifier, Transaction, TxKernelEntry, +}; +use crate::core::global; +use crate::core::pow; +use crate::error::{Error, ErrorKind}; +use crate::lmdb; +use crate::pipe; +use crate::store; +use crate::txhashset; +use crate::types::{ + BlockStatus, ChainAdapter, NoStatus, Options, Tip, TxHashSetRoots, TxHashsetWriteStatus, +}; +use crate::util::secp::pedersen::{Commitment, RangeProof}; +use crate::util::RwLock; +use grin_store::Error::NotFoundErr; use std::collections::HashMap; use std::fs::File; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use std::time::{Duration, Instant}; -use util::RwLock; - -use lmdb; - -use core::core::hash::{Hash, Hashed, ZERO_HASH}; -use core::core::merkle_proof::MerkleProof; -use core::core::verifier_cache::VerifierCache; -use core::core::{ - Block, BlockHeader, BlockSums, Committed, Output, OutputIdentifier, Transaction, TxKernelEntry, -}; -use core::global; -use core::pow; -use error::{Error, ErrorKind}; -use grin_store::Error::NotFoundErr; -use pipe; -use store; -use txhashset; -use types::{ - BlockStatus, ChainAdapter, NoStatus, Options, Tip, TxHashSetRoots, TxHashsetWriteStatus, -}; -use util::secp::pedersen::{Commitment, RangeProof}; /// Orphan pool size is limited by MAX_ORPHAN_SIZE pub const MAX_ORPHAN_SIZE: usize = 200; @@ -144,10 +142,10 @@ impl OrphanBlockPool { pub struct Chain { db_root: String, store: Arc, - adapter: Arc, + adapter: Arc, orphans: Arc, txhashset: Arc>, - verifier_cache: Arc>, + verifier_cache: Arc>, // POW verification function pow_verifier: fn(&BlockHeader) -> Result<(), pow::Error>, archive_mode: bool, @@ -161,10 +159,10 @@ impl Chain { pub fn init( db_root: String, db_env: Arc, - adapter: Arc, + adapter: Arc, genesis: Block, pow_verifier: fn(&BlockHeader) -> Result<(), pow::Error>, - verifier_cache: Arc>, + verifier_cache: Arc>, archive_mode: bool, ) -> Result { let chain_store = store::ChainStore::new(db_env)?; @@ -782,7 +780,7 @@ impl Chain { &self, h: Hash, txhashset_data: File, - status: &TxHashsetWriteStatus, + status: &dyn TxHashsetWriteStatus, ) -> Result<(), Error> { status.on_setup(); @@ -988,7 +986,8 @@ impl Chain { if outputs.0 != rangeproofs.0 || outputs.1.len() != rangeproofs.1.len() { return Err(ErrorKind::TxHashSetErr(String::from( "Output and rangeproof sets don't match", - )).into()); + )) + .into()); } let mut output_vec: Vec = vec![]; for (ref x, &y) in outputs.1.iter().zip(rangeproofs.1.iter()) { @@ -1131,7 +1130,7 @@ impl Chain { /// Builds an iterator on blocks starting from the current chain head and /// running backward. Specialized to return information pertaining to block /// difficulty calculation (timestamp and previous difficulties). - pub fn difficulty_iter(&self) -> store::DifficultyIter { + pub fn difficulty_iter(&self) -> store::DifficultyIter<'_> { let head = self.head().unwrap(); let store = self.store.clone(); store::DifficultyIter::from(head.last_block_h, store) diff --git a/chain/src/error.rs b/chain/src/error.rs index 133a2bdd1..1ef741280 100644 --- a/chain/src/error.rs +++ b/chain/src/error.rs @@ -13,17 +13,16 @@ // limitations under the License. //! Error types for chain +use crate::core::core::{block, committed, transaction}; +use crate::core::ser; +use crate::keychain; +use crate::util::secp; +use crate::util::secp::pedersen::Commitment; use failure::{Backtrace, Context, Fail}; +use grin_store as store; use std::fmt::{self, Display}; use std::io; -use core::core::{block, committed, transaction}; -use core::ser; -use grin_store as store; -use keychain; -use util::secp; -use util::secp::pedersen::Commitment; - /// Error definition #[derive(Debug, Fail)] pub struct Error { @@ -132,7 +131,7 @@ pub enum ErrorKind { } impl Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let cause = match self.cause() { Some(c) => format!("{}", c), None => String::from("Unknown"), @@ -155,7 +154,7 @@ impl Error { self.inner.get_context().clone() } /// get cause - pub fn cause(&self) -> Option<&Fail> { + pub fn cause(&self) -> Option<&dyn Fail> { self.inner.cause() } /// get backtrace diff --git a/chain/src/lib.rs b/chain/src/lib.rs index 9b6e65ff6..29ff83bd7 100644 --- a/chain/src/lib.rs +++ b/chain/src/lib.rs @@ -22,24 +22,19 @@ #[macro_use] extern crate bitflags; -extern crate byteorder; -extern crate croaring; -extern crate lmdb_zero as lmdb; -extern crate lru_cache; -extern crate serde; + +use lmdb_zero as lmdb; + #[macro_use] extern crate serde_derive; #[macro_use] extern crate log; -extern crate chrono; -extern crate failure; -#[macro_use] -extern crate failure_derive; -extern crate grin_core as core; -extern crate grin_keychain as keychain; -extern crate grin_store; -extern crate grin_util as util; +use failure; +use grin_core as core; +use grin_keychain as keychain; +use grin_store; +use grin_util as util; mod chain; mod error; @@ -50,7 +45,7 @@ pub mod types; // Re-export the base interface -pub use chain::{Chain, MAX_ORPHAN_SIZE}; -pub use error::{Error, ErrorKind}; -pub use store::ChainStore; -pub use types::{BlockStatus, ChainAdapter, Options, Tip, TxHashsetWriteStatus}; +pub use crate::chain::{Chain, MAX_ORPHAN_SIZE}; +pub use crate::error::{Error, ErrorKind}; +pub use crate::store::ChainStore; +pub use crate::types::{BlockStatus, ChainAdapter, Options, Tip, TxHashsetWriteStatus}; diff --git a/chain/src/pipe.rs b/chain/src/pipe.rs index 8f74a357b..1bc599bdf 100644 --- a/chain/src/pipe.rs +++ b/chain/src/pipe.rs @@ -14,25 +14,23 @@ //! Implementation of the chain block acceptance (or refusal) pipeline. -use std::sync::Arc; -use util::RwLock; - +use crate::chain::OrphanBlockPool; +use crate::core::consensus; +use crate::core::core::hash::Hashed; +use crate::core::core::verifier_cache::VerifierCache; +use crate::core::core::Committed; +use crate::core::core::{Block, BlockHeader, BlockSums}; +use crate::core::global; +use crate::core::pow; +use crate::error::{Error, ErrorKind}; +use crate::store; +use crate::txhashset; +use crate::types::{Options, Tip}; +use crate::util::RwLock; use chrono::prelude::Utc; use chrono::Duration; - -use chain::OrphanBlockPool; -use core::consensus; -use core::core::hash::Hashed; -use core::core::verifier_cache::VerifierCache; -use core::core::Committed; -use core::core::{Block, BlockHeader, BlockSums}; -use core::global; -use core::pow; -use error::{Error, ErrorKind}; use grin_store; -use store; -use txhashset; -use types::{Options, Tip}; +use std::sync::Arc; /// Contextual information required to process a new block and either reject or /// accept it. @@ -46,7 +44,7 @@ pub struct BlockContext<'a> { /// The active batch to use for block processing. pub batch: store::Batch<'a>, /// The verifier cache (caching verifier for rangeproofs and kernel signatures) - pub verifier_cache: Arc>, + pub verifier_cache: Arc>, /// Recent orphan blocks to avoid double-processing pub orphans: Arc, } @@ -56,7 +54,7 @@ pub struct BlockContext<'a> { fn process_header_for_block( header: &BlockHeader, is_fork: bool, - ctx: &mut BlockContext, + ctx: &mut BlockContext<'_>, ) -> Result<(), Error> { txhashset::header_extending(&mut ctx.txhashset, &mut ctx.batch, |extension| { extension.force_rollback(); @@ -77,7 +75,7 @@ fn process_header_for_block( // Check if we already know about this block for various reasons // from cheapest to most expensive (delay hitting the db until last). -fn check_known(block: &Block, ctx: &mut BlockContext) -> Result<(), Error> { +fn check_known(block: &Block, ctx: &mut BlockContext<'_>) -> Result<(), Error> { check_known_head(&block.header, ctx)?; check_known_orphans(&block.header, ctx)?; check_known_store(&block.header, ctx)?; @@ -87,7 +85,7 @@ fn check_known(block: &Block, ctx: &mut BlockContext) -> Result<(), Error> { /// Runs the block processing pipeline, including validation and finding a /// place for the new block in the chain. /// Returns new head if chain head updated. -pub fn process_block(b: &Block, ctx: &mut BlockContext) -> Result, Error> { +pub fn process_block(b: &Block, ctx: &mut BlockContext<'_>) -> Result, Error> { // TODO should just take a promise for a block with a full header so we don't // spend resources reading the full block when its header is invalid @@ -183,7 +181,7 @@ pub fn process_block(b: &Block, ctx: &mut BlockContext) -> Result, E /// This is only ever used during sync and uses a context based on sync_head. pub fn sync_block_headers( headers: &[BlockHeader], - ctx: &mut BlockContext, + ctx: &mut BlockContext<'_>, ) -> Result, Error> { if let Some(header) = headers.first() { debug!( @@ -251,7 +249,7 @@ pub fn sync_block_headers( /// We validate the header but we do not store it or update header head based /// on this. We will update these once we get the block back after requesting /// it. -pub fn process_block_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), Error> { +pub fn process_block_header(header: &BlockHeader, ctx: &mut BlockContext<'_>) -> Result<(), Error> { debug!( "pipe: process_block_header: {} at {}", header.hash(), @@ -266,7 +264,7 @@ pub fn process_block_header(header: &BlockHeader, ctx: &mut BlockContext) -> Res /// Quick in-memory check to fast-reject any block header we've already handled /// recently. Keeps duplicates from the network in check. /// ctx here is specific to the header_head (tip of the header chain) -fn check_header_known(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), Error> { +fn check_header_known(header: &BlockHeader, ctx: &mut BlockContext<'_>) -> Result<(), Error> { let header_head = ctx.batch.header_head()?; if header.hash() == header_head.last_block_h || header.hash() == header_head.prev_block_h { return Err(ErrorKind::Unfit("header already known".to_string()).into()); @@ -277,7 +275,7 @@ fn check_header_known(header: &BlockHeader, ctx: &mut BlockContext) -> Result<() /// Quick in-memory check to fast-reject any block handled recently. /// Keeps duplicates from the network in check. /// Checks against the last_block_h and prev_block_h of the chain head. -fn check_known_head(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), Error> { +fn check_known_head(header: &BlockHeader, ctx: &mut BlockContext<'_>) -> Result<(), Error> { let head = ctx.batch.head()?; let bh = header.hash(); if bh == head.last_block_h || bh == head.prev_block_h { @@ -287,7 +285,7 @@ fn check_known_head(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), } /// Check if this block is in the set of known orphans. -fn check_known_orphans(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), Error> { +fn check_known_orphans(header: &BlockHeader, ctx: &mut BlockContext<'_>) -> Result<(), Error> { if ctx.orphans.contains(&header.hash()) { Err(ErrorKind::Unfit("already known in orphans".to_string()).into()) } else { @@ -296,7 +294,7 @@ fn check_known_orphans(header: &BlockHeader, ctx: &mut BlockContext) -> Result<( } // Check if this block is in the store already. -fn check_known_store(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), Error> { +fn check_known_store(header: &BlockHeader, ctx: &mut BlockContext<'_>) -> Result<(), Error> { match ctx.batch.block_exists(&header.hash()) { Ok(true) => { let head = ctx.batch.head()?; @@ -321,7 +319,10 @@ fn check_known_store(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), // Find the previous header from the store. // Return an Orphan error if we cannot find the previous header. -fn prev_header_store(header: &BlockHeader, batch: &mut store::Batch) -> Result { +fn prev_header_store( + header: &BlockHeader, + batch: &mut store::Batch<'_>, +) -> Result { let prev = batch.get_previous_header(&header).map_err(|e| match e { grin_store::Error::NotFoundErr(_) => ErrorKind::Orphan, _ => ErrorKind::StoreErr(e, "check prev header".into()), @@ -332,7 +333,7 @@ fn prev_header_store(header: &BlockHeader, batch: &mut store::Batch) -> Result Result<(), Error> { +fn validate_header(header: &BlockHeader, ctx: &mut BlockContext<'_>) -> Result<(), Error> { // check version, enforces scheduled hard fork if !consensus::valid_header_version(header.height, header.version) { error!( @@ -425,7 +426,7 @@ fn validate_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), E Ok(()) } -fn validate_block(block: &Block, ctx: &mut BlockContext) -> Result<(), Error> { +fn validate_block(block: &Block, ctx: &mut BlockContext<'_>) -> Result<(), Error> { let prev = ctx.batch.get_previous_header(&block.header)?; block .validate(&prev.total_kernel_offset, ctx.verifier_cache.clone()) @@ -437,7 +438,10 @@ fn validate_block(block: &Block, ctx: &mut BlockContext) -> Result<(), Error> { /// Verify the block is not attempting to spend coinbase outputs /// before they have sufficiently matured. /// Note: requires a txhashset extension. -fn verify_coinbase_maturity(block: &Block, ext: &mut txhashset::Extension) -> Result<(), Error> { +fn verify_coinbase_maturity( + block: &Block, + ext: &mut txhashset::Extension<'_>, +) -> Result<(), Error> { ext.verify_coinbase_maturity(&block.inputs(), block.header.height)?; Ok(()) } @@ -447,7 +451,7 @@ fn verify_coinbase_maturity(block: &Block, ext: &mut txhashset::Extension) -> Re /// This allows us to verify kernel sums across the full utxo and kernel sets /// based on block_sums of previous block, accounting for the inputs|outputs|kernels /// of the new block. -fn verify_block_sums(b: &Block, ext: &mut txhashset::Extension) -> Result<(), Error> { +fn verify_block_sums(b: &Block, ext: &mut txhashset::Extension<'_>) -> Result<(), Error> { // TODO - this is 2 db calls, can we optimize this? // Retrieve the block_sums for the previous block. let prev = ext.batch.get_previous_header(&b.header)?; @@ -462,7 +466,7 @@ fn verify_block_sums(b: &Block, ext: &mut txhashset::Extension) -> Result<(), Er // Verify the kernel sums for the block_sums with the new block applied. let (utxo_sum, kernel_sum) = - (block_sums, b as &Committed).verify_kernel_sums(overage, offset)?; + (block_sums, b as &dyn Committed).verify_kernel_sums(overage, offset)?; // Save the new block_sums for the new block to the db via the batch. ext.batch.save_block_sums( @@ -478,7 +482,10 @@ fn verify_block_sums(b: &Block, ext: &mut txhashset::Extension) -> Result<(), Er /// Fully validate the block by applying it to the txhashset extension. /// Check both the txhashset roots and sizes are correct after applying the block. -fn apply_block_to_txhashset(block: &Block, ext: &mut txhashset::Extension) -> Result<(), Error> { +fn apply_block_to_txhashset( + block: &Block, + ext: &mut txhashset::Extension<'_>, +) -> Result<(), Error> { ext.validate_header_root(&block.header)?; ext.apply_block(block)?; ext.validate_roots()?; @@ -488,7 +495,7 @@ fn apply_block_to_txhashset(block: &Block, ext: &mut txhashset::Extension) -> Re /// Officially adds the block to our chain. /// Header must be added separately (assume this has been done previously). -fn add_block(b: &Block, batch: &store::Batch) -> Result<(), Error> { +fn add_block(b: &Block, batch: &store::Batch<'_>) -> Result<(), Error> { batch .save_block(b) .map_err(|e| ErrorKind::StoreErr(e, "pipe save block".to_owned()))?; @@ -496,7 +503,7 @@ fn add_block(b: &Block, batch: &store::Batch) -> Result<(), Error> { } /// Update the block chain tail so we can know the exact tail of full blocks in this node -fn update_body_tail(bh: &BlockHeader, batch: &store::Batch) -> Result<(), Error> { +fn update_body_tail(bh: &BlockHeader, batch: &store::Batch<'_>) -> Result<(), Error> { let tip = Tip::from_header(bh); batch .save_body_tail(&tip) @@ -506,7 +513,7 @@ fn update_body_tail(bh: &BlockHeader, batch: &store::Batch) -> Result<(), Error> } /// Officially adds the block header to our header chain. -fn add_block_header(bh: &BlockHeader, batch: &store::Batch) -> Result<(), Error> { +fn add_block_header(bh: &BlockHeader, batch: &store::Batch<'_>) -> Result<(), Error> { batch .save_block_header(bh) .map_err(|e| ErrorKind::StoreErr(e, "pipe save header".to_owned()))?; @@ -516,7 +523,7 @@ fn add_block_header(bh: &BlockHeader, batch: &store::Batch) -> Result<(), Error> /// Directly updates the head if we've just appended a new block to it or handle /// the situation where we've just added enough work to have a fork with more /// work than the head. -fn update_head(b: &Block, ctx: &BlockContext) -> Result, Error> { +fn update_head(b: &Block, ctx: &BlockContext<'_>) -> Result, Error> { // if we made a fork with more work than the head (which should also be true // when extending the head), update it let head = ctx.batch.head()?; @@ -544,7 +551,7 @@ fn has_more_work(header: &BlockHeader, head: &Tip) -> bool { } /// Update the sync head so we can keep syncing from where we left off. -fn update_sync_head(bh: &BlockHeader, batch: &mut store::Batch) -> Result<(), Error> { +fn update_sync_head(bh: &BlockHeader, batch: &mut store::Batch<'_>) -> Result<(), Error> { let tip = Tip::from_header(bh); batch .save_sync_head(&tip) @@ -554,7 +561,7 @@ fn update_sync_head(bh: &BlockHeader, batch: &mut store::Batch) -> Result<(), Er } /// Update the header head if this header has most work. -fn update_header_head(bh: &BlockHeader, ctx: &mut BlockContext) -> Result, Error> { +fn update_header_head(bh: &BlockHeader, ctx: &mut BlockContext<'_>) -> Result, Error> { let header_head = ctx.batch.header_head()?; if has_more_work(&bh, &header_head) { let tip = Tip::from_header(bh); @@ -576,7 +583,7 @@ fn update_header_head(bh: &BlockHeader, ctx: &mut BlockContext) -> Result