Merge branch 'master' of github.com:ethcore/parity into discovery

This commit is contained in:
arkpar 2016-02-19 13:39:43 +01:00
commit d9fec87143
32 changed files with 409 additions and 324 deletions

View File

@ -9,10 +9,14 @@ branches:
- /^beta$/ - /^beta$/
- /^stable$/ - /^stable$/
matrix: matrix:
fast_finish: true fast_finish: false
include: allow_failures:
- rust: nightly - rust: nightly
env: FEATURES="--features ethcore/json-tests" KCOV_FEATURES="" TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity" ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}" include:
- rust: beta
env: FEATURES="--features travis-beta" KCOV_FEATURES="" TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity" ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}"
- rust: nightly
env: FEATURES="--features travis-nightly" KCOV_FEATURES="" TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity" ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}"
cache: cache:
apt: true apt: true
directories: directories:
@ -20,6 +24,7 @@ cache:
- target/debug/build - target/debug/build
- target/release/deps - target/release/deps
- target/release/build - target/release/build
- $HOME/.cargo
addons: addons:
apt: apt:
packages: packages:
@ -33,7 +38,7 @@ before_script: |
script: script:
- cargo build --release --verbose ${FEATURES} - cargo build --release --verbose ${FEATURES}
- cargo test --release --verbose ${FEATURES} ${TARGETS} - cargo test --release --verbose ${FEATURES} ${TARGETS}
- cargo bench --no-run ${FEATURES} ${TARGETS} #- cargo bench --no-run ${FEATURES} ${TARGETS}
- tar cvzf parity${ARCHIVE_SUFFIX}.tar.gz -C target/release parity - tar cvzf parity${ARCHIVE_SUFFIX}.tar.gz -C target/release parity
after_success: | after_success: |
wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz &&
@ -47,7 +52,7 @@ after_success: |
./kcov-master/tmp/usr/local/bin/kcov --coveralls-id=${TRAVIS_JOB_ID} --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/parity-* && ./kcov-master/tmp/usr/local/bin/kcov --coveralls-id=${TRAVIS_JOB_ID} --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/parity-* &&
[ $TRAVIS_BRANCH = master ] && [ $TRAVIS_BRANCH = master ] &&
[ $TRAVIS_PULL_REQUEST = false ] && [ $TRAVIS_PULL_REQUEST = false ] &&
[ $TRAVIS_RUST_VERSION = nightly ] && [ $TRAVIS_RUST_VERSION = beta ] &&
cargo doc --no-deps --verbose ${KCOV_FEATURES} ${TARGETS} && cargo doc --no-deps --verbose ${KCOV_FEATURES} ${TARGETS} &&
echo '<meta http-equiv=refresh content=0;url=ethcore/index.html>' > target/doc/index.html && echo '<meta http-equiv=refresh content=0;url=ethcore/index.html>' > target/doc/index.html &&
pip install --user ghp-import && pip install --user ghp-import &&

165
Cargo.lock generated
View File

@ -2,11 +2,10 @@
name = "parity" name = "parity"
version = "0.9.99" version = "0.9.99"
dependencies = [ dependencies = [
"clippy 0.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.42 (registry+https://github.com/rust-lang/crates.io-index)",
"ctrlc 1.0.1 (git+https://github.com/tomusdrw/rust-ctrlc.git)", "ctrlc 1.0.1 (git+https://github.com/tomusdrw/rust-ctrlc.git)",
"daemonize 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "daemonize 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"docopt 0.6.78 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.78 (registry+https://github.com/rust-lang/crates.io-index)",
"docopt_macros 0.6.81 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 0.9.99", "ethcore 0.9.99",
"ethcore-rpc 0.9.99", "ethcore-rpc 0.9.99",
@ -20,7 +19,7 @@ dependencies = [
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "0.5.0" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
@ -37,8 +36,11 @@ dependencies = [
[[package]] [[package]]
name = "aster" name = "aster"
version = "0.12.0" version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"syntex_syntax 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "bitflags" name = "bitflags"
@ -62,11 +64,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "clippy" name = "clippy"
version = "0.0.41" version = "0.0.42"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"regex-syntax 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -127,14 +129,6 @@ dependencies = [
"strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "docopt_macros"
version = "0.6.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"docopt 0.6.78 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "elastic-array" name = "elastic-array"
version = "0.4.0" version = "0.4.0"
@ -152,14 +146,14 @@ dependencies = [
[[package]] [[package]]
name = "eth-secp256k1" name = "eth-secp256k1"
version = "0.5.4" version = "0.5.4"
source = "git+https://github.com/arkpar/rust-secp256k1.git#321e6c22a83606d1875f89cb61c9cb37c7d249ae" source = "git+https://github.com/arkpar/rust-secp256k1.git#45503e1de68d909b1862e3f2bdb9e1cdfdff3f1e"
dependencies = [ dependencies = [
"arrayvec 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -168,7 +162,6 @@ name = "ethash"
version = "0.9.99" version = "0.9.99"
dependencies = [ dependencies = [
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"lru-cache 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"sha3 0.1.0", "sha3 0.1.0",
] ]
@ -176,12 +169,12 @@ dependencies = [
name = "ethcore" name = "ethcore"
version = "0.9.99" version = "0.9.99"
dependencies = [ dependencies = [
"clippy 0.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.42 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 0.9.99", "ethash 0.9.99",
"ethcore-util 0.9.99", "ethcore-util 0.9.99",
"heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
@ -195,16 +188,17 @@ dependencies = [
name = "ethcore-rpc" name = "ethcore-rpc"
version = "0.9.99" version = "0.9.99"
dependencies = [ dependencies = [
"clippy 0.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.42 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 0.9.99", "ethcore 0.9.99",
"ethcore-util 0.9.99", "ethcore-util 0.9.99",
"ethsync 0.9.99", "ethsync 0.9.99",
"jsonrpc-core 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-http-server 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-http-server 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_codegen 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
"target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -213,12 +207,12 @@ name = "ethcore-util"
version = "0.9.99" version = "0.9.99"
dependencies = [ dependencies = [
"arrayvec 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.42 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"eth-secp256k1 0.5.4 (git+https://github.com/arkpar/rust-secp256k1.git)", "eth-secp256k1 0.5.4 (git+https://github.com/arkpar/rust-secp256k1.git)",
"heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"igd 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "igd 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"json-tests 0.1.0", "json-tests 0.1.0",
@ -230,7 +224,7 @@ dependencies = [
"rocksdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rocksdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
"sha3 0.1.0", "sha3 0.1.0",
"slab 0.1.4 (git+https://github.com/arkpar/slab.git)", "slab 0.1.4 (git+https://github.com/arkpar/slab.git)",
"target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -242,7 +236,7 @@ dependencies = [
name = "ethsync" name = "ethsync"
version = "0.9.99" version = "0.9.99"
dependencies = [ dependencies = [
"clippy 0.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.42 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 0.9.99", "ethcore 0.9.99",
"ethcore-util 0.9.99", "ethcore-util 0.9.99",
@ -270,11 +264,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "heapsize" name = "heapsize"
version = "0.2.5" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "hpack" name = "hpack"
@ -356,12 +347,13 @@ dependencies = [
[[package]] [[package]]
name = "jsonrpc-core" name = "jsonrpc-core"
version = "1.1.2" version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_codegen 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -370,7 +362,7 @@ version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"hyper 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-core 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -407,11 +399,6 @@ name = "libc"
version = "0.2.7" version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "linked-hash-map"
version = "0.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "log" name = "log"
version = "0.3.5" version = "0.3.5"
@ -420,14 +407,6 @@ dependencies = [
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "lru-cache"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"linked-hash-map 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "matches" name = "matches"
version = "0.1.2" version = "0.1.2"
@ -447,7 +426,7 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -513,7 +492,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "num" name = "num"
version = "0.1.30" version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
@ -537,23 +516,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "quasi" name = "quasi"
version = "0.6.0" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "quasi_codegen"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"aster 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_syntax 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "quasi_macros" name = "quasi_codegen"
version = "0.6.0" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"quasi_codegen 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "aster 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
"syntex_syntax 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -569,7 +545,7 @@ name = "regex"
version = "0.1.51" version = "0.1.51"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"aho-corasick 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -607,7 +583,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "rustc_version" name = "rustc_version"
version = "0.1.6" version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
@ -620,7 +596,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "semver" name = "semver"
version = "0.2.2" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"nom 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "nom 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -628,20 +604,22 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "0.6.13" version = "0.6.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"num 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "serde_codegen" name = "serde_codegen"
version = "0.6.13" version = "0.6.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"aster 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "aster 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"quasi 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "quasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"quasi_macros 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "quasi_codegen 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
"syntex_syntax 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -649,16 +627,8 @@ name = "serde_json"
version = "0.6.0" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"num 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_macros"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde_codegen 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -692,11 +662,41 @@ name = "strsim"
version = "0.3.0" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "syntex"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"syntex_syntax 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "syntex_syntax"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
"term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "target_info" name = "target_info"
version = "0.1.0" version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "term"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "time" name = "time"
version = "0.1.34" version = "0.1.34"
@ -727,7 +727,7 @@ name = "unicase"
version = "1.2.1" version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"rustc_version 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -743,6 +743,11 @@ name = "unicode-normalization"
version = "0.1.2" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-xid"
version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "url" name = "url"
version = "0.2.38" version = "0.2.38"

View File

@ -10,9 +10,8 @@ log = "0.3"
env_logger = "0.3" env_logger = "0.3"
rustc-serialize = "0.3" rustc-serialize = "0.3"
docopt = "0.6" docopt = "0.6"
docopt_macros = "0.6"
ctrlc = { git = "https://github.com/tomusdrw/rust-ctrlc.git" } ctrlc = { git = "https://github.com/tomusdrw/rust-ctrlc.git" }
clippy = "0.0.41" clippy = { version = "0.0.42", optional = true }
ethcore-util = { path = "util" } ethcore-util = { path = "util" }
ethcore = { path = "ethcore" } ethcore = { path = "ethcore" }
ethsync = { path = "sync" } ethsync = { path = "sync" }
@ -24,6 +23,9 @@ daemonize = "0.2"
[features] [features]
default = ["rpc"] default = ["rpc"]
rpc = ["ethcore-rpc"] rpc = ["ethcore-rpc"]
dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "ethcore-rpc/dev"]
travis-beta = ["ethcore/json-tests"]
travis-nightly = ["ethcore/json-tests", "dev"]
[[bin]] [[bin]]
path = "parity/main.rs" path = "parity/main.rs"

View File

@ -1,6 +1,6 @@
# ethcore # ethcore
[![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Join the chat at https://gitter.im/trogdoro/xiki][gitter-image]][gitter-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Join the chat at https://gitter.im/trogdoro/xiki][gitter-image]][gitter-url] [![GPLv3][license-image]][license-url]
[travis-image]: https://travis-ci.org/ethcore/parity.svg?branch=master [travis-image]: https://travis-ci.org/ethcore/parity.svg?branch=master
[travis-url]: https://travis-ci.org/ethcore/parity [travis-url]: https://travis-ci.org/ethcore/parity
@ -8,6 +8,8 @@
[coveralls-url]: https://coveralls.io/github/ethcore/parity?branch=master [coveralls-url]: https://coveralls.io/github/ethcore/parity?branch=master
[gitter-image]: https://badges.gitter.im/Join%20Chat.svg [gitter-image]: https://badges.gitter.im/Join%20Chat.svg
[gitter-url]: https://gitter.im/ethcore/parity?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge [gitter-url]: https://gitter.im/ethcore/parity?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[license-image]: https://img.shields.io/badge/license-GPL%20v3-green.svg
[license-url]: http://www.gnu.org/licenses/gpl-3.0.en.html
[Documentation](http://ethcore.github.io/parity/ethcore/index.html) [Documentation](http://ethcore.github.io/parity/ethcore/index.html)
@ -24,9 +26,8 @@ apt-get install -y --force-yes librocksdb-dev
# install multirust # install multirust
curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sh -s -- --yes curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sh -s -- --yes
# install nightly and make it default # install beta and make it default
multirust update nightly multirust default beta
multirust default nightly
# download and build parity # download and build parity
git clone https://github.com/ethcore/parity git clone https://github.com/ethcore/parity
@ -45,12 +46,11 @@ sudo cp -a librocksdb.so* /usr/lib
sudo ldconfig sudo ldconfig
cd .. cd ..
# install rust nightly # install rust beta
curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sudo sh -s -- --yes curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sudo sh -s -- --yes
# install nightly and make it default # install beta and make it default
sudo multirust update nightly sudo multirust default beta
sudo multirust default nightly
# download and build parity # download and build parity
git clone https://github.com/ethcore/parity git clone https://github.com/ethcore/parity
@ -66,8 +66,8 @@ brew update
brew install rocksdb brew install rocksdb
brew install multirust brew install multirust
# install nightly and make it default # install beta and make it default
multirust update nightly && multirust default nightly multirust default beta
# download and build parity # download and build parity
git clone https://github.com/ethcore/parity git clone https://github.com/ethcore/parity

View File

@ -7,5 +7,4 @@ authors = ["arkpar <arkadiy@ethcore.io"]
[dependencies] [dependencies]
log = "0.3" log = "0.3"
lru-cache = "0.0"
sha3 = { path = "../util/sha3" } sha3 = { path = "../util/sha3" }

View File

@ -17,28 +17,39 @@
//! Ethash implementation //! Ethash implementation
//! See https://github.com/ethereum/wiki/wiki/Ethash //! See https://github.com/ethereum/wiki/wiki/Ethash
extern crate sha3; extern crate sha3;
extern crate lru_cache;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
mod sizes; mod sizes;
mod compute; mod compute;
use lru_cache::LruCache; use std::mem;
use compute::Light; use compute::Light;
pub use compute::{quick_get_difficulty, H256, ProofOfWork, ETHASH_EPOCH_LENGTH}; pub use compute::{quick_get_difficulty, H256, ProofOfWork, ETHASH_EPOCH_LENGTH};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
struct LightCache {
recent_epoch: Option<u64>,
recent: Option<Arc<Light>>,
prev_epoch: Option<u64>,
prev: Option<Arc<Light>>,
}
/// Lighy/Full cache manager /// Lighy/Full cache manager
pub struct EthashManager { pub struct EthashManager {
lights: Mutex<LruCache<u64, Arc<Light>>> cache: Mutex<LightCache>,
} }
impl EthashManager { impl EthashManager {
/// Create a new new instance of ethash manager /// Create a new new instance of ethash manager
pub fn new() -> EthashManager { pub fn new() -> EthashManager {
EthashManager { EthashManager {
lights: Mutex::new(LruCache::new(2)) cache: Mutex::new(LightCache {
recent_epoch: None,
recent: None,
prev_epoch: None,
prev: None,
}),
} }
} }
@ -50,8 +61,24 @@ impl EthashManager {
pub fn compute_light(&self, block_number: u64, header_hash: &H256, nonce: u64) -> ProofOfWork { pub fn compute_light(&self, block_number: u64, header_hash: &H256, nonce: u64) -> ProofOfWork {
let epoch = block_number / ETHASH_EPOCH_LENGTH; let epoch = block_number / ETHASH_EPOCH_LENGTH;
let light = { let light = {
let mut lights = self.lights.lock().unwrap(); let mut lights = self.cache.lock().unwrap();
match lights.get_mut(&epoch).map(|l| l.clone()) { let light = match lights.recent_epoch.clone() {
Some(ref e) if *e == epoch => lights.recent.clone(),
_ => match lights.prev_epoch.clone() {
Some(e) if e == epoch => {
// swap
let t = lights.prev_epoch;
lights.prev_epoch = lights.recent_epoch;
lights.recent_epoch = t;
let t = lights.prev.clone();
lights.prev = lights.recent.clone();
lights.recent = t;
lights.recent.clone()
}
_ => None,
}
};
match light {
None => { None => {
let light = match Light::from_file(block_number) { let light = match Light::from_file(block_number) {
Ok(light) => Arc::new(light), Ok(light) => Arc::new(light),
@ -64,7 +91,8 @@ impl EthashManager {
Arc::new(light) Arc::new(light)
} }
}; };
lights.insert(epoch, light.clone()); lights.prev_epoch = mem::replace(&mut lights.recent_epoch, Some(epoch));
lights.prev = mem::replace(&mut lights.recent, Some(light.clone()));
light light
} }
Some(light) => light Some(light) => light
@ -73,3 +101,19 @@ impl EthashManager {
light.compute(header_hash, nonce) light.compute(header_hash, nonce)
} }
} }
#[test]
fn test_lru() {
let ethash = EthashManager::new();
let hash = [0u8; 32];
ethash.compute_light(1, &hash, 1);
ethash.compute_light(50000, &hash, 1);
assert_eq!(ethash.cache.lock().unwrap().recent_epoch.unwrap(), 1);
assert_eq!(ethash.cache.lock().unwrap().prev_epoch.unwrap(), 0);
ethash.compute_light(1, &hash, 1);
assert_eq!(ethash.cache.lock().unwrap().recent_epoch.unwrap(), 0);
assert_eq!(ethash.cache.lock().unwrap().prev_epoch.unwrap(), 1);
ethash.compute_light(70000, &hash, 1);
assert_eq!(ethash.cache.lock().unwrap().recent_epoch.unwrap(), 2);
assert_eq!(ethash.cache.lock().unwrap().prev_epoch.unwrap(), 0);
}

View File

@ -11,14 +11,14 @@ log = "0.3"
env_logger = "0.3" env_logger = "0.3"
rustc-serialize = "0.3" rustc-serialize = "0.3"
rocksdb = "0.3" rocksdb = "0.3"
heapsize = "0.2.0" heapsize = "0.3"
rust-crypto = "0.2.34" rust-crypto = "0.2.34"
time = "0.1" time = "0.1"
ethcore-util = { path = "../util" } ethcore-util = { path = "../util" }
evmjit = { path = "../evmjit", optional = true } evmjit = { path = "../evmjit", optional = true }
ethash = { path = "../ethash" } ethash = { path = "../ethash" }
num_cpus = "0.2" num_cpus = "0.2"
clippy = "0.0.41" clippy = { version = "0.0.42", optional = true }
crossbeam = "0.1.5" crossbeam = "0.1.5"
lazy_static = "0.1" lazy_static = "0.1"
@ -27,3 +27,5 @@ jit = ["evmjit"]
evm-debug = [] evm-debug = []
json-tests = [] json-tests = []
test-heavy = [] test-heavy = []
dev = ["clippy"]
default = []

View File

@ -267,7 +267,7 @@ impl<'x, 'y> OpenBlock<'x, 'y> {
s.block.base.header.uncles_hash = uncle_bytes.sha3(); s.block.base.header.uncles_hash = uncle_bytes.sha3();
s.block.base.header.state_root = s.block.state.root().clone(); s.block.base.header.state_root = s.block.state.root().clone();
s.block.base.header.receipts_root = ordered_trie_root(s.block.receipts.iter().map(|ref r| r.rlp_bytes().to_vec()).collect()); s.block.base.header.receipts_root = ordered_trie_root(s.block.receipts.iter().map(|ref r| r.rlp_bytes().to_vec()).collect());
s.block.base.header.log_bloom = s.block.receipts.iter().fold(LogBloom::zero(), |mut b, r| {b |= &r.log_bloom; b}); s.block.base.header.log_bloom = s.block.receipts.iter().fold(LogBloom::zero(), |mut b, r| {b = &b | &r.log_bloom; b}); //TODO: use |= operator
s.block.base.header.gas_used = s.block.receipts.last().map_or(U256::zero(), |r| r.gas_used); s.block.base.header.gas_used = s.block.receipts.last().map_or(U256::zero(), |r| r.gas_used);
s.block.base.header.note_dirty(); s.block.base.header.note_dirty();

View File

@ -162,7 +162,7 @@ impl ClientReport {
pub fn accrue_block(&mut self, block: &PreVerifiedBlock) { pub fn accrue_block(&mut self, block: &PreVerifiedBlock) {
self.blocks_imported += 1; self.blocks_imported += 1;
self.transactions_applied += block.transactions.len(); self.transactions_applied += block.transactions.len();
self.gas_processed += block.header.gas_used; self.gas_processed = self.gas_processed + block.header.gas_used;
} }
} }

View File

@ -299,7 +299,7 @@ impl evm::Evm for Interpreter {
let (gas_cost, mem_size) = try!(self.get_gas_cost_mem(ext, instruction, &mut mem, &stack)); let (gas_cost, mem_size) = try!(self.get_gas_cost_mem(ext, instruction, &mut mem, &stack));
try!(self.verify_gas(&current_gas, &gas_cost)); try!(self.verify_gas(&current_gas, &gas_cost));
mem.expand(mem_size); mem.expand(mem_size);
current_gas -= gas_cost; current_gas = current_gas - gas_cost; //TODO: use operator -=
evm_debug!({ evm_debug!({
println!("[0x{:x}][{}(0x{:x}) Gas: {:x}\n Gas Before: {:x}", println!("[0x{:x}][{}(0x{:x}) Gas: {:x}\n Gas Before: {:x}",
@ -320,7 +320,7 @@ impl evm::Evm for Interpreter {
match result { match result {
InstructionResult::Ok => {}, InstructionResult::Ok => {},
InstructionResult::UnusedGas(gas) => { InstructionResult::UnusedGas(gas) => {
current_gas += gas; current_gas = current_gas + gas; //TODO: use operator +=
}, },
InstructionResult::UseAllGas => { InstructionResult::UseAllGas => {
current_gas = U256::zero(); current_gas = U256::zero();

View File

@ -15,11 +15,8 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
#![warn(missing_docs)] #![warn(missing_docs)]
#![feature(cell_extras)] #![cfg_attr(feature="dev", feature(plugin))]
#![feature(augmented_assignments)] #![cfg_attr(feature="dev", plugin(clippy))]
#![feature(plugin)]
// Clippy
#![plugin(clippy)]
// TODO [todr] not really sure // TODO [todr] not really sure
#![allow(needless_range_loop)] #![allow(needless_range_loop)]
// Shorter than if-else // Shorter than if-else
@ -27,7 +24,6 @@
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref. // Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
#![allow(clone_on_copy)] #![allow(clone_on_copy)]
//! Ethcore library //! Ethcore library
//! //!
//! ### Rust version: //! ### Rust version:

View File

@ -39,7 +39,7 @@ impl Receipt {
Receipt { Receipt {
state_root: state_root, state_root: state_root,
gas_used: gas_used, gas_used: gas_used,
log_bloom: logs.iter().fold(LogBloom::new(), |mut b, l| { b |= &l.bloom(); b }), log_bloom: logs.iter().fold(LogBloom::new(), |mut b, l| { b = &b | &l.bloom(); b }), //TODO: use |= operator
logs: logs, logs: logs,
} }
} }

View File

@ -124,6 +124,8 @@ impl IoHandler<NetSyncMessage> for ClientIoHandler {
} }
} }
// TODO: rewrite into something that doesn't dependent on the testing environment having a particular port ready for use.
/*
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
@ -138,3 +140,4 @@ mod tests {
assert!(service.is_ok()); assert!(service.is_ok());
} }
} }
*/

View File

@ -282,7 +282,7 @@ impl State {
/// Pull account `a` in our cache from the trie DB and return it. /// Pull account `a` in our cache from the trie DB and return it.
/// `require_code` requires that the code be cached, too. /// `require_code` requires that the code be cached, too.
fn get(&self, a: &Address, require_code: bool) -> Ref<Option<Account>> { fn get<'a>(&'a self, a: &Address, require_code: bool) -> &'a Option<Account> {
let have_key = self.cache.borrow().contains_key(a); let have_key = self.cache.borrow().contains_key(a);
if !have_key { if !have_key {
self.insert_cache(a, SecTrieDB::new(&self.db, &self.root).get(&a).map(Account::from_rlp)) self.insert_cache(a, SecTrieDB::new(&self.db, &self.root).get(&a).map(Account::from_rlp))
@ -292,17 +292,17 @@ impl State {
account.cache_code(&AccountDB::new(&self.db, a)); account.cache_code(&AccountDB::new(&self.db, a));
} }
} }
Ref::map(self.cache.borrow(), |m| m.get(a).unwrap()) unsafe { ::std::mem::transmute(self.cache.borrow().get(a).unwrap()) }
} }
/// Pull account `a` in our cache from the trie DB. `require_code` requires that the code be cached, too. /// Pull account `a` in our cache from the trie DB. `require_code` requires that the code be cached, too.
fn require(&self, a: &Address, require_code: bool) -> RefMut<Account> { fn require<'a>(&'a self, a: &Address, require_code: bool) -> &'a mut Account {
self.require_or_from(a, require_code, || Account::new_basic(U256::from(0u8), self.account_start_nonce), |_|{}) self.require_or_from(a, require_code, || Account::new_basic(U256::from(0u8), self.account_start_nonce), |_|{})
} }
/// Pull account `a` in our cache from the trie DB. `require_code` requires that the code be cached, too. /// Pull account `a` in our cache from the trie DB. `require_code` requires that the code be cached, too.
/// If it doesn't exist, make account equal the evaluation of `default`. /// If it doesn't exist, make account equal the evaluation of `default`.
fn require_or_from<F: FnOnce() -> Account, G: FnOnce(&mut Account)>(&self, a: &Address, require_code: bool, default: F, not_default: G) -> RefMut<Account> { fn require_or_from<'a, F: FnOnce() -> Account, G: FnOnce(&mut Account)>(&self, a: &Address, require_code: bool, default: F, not_default: G) -> &'a mut Account {
let have_key = self.cache.borrow().contains_key(a); let have_key = self.cache.borrow().contains_key(a);
if !have_key { if !have_key {
self.insert_cache(a, SecTrieDB::new(&self.db, &self.root).get(&a).map(Account::from_rlp)) self.insert_cache(a, SecTrieDB::new(&self.db, &self.root).get(&a).map(Account::from_rlp))
@ -316,13 +316,12 @@ impl State {
not_default(self.cache.borrow_mut().get_mut(a).unwrap().as_mut().unwrap()); not_default(self.cache.borrow_mut().get_mut(a).unwrap().as_mut().unwrap());
} }
let b = self.cache.borrow_mut(); unsafe { ::std::mem::transmute(self.cache.borrow_mut().get_mut(a).unwrap().as_mut().map(|account| {
RefMut::map(b, |m| m.get_mut(a).unwrap().as_mut().map(|account| {
if require_code { if require_code {
account.cache_code(&AccountDB::new(&self.db, a)); account.cache_code(&AccountDB::new(&self.db, a));
} }
account account
}).unwrap()) }).unwrap()) }
} }
} }

View File

@ -346,8 +346,7 @@ function run_installer()
exe brew install rocksdb exe brew install rocksdb
info "Installing multirust" info "Installing multirust"
exe brew install multirust exe brew install multirust
sudo multirust update nightly sudo multirust default beta
sudo multirust default nightly
echo echo
} }
@ -426,20 +425,20 @@ function run_installer()
depFound=$((depFound+1)) depFound=$((depFound+1))
check "multirust" check "multirust"
isMultirust=true isMultirust=true
if [[ $(multirust show-default 2>/dev/null | grep nightly | wc -l) == 4 ]]; then if [[ $(multirust show-default 2>/dev/null | grep beta | wc -l) == 4 ]]; then
depFound=$((depFound+1)) depFound=$((depFound+1))
check "rust nightly" check "rust beta"
isMultirustNightly=true isMultirustBeta=true
else else
uncheck "rust is not nightly" uncheck "rust is not beta"
isMultirustNightly=false isMultirustBeta=false
INSTALL_FILES+="${blue}${dim}==> multirust -> rust nightly:${reset}${n}" INSTALL_FILES+="${blue}${dim}==> multirust -> rust beta:${reset}${n}"
fi fi
else else
uncheck "multirust is missing" uncheck "multirust is missing"
uncheck "rust nightly is missing" uncheck "rust beta is missing"
isMultirust=false isMultirust=false
isMultirustNightly=false isMultirustBeta=false
INSTALL_FILES+="${blue}${dim}==> multirust:${reset}${n}" INSTALL_FILES+="${blue}${dim}==> multirust:${reset}${n}"
fi fi
} }
@ -626,10 +625,9 @@ function run_installer()
echo echo
fi fi
if [[ $isMultirustNightly == false ]]; then if [[ $isMultirustBeta == false ]]; then
info "Installing rust nightly..." info "Installing rust beta..."
multirust update nightly multirust default beta
multirust default nightly
echo echo
fi fi
} }
@ -660,7 +658,7 @@ function run_installer()
find_rocksdb find_rocksdb
find_multirust find_multirust
if [[ $isCurl == false || $isGit == false || $isMake == false || $isGCC == false || $isRocksDB == false || $isMultirustNightly == false ]]; then if [[ $isCurl == false || $isGit == false || $isMake == false || $isGCC == false || $isRocksDB == false || $isMultirustBeta == false ]]; then
abort_install abort_install
fi fi
fi fi

View File

@ -17,8 +17,8 @@
//! Ethcore client application. //! Ethcore client application.
#![warn(missing_docs)] #![warn(missing_docs)]
#![feature(plugin)] #![cfg_attr(feature="dev", feature(plugin))]
#![plugin(clippy)] #![cfg_attr(feature="dev", plugin(clippy))]
extern crate docopt; extern crate docopt;
extern crate rustc_serialize; extern crate rustc_serialize;
extern crate ethcore_util as util; extern crate ethcore_util as util;

View File

@ -4,18 +4,28 @@ name = "ethcore-rpc"
version = "0.9.99" version = "0.9.99"
license = "GPL-3.0" license = "GPL-3.0"
authors = ["Ethcore <admin@ethcore.io"] authors = ["Ethcore <admin@ethcore.io"]
build = "build.rs"
[lib] [lib]
[dependencies] [dependencies]
serde = "0.6.7" serde = "0.6.7"
serde_macros = "0.6.13"
serde_json = "0.6.0" serde_json = "0.6.0"
jsonrpc-core = "1.1.2" jsonrpc-core = "1.1"
jsonrpc-http-server = "1.1.2" jsonrpc-http-server = "1.1"
ethcore-util = { path = "../util" } ethcore-util = { path = "../util" }
ethcore = { path = "../ethcore" } ethcore = { path = "../ethcore" }
ethsync = { path = "../sync" } ethsync = { path = "../sync" }
clippy = "0.0.41" clippy = { version = "0.0.42", optional = true }
target_info = "0.1.0" target_info = "0.1.0"
rustc-serialize = "0.3" rustc-serialize = "0.3"
serde_macros = { version = "0.6.13", optional = true }
[build-dependencies]
serde_codegen = { version = "0.6.13", optional = true }
syntex = "0.29.0"
[features]
default = ["serde_codegen"]
nightly = ["serde_macros"]
dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev"]

29
rpc/build.rs Normal file
View File

@ -0,0 +1,29 @@
#[cfg(not(feature = "serde_macros"))]
mod inner {
extern crate syntex;
extern crate serde_codegen;
use std::env;
use std::path::Path;
pub fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
let src = Path::new("src/lib.rs.in");
let dst = Path::new(&out_dir).join("lib.rs");
let mut registry = syntex::Registry::new();
serde_codegen::register(&mut registry);
registry.expand("", &src, &dst).unwrap();
}
}
#[cfg(feature = "serde_macros")]
mod inner {
pub fn main() {}
}
fn main() {
inner::main();
}

View File

@ -16,9 +16,8 @@
//! Ethcore rpc. //! Ethcore rpc.
#![warn(missing_docs)] #![warn(missing_docs)]
#![feature(custom_derive, custom_attribute, plugin)] #![cfg_attr(nightly, feature(custom_derive, custom_attribute, plugin))]
#![plugin(serde_macros)] #![cfg_attr(nightly, plugin(serde_macros, clippy))]
#![plugin(clippy)]
extern crate rustc_serialize; extern crate rustc_serialize;
extern crate target_info; extern crate target_info;
@ -30,38 +29,8 @@ extern crate ethcore_util as util;
extern crate ethcore; extern crate ethcore;
extern crate ethsync; extern crate ethsync;
use self::jsonrpc_core::{IoHandler, IoDelegate}; #[cfg(feature = "serde_macros")]
include!("lib.rs.in");
pub mod v1; #[cfg(not(feature = "serde_macros"))]
include!(concat!(env!("OUT_DIR"), "/lib.rs"));
/// Http server.
pub struct HttpServer {
handler: IoHandler,
threads: usize
}
impl HttpServer {
/// Construct new http server object with given number of threads.
pub fn new(threads: usize) -> HttpServer {
HttpServer {
handler: IoHandler::new(),
threads: threads
}
}
/// Add io delegate.
pub fn add_delegate<D>(&mut self, delegate: IoDelegate<D>) where D: Send + Sync + 'static {
self.handler.add_delegate(delegate);
}
/// Start server asynchronously in new thread
pub fn start_async(self, addr: &str) {
let server = jsonrpc_http_server::Server::new(self.handler, self.threads);
server.start_async(addr)
}
}
/// Lib needs at least 1 test to generate coverage reports correctly.
#[test]
fn if_works() {
}

30
rpc/src/lib.rs.in Normal file
View File

@ -0,0 +1,30 @@
use self::jsonrpc_core::{IoHandler, IoDelegate};
pub mod v1;
/// Http server.
pub struct HttpServer {
handler: IoHandler,
threads: usize
}
impl HttpServer {
/// Construct new http server object with given number of threads.
pub fn new(threads: usize) -> HttpServer {
HttpServer {
handler: IoHandler::new(),
threads: threads
}
}
/// Add io delegate.
pub fn add_delegate<D>(&mut self, delegate: IoDelegate<D>) where D: Send + Sync + 'static {
self.handler.add_delegate(delegate);
}
/// Start server asynchronously in new thread
pub fn start_async(self, addr: &str) {
let server = jsonrpc_http_server::Server::new(self.handler, self.threads);
server.start_async(addr)
}
}

View File

@ -10,8 +10,12 @@ authors = ["Ethcore <admin@ethcore.io"]
[dependencies] [dependencies]
ethcore-util = { path = "../util" } ethcore-util = { path = "../util" }
ethcore = { path = ".." } ethcore = { path = ".." }
clippy = "0.0.41" clippy = { version = "0.0.42", optional = true }
log = "0.3" log = "0.3"
env_logger = "0.3" env_logger = "0.3"
time = "0.1.34" time = "0.1.34"
rand = "0.3.13" rand = "0.3.13"
[features]
default = []
dev = ["clippy", "ethcore/dev", "ethcore-util/dev"]

View File

@ -15,9 +15,8 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
#![warn(missing_docs)] #![warn(missing_docs)]
#![feature(plugin)] #![cfg_attr(feature="dev", feature(plugin))]
#![feature(augmented_assignments)] #![cfg_attr(feature="dev", plugin(clippy))]
#![plugin(clippy)]
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref. // Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
#![allow(clone_on_copy)] #![allow(clone_on_copy)]
@ -59,7 +58,7 @@ use std::ops::*;
use std::sync::*; use std::sync::*;
use ethcore::client::Client; use ethcore::client::Client;
use util::network::{NetworkProtocolHandler, NetworkService, NetworkContext, PeerId}; use util::network::{NetworkProtocolHandler, NetworkService, NetworkContext, PeerId};
use util::io::TimerToken; use util::TimerToken;
use chain::ChainSync; use chain::ChainSync;
use ethcore::service::SyncMessage; use ethcore::service::SyncMessage;
use io::NetSyncIo; use io::NetSyncIo;

View File

@ -213,7 +213,10 @@ impl BlockChainClient for TestBlockChainClient {
} }
let len = self.numbers.read().unwrap().len(); let len = self.numbers.read().unwrap().len();
if number == len { if number == len {
*self.difficulty.write().unwrap().deref_mut() += header.difficulty; {
let mut difficulty = self.difficulty.write().unwrap();
*difficulty.deref_mut() = *difficulty.deref() + header.difficulty;
}
mem::replace(self.last_hash.write().unwrap().deref_mut(), h.clone()); mem::replace(self.last_hash.write().unwrap().deref_mut(), h.clone());
self.blocks.write().unwrap().insert(h.clone(), b); self.blocks.write().unwrap().insert(h.clone(), b);
self.numbers.write().unwrap().insert(number, h.clone()); self.numbers.write().unwrap().insert(number, h.clone());

View File

@ -20,14 +20,18 @@ lazy_static = "0.1"
eth-secp256k1 = { git = "https://github.com/arkpar/rust-secp256k1.git" } eth-secp256k1 = { git = "https://github.com/arkpar/rust-secp256k1.git" }
rust-crypto = "0.2.34" rust-crypto = "0.2.34"
elastic-array = "0.4" elastic-array = "0.4"
heapsize = "0.2" heapsize = "0.3"
itertools = "0.4" itertools = "0.4"
crossbeam = "0.2" crossbeam = "0.2"
slab = { git = "https://github.com/arkpar/slab.git" } slab = { git = "https://github.com/arkpar/slab.git" }
sha3 = { path = "sha3" } sha3 = { path = "sha3" }
serde = "0.6.7" serde = "0.6.7"
clippy = "0.0.41" clippy = { version = "0.0.42", optional = true }
json-tests = { path = "json-tests" } json-tests = { path = "json-tests" }
target_info = "0.1.0" target_info = "0.1.0"
igd = "0.4.2" igd = "0.4.2"
libc = "0.2.7" libc = "0.2.7"
[features]
default = []
dev = ["clippy"]

View File

@ -414,15 +414,6 @@ macro_rules! impl_hash {
} }
} }
/// Moving BitOrAssign
impl<'a> BitOrAssign<&'a $from> for $from {
fn bitor_assign(&mut self, rhs: &'a Self) {
for i in 0..$size {
self.0[i] = self.0[i] | rhs.0[i];
}
}
}
/// BitAnd on references /// BitAnd on references
impl <'a> BitAnd for &'a $from { impl <'a> BitAnd for &'a $from {
type Output = $from; type Output = $from;

View File

@ -15,14 +15,9 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
#![warn(missing_docs)] #![warn(missing_docs)]
#![feature(op_assign_traits)] #![cfg_attr(feature="dev", feature(plugin))]
#![feature(augmented_assignments)] #![cfg_attr(feature="dev", plugin(clippy))]
#![feature(associated_consts)]
#![feature(plugin)]
#![feature(ip)]
#![feature(catch_panic)]
// Clippy settings // Clippy settings
#![plugin(clippy)]
// TODO [todr] not really sure // TODO [todr] not really sure
#![allow(needless_range_loop)] #![allow(needless_range_loop)]
// Shorter than if-else // Shorter than if-else

View File

@ -27,6 +27,40 @@ pub enum IpAddr{
V6(Ipv6Addr), V6(Ipv6Addr),
} }
/// Socket address extension for rustc beta. To be replaces with now unstable API
pub trait SocketAddrExt {
/// Returns true for the special 'unspecified' address 0.0.0.0.
fn is_unspecified_s(&self) -> bool;
/// Returns true if the address appears to be globally routable.
fn is_global_s(&self) -> bool;
}
impl SocketAddrExt for Ipv4Addr {
fn is_unspecified_s(&self) -> bool {
self.octets() == [0, 0, 0, 0]
}
fn is_global_s(&self) -> bool {
!self.is_private() && !self.is_loopback() && !self.is_link_local() &&
!self.is_broadcast() && !self.is_documentation()
}
}
impl SocketAddrExt for Ipv6Addr {
fn is_unspecified_s(&self) -> bool {
self.segments() == [0, 0, 0, 0, 0, 0, 0, 0]
}
fn is_global_s(&self) -> bool {
if self.is_multicast() {
self.segments()[0] & 0x000f == 14
} else {
!self.is_loopback() && !((self.segments()[0] & 0xffc0) == 0xfe80) &&
!((self.segments()[0] & 0xffc0) == 0xfec0) && !((self.segments()[0] & 0xfe00) == 0xfc00)
}
}
}
#[cfg(not(windows))] #[cfg(not(windows))]
mod getinterfaces { mod getinterfaces {
use std::{mem, io, ptr}; use std::{mem, io, ptr};
@ -115,7 +149,7 @@ pub fn select_public_address(port: u16) -> SocketAddr {
//prefer IPV4 bindings //prefer IPV4 bindings
for addr in &list { //TODO: use better criteria than just the first in the list for addr in &list { //TODO: use better criteria than just the first in the list
match *addr { match *addr {
IpAddr::V4(a) if !a.is_unspecified() && !a.is_loopback() && !a.is_link_local() => { IpAddr::V4(a) if !a.is_unspecified_s() && !a.is_loopback() && !a.is_link_local() => {
return SocketAddr::V4(SocketAddrV4::new(a, port)); return SocketAddr::V4(SocketAddrV4::new(a, port));
}, },
_ => {}, _ => {},
@ -123,7 +157,7 @@ pub fn select_public_address(port: u16) -> SocketAddr {
} }
for addr in list { for addr in list {
match addr { match addr {
IpAddr::V6(a) if !a.is_unspecified() && !a.is_loopback() => { IpAddr::V6(a) if !a.is_unspecified_s() && !a.is_loopback() => {
return SocketAddr::V6(SocketAddrV6::new(a, port, 0, 0)); return SocketAddr::V6(SocketAddrV6::new(a, port, 0, 0));
}, },
_ => {}, _ => {},
@ -180,3 +214,55 @@ fn can_map_external_address_or_fail() {
let _ = map_external_address(&NodeEndpoint { address: pub_address, udp_port: 40478 }); let _ = map_external_address(&NodeEndpoint { address: pub_address, udp_port: 40478 });
} }
#[test]
fn ipv4_properties() {
fn check(octets: &[u8; 4], unspec: bool, loopback: bool,
private: bool, link_local: bool, global: bool,
multicast: bool, broadcast: bool, documentation: bool) {
let ip = Ipv4Addr::new(octets[0], octets[1], octets[2], octets[3]);
assert_eq!(octets, &ip.octets());
assert_eq!(ip.is_unspecified_s(), unspec);
assert_eq!(ip.is_loopback(), loopback);
assert_eq!(ip.is_private(), private);
assert_eq!(ip.is_link_local(), link_local);
assert_eq!(ip.is_global_s(), global);
assert_eq!(ip.is_multicast(), multicast);
assert_eq!(ip.is_broadcast(), broadcast);
assert_eq!(ip.is_documentation(), documentation);
}
// address unspec loopbk privt linloc global multicast brdcast doc
check(&[0, 0, 0, 0], true, false, false, false, true, false, false, false);
check(&[0, 0, 0, 1], false, false, false, false, true, false, false, false);
check(&[1, 0, 0, 0], false, false, false, false, true, false, false, false);
check(&[10, 9, 8, 7], false, false, true, false, false, false, false, false);
check(&[127, 1, 2, 3], false, true, false, false, false, false, false, false);
check(&[172, 31, 254, 253], false, false, true, false, false, false, false, false);
check(&[169, 254, 253, 242], false, false, false, true, false, false, false, false);
check(&[192, 0, 2, 183], false, false, false, false, false, false, false, true);
check(&[192, 1, 2, 183], false, false, false, false, true, false, false, false);
check(&[192, 168, 254, 253], false, false, true, false, false, false, false, false);
check(&[198, 51, 100, 0], false, false, false, false, false, false, false, true);
check(&[203, 0, 113, 0], false, false, false, false, false, false, false, true);
check(&[203, 2, 113, 0], false, false, false, false, true, false, false, false);
check(&[224, 0, 0, 0], false, false, false, false, true, true, false, false);
check(&[239, 255, 255, 255], false, false, false, false, true, true, false, false);
check(&[255, 255, 255, 255], false, false, false, false, false, false, true, false);
}
#[test]
fn ipv6_properties() {
fn check(str_addr: &str, unspec: bool, loopback: bool, global: bool) {
let ip: Ipv6Addr = str_addr.parse().unwrap();
assert_eq!(str_addr, ip.to_string());
assert_eq!(ip.is_unspecified_s(), unspec);
assert_eq!(ip.is_loopback(), loopback);
assert_eq!(ip.is_global_s(), global);
}
// unspec loopbk global
check("::", true, false, true);
check("::1", false, true, false);
}

View File

@ -30,6 +30,7 @@ use rlp::*;
use time::Tm; use time::Tm;
use error::*; use error::*;
use network::discovery::{TableUpdates, NodeEntry}; use network::discovery::{TableUpdates, NodeEntry};
use network::ip_utils::*;
pub use rustc_serialize::json::Json; pub use rustc_serialize::json::Json;
/// Node public key /// Node public key
@ -92,15 +93,15 @@ impl NodeEndpoint {
pub fn is_valid(&self) -> bool { pub fn is_valid(&self) -> bool {
self.udp_port != 0 && self.address.port() != 0 && self.udp_port != 0 && self.address.port() != 0 &&
match self.address { match self.address {
SocketAddr::V4(a) => !a.ip().is_unspecified(), SocketAddr::V4(a) => !a.ip().is_unspecified_s(),
SocketAddr::V6(a) => !a.ip().is_unspecified() SocketAddr::V6(a) => !a.ip().is_unspecified_s()
} }
} }
pub fn is_global(&self) -> bool { pub fn is_global(&self) -> bool {
match self.address { match self.address {
SocketAddr::V4(a) => a.ip().is_global(), SocketAddr::V4(a) => a.ip().is_global_s(),
SocketAddr::V6(a) => a.ip().is_global() SocketAddr::V6(a) => a.ip().is_global_s()
} }
} }
} }

View File

@ -40,6 +40,18 @@ pub trait MayPanic {
fn on_panic<F>(&self, closure: F) where F: OnPanicListener; fn on_panic<F>(&self, closure: F) where F: OnPanicListener;
} }
struct PanicGuard<'a> {
handler: &'a PanicHandler,
}
impl<'a> Drop for PanicGuard<'a> {
fn drop(&mut self) {
if thread::panicking() {
self.handler.notify_all("Panic!".to_owned());
}
}
}
/// Structure that allows to catch panics and notify listeners /// Structure that allows to catch panics and notify listeners
pub struct PanicHandler { pub struct PanicHandler {
listeners: Mutex<Vec<Box<OnPanicListener>>> listeners: Mutex<Vec<Box<OnPanicListener>>>
@ -63,16 +75,9 @@ impl PanicHandler {
#[allow(deprecated)] #[allow(deprecated)]
// TODO [todr] catch_panic is deprecated but panic::recover has different bounds (not allowing mutex) // TODO [todr] catch_panic is deprecated but panic::recover has different bounds (not allowing mutex)
pub fn catch_panic<G, R>(&self, g: G) -> thread::Result<R> where G: FnOnce() -> R + Send + 'static { pub fn catch_panic<G, R>(&self, g: G) -> thread::Result<R> where G: FnOnce() -> R + Send + 'static {
let result = thread::catch_panic(g); let guard = PanicGuard { handler: self };
let result = g();
if let Err(ref e) = result { Ok(result)
let res = convert_to_string(e);
if let Some(r) = res {
self.notify_all(r);
}
}
result
} }
fn notify_all(&self, r: String) { fn notify_all(&self, r: String) {
@ -111,6 +116,7 @@ fn convert_to_string(t: &Box<Any + Send>) -> Option<String> {
} }
#[test] #[test]
#[ignore] // panic forwarding doesnt work on the same thread in beta
fn should_notify_listeners_about_panic () { fn should_notify_listeners_about_panic () {
use std::sync::RwLock; use std::sync::RwLock;
// given // given
@ -127,6 +133,7 @@ fn should_notify_listeners_about_panic () {
} }
#[test] #[test]
#[ignore] // panic forwarding doesnt work on the same thread in beta
fn should_notify_listeners_about_panic_when_string_is_dynamic () { fn should_notify_listeners_about_panic_when_string_is_dynamic () {
use std::sync::RwLock; use std::sync::RwLock;
// given // given
@ -164,6 +171,7 @@ fn should_notify_listeners_about_panic_in_other_thread () {
} }
#[test] #[test]
#[ignore] // panic forwarding doesnt work on the same thread in beta
fn should_forward_panics () { fn should_forward_panics () {
use std::sync::RwLock; use std::sync::RwLock;
// given // given

View File

@ -232,12 +232,12 @@ impl_uint_from_bytes!(u64);
impl_uint_from_bytes!(usize); impl_uint_from_bytes!(usize);
macro_rules! impl_uint_from_bytes { macro_rules! impl_uint_from_bytes {
($name: ident) => { ($name: ident, $size: expr) => {
impl FromBytes for $name { impl FromBytes for $name {
fn from_bytes(bytes: &[u8]) -> FromBytesResult<$name> { fn from_bytes(bytes: &[u8]) -> FromBytesResult<$name> {
if !bytes.is_empty() && bytes[0] == 0 { if !bytes.is_empty() && bytes[0] == 0 {
Err(FromBytesError::ZeroPrefixedInt) Err(FromBytesError::ZeroPrefixedInt)
} else if bytes.len() <= $name::SIZE { } else if bytes.len() <= $size {
Ok($name::from(bytes)) Ok($name::from(bytes))
} else { } else {
Err(FromBytesError::DataIsTooLong) Err(FromBytesError::DataIsTooLong)
@ -247,8 +247,8 @@ macro_rules! impl_uint_from_bytes {
} }
} }
impl_uint_from_bytes!(U256); impl_uint_from_bytes!(U256, 32);
impl_uint_from_bytes!(U128); impl_uint_from_bytes!(U128, 16);
impl <T>FromBytes for T where T: FixedHash { impl <T>FromBytes for T where T: FixedHash {
fn from_bytes(bytes: &[u8]) -> FromBytesResult<T> { fn from_bytes(bytes: &[u8]) -> FromBytesResult<T> {

View File

@ -429,7 +429,6 @@ impl<T> Decodable for Option<T> where T: Decodable {
macro_rules! impl_array_decodable { macro_rules! impl_array_decodable {
($index_type:ty, $len:expr ) => ( ($index_type:ty, $len:expr ) => (
impl<T> Decodable for [T; $len] where T: Decodable { impl<T> Decodable for [T; $len] where T: Decodable {
#[allow(len_zero)]
fn decode<D>(decoder: &D) -> Result<Self, DecoderError> where D: Decoder { fn decode<D>(decoder: &D) -> Result<Self, DecoderError> where D: Decoder {
let decoders = decoder.as_rlp(); let decoders = decoder.as_rlp();

View File

@ -78,9 +78,6 @@ macro_rules! panic_on_overflow {
/// Large, fixed-length unsigned integer type. /// Large, fixed-length unsigned integer type.
pub trait Uint: Sized + Default + FromStr + From<u64> + FromJson + fmt::Debug + fmt::Display + PartialOrd + Ord + PartialEq + Eq + Hash { pub trait Uint: Sized + Default + FromStr + From<u64> + FromJson + fmt::Debug + fmt::Display + PartialOrd + Ord + PartialEq + Eq + Hash {
/// Size of this type.
const SIZE: usize;
/// Returns new instance equalling zero. /// Returns new instance equalling zero.
fn zero() -> Self; fn zero() -> Self;
/// Returns new instance equalling one. /// Returns new instance equalling one.
@ -148,8 +145,6 @@ macro_rules! construct_uint {
pub struct $name(pub [u64; $n_words]); pub struct $name(pub [u64; $n_words]);
impl Uint for $name { impl Uint for $name {
const SIZE: usize = $n_words * 8;
type FromDecStrErr = FromHexError; type FromDecStrErr = FromHexError;
/// TODO: optimize, throw appropriate err /// TODO: optimize, throw appropriate err
@ -634,66 +629,6 @@ macro_rules! construct_uint {
// TODO: optimise and traitify. // TODO: optimise and traitify.
impl<'a> AddAssign<&'a $name> for $name {
fn add_assign(&mut self, other: &'a Self) {
*self = self.add(*other);
}
}
impl<'a> SubAssign<&'a $name> for $name {
fn sub_assign(&mut self, other: &'a Self) {
*self = self.sub(*other);
}
}
impl<'a> MulAssign<&'a $name> for $name {
fn mul_assign(&mut self, other: &'a Self) {
*self = self.mul(*other);
}
}
impl<'a> DivAssign<&'a $name> for $name {
fn div_assign(&mut self, other: &'a Self) {
*self = self.div(*other);
}
}
impl<'a> RemAssign<&'a $name> for $name {
fn rem_assign(&mut self, other: &'a Self) {
*self = self.rem(*other);
}
}
impl AddAssign<$name> for $name {
fn add_assign(&mut self, other: Self) {
*self = self.add(other);
}
}
impl SubAssign<$name> for $name {
fn sub_assign(&mut self, other: Self) {
*self = self.sub(other);
}
}
impl MulAssign<$name> for $name {
fn mul_assign(&mut self, other: Self) {
*self = self.mul(other);
}
}
impl DivAssign<$name> for $name {
fn div_assign(&mut self, other: Self) {
*self = self.div(other);
}
}
impl RemAssign<$name> for $name {
fn rem_assign(&mut self, other: Self) {
*self = self.rem(other);
}
}
impl BitAnd<$name> for $name { impl BitAnd<$name> for $name {
type Output = $name; type Output = $name;
@ -964,37 +899,6 @@ mod tests {
use uint::{Uint, U128, U256, U512}; use uint::{Uint, U128, U256, U512};
use std::str::FromStr; use std::str::FromStr;
#[test]
pub fn assign_ops() {
let x: U256 = x!(69);
let y: U256 = x!(42);
{
let mut z = x;
z += y;
assert_eq!(z, x + y);
}
{
let mut z = x;
z -= y;
assert_eq!(z, x - y);
}
{
let mut z = x;
z *= y;
assert_eq!(z, x * y);
}
{
let mut z = x;
z /= y;
assert_eq!(z, x / y);
}
{
let mut z = x;
z %= y;
assert_eq!(z, x % y);
}
}
#[test] #[test]
pub fn uint256_from() { pub fn uint256_from() {
let e = U256([10, 0, 0, 0]); let e = U256([10, 0, 0, 0]);