Merge branch 'master' into auth-bft

This commit is contained in:
keorn 2016-12-12 21:28:46 +01:00
commit fa504e510f
1537 changed files with 7013 additions and 3760 deletions

View File

@ -422,10 +422,10 @@ test-rust-stable:
image: ethcore/rust:stable image: ethcore/rust:stable
before_script: before_script:
- git submodule update --init --recursive - git submodule update --init --recursive
- export RUST_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep -v ^js/ | wc -l) - export RUST_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep -v -e ^js -e ^\\. -e ^LICENSE -e ^README.md -e ^appveyor.yml -e ^test.sh -e ^windows/ -e ^scripts/ -e^mac/ -e ^nsis/ | wc -l)
script: script:
- export RUST_BACKTRACE=1 - export RUST_BACKTRACE=1
- if [ "$RUST_FILES_MODIFIED" = 0 ]; then echo "Skipping Rust tests since no Rust files modified."; else ./test.sh $CARGOFLAGS; fi - if [ $RUST_FILES_MODIFIED -eq 0 ]; then echo "Skipping Rust tests since no Rust files modified."; else ./test.sh $CARGOFLAGS; fi
tags: tags:
- rust - rust
- rust-stable - rust-stable
@ -435,9 +435,9 @@ js-test:
before_script: before_script:
- git submodule update --init --recursive - git submodule update --init --recursive
- export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep ^js/ | wc -l) - export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep ^js/ | wc -l)
- if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "Skipping JS deps install since no JS files modified."; else ./js/scripts/install-deps.sh;fi - if [ $JS_FILES_MODIFIED -eq 0 ]; then echo "Skipping JS deps install since no JS files modified."; else ./js/scripts/install-deps.sh;fi
script: script:
- if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "Skipping JS lint since no JS files modified."; else ./js/scripts/lint.sh && ./js/scripts/test.sh && ./js/scripts/build.sh; fi - if [ $JS_FILES_MODIFIED -eq 0 ]; then echo "Skipping JS lint since no JS files modified."; else ./js/scripts/lint.sh && ./js/scripts/test.sh && ./js/scripts/build.sh; fi
tags: tags:
- rust - rust
- rust-stable - rust-stable
@ -480,9 +480,9 @@ js-release:
before_script: before_script:
- export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep ^js/ | wc -l) - export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep ^js/ | wc -l)
- echo $JS_FILES_MODIFIED - echo $JS_FILES_MODIFIED
- if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "Skipping JS deps install since no JS files modified."; else ./js/scripts/install-deps.sh;fi - if [ $JS_FILES_MODIFIED -eq 0 ]; then echo "Skipping JS deps install since no JS files modified."; else ./js/scripts/install-deps.sh;fi
script: script:
- echo $JS_FILES_MODIFIED - echo $JS_FILES_MODIFIED
- if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "Skipping JS rebuild since no JS files modified."; else ./js/scripts/build.sh && ./js/scripts/release.sh; fi - if [ $JS_FILES_MODIFIED -eq 0 ]; then echo "Skipping JS rebuild since no JS files modified."; else ./js/scripts/build.sh && ./js/scripts/release.sh; fi
tags: tags:
- javascript - javascript

2
Cargo.lock generated
View File

@ -1290,7 +1290,7 @@ dependencies = [
[[package]] [[package]]
name = "parity-ui-precompiled" name = "parity-ui-precompiled"
version = "1.4.0" version = "1.4.0"
source = "git+https://github.com/ethcore/js-precompiled.git#3d3b2f9e8e8b0fd62c172240bfd001a317cf2979" source = "git+https://github.com/ethcore/js-precompiled.git#b29e2a151561ae41aa27af3b226522844ae8aae2"
dependencies = [ dependencies = [
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]

View File

@ -3,7 +3,7 @@ description = "Ethcore client."
name = "parity" name = "parity"
version = "1.5.0" version = "1.5.0"
license = "GPL-3.0" license = "GPL-3.0"
authors = ["Ethcore <admin@ethcore.io>"] authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs" build = "build.rs"
[build-dependencies] [build-dependencies]

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -3,7 +3,7 @@ description = "Parity Dapps crate"
name = "ethcore-dapps" name = "ethcore-dapps"
version = "1.5.0" version = "1.5.0"
license = "GPL-3.0" license = "GPL-3.0"
authors = ["Ethcore <admin@ethcore.io"] authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs" build = "build.rs"
[lib] [lib]

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -3,7 +3,7 @@ description = "Base Package for all Parity built-in dapps"
name = "parity-dapps-glue" name = "parity-dapps-glue"
version = "1.5.0" version = "1.5.0"
license = "GPL-3.0" license = "GPL-3.0"
authors = ["Ethcore <admin@ethcore.io"] authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs" build = "build.rs"
[build-dependencies] [build-dependencies]

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,10 +1,10 @@
[package] [package]
description = "Ethcore Parity UI" description = "Ethcore Parity UI"
homepage = "http://ethcore.io" homepage = "http://parity.io"
license = "GPL-3.0" license = "GPL-3.0"
name = "parity-ui" name = "parity-ui"
version = "1.5.0" version = "1.5.0"
authors = ["Ethcore <admin@ethcore.io>"] authors = ["Parity Technologies <admin@parity.io>"]
[build-dependencies] [build-dependencies]
rustc_version = "0.1" rustc_version = "0.1"

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,10 +1,10 @@
[package] [package]
description = "Ethcore Database" description = "Ethcore Database"
homepage = "http://ethcore.io" homepage = "http://parity.io"
license = "GPL-3.0" license = "GPL-3.0"
name = "ethcore-db" name = "ethcore-db"
version = "1.5.0" version = "1.5.0"
authors = ["Ethcore <admin@ethcore.io>"] authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs" build = "build.rs"
[build-dependencies] [build-dependencies]

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,10 +1,10 @@
[package] [package]
description = "Ethcore development/test/build tools" description = "Ethcore development/test/build tools"
homepage = "http://ethcore.io" homepage = "http://parity.io"
license = "GPL-3.0" license = "GPL-3.0"
name = "ethcore-devtools" name = "ethcore-devtools"
version = "1.5.0" version = "1.5.0"
authors = ["Ethcore <admin@ethcore.io>"] authors = ["Parity Technologies <admin@parity.io>"]
[dependencies] [dependencies]
rand = "0.3" rand = "0.3"

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,7 +1,7 @@
[package] [package]
name = "ethash" name = "ethash"
version = "1.5.0" version = "1.5.0"
authors = ["arkpar <arkadiy@ethcore.io"] authors = ["Parity Technologies <admin@parity.io>"]
[lib] [lib]

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,10 +1,10 @@
[package] [package]
description = "Ethcore library" description = "Ethcore library"
homepage = "http://ethcore.io" homepage = "http://parity.io"
license = "GPL-3.0" license = "GPL-3.0"
name = "ethcore" name = "ethcore"
version = "1.5.0" version = "1.5.0"
authors = ["Ethcore <admin@ethcore.io>"] authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs" build = "build.rs"
[build-dependencies] [build-dependencies]

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,10 +1,10 @@
[package] [package]
description = "Fetching hash-addressed content." description = "Fetching hash-addressed content."
homepage = "https://ethcore.io" homepage = "http://parity.io"
license = "GPL-3.0" license = "GPL-3.0"
name = "ethcore-hash-fetch" name = "ethcore-hash-fetch"
version = "1.5.0" version = "1.5.0"
authors = ["Ethcore <admin@ethcore.io>"] authors = ["Parity Technologies <admin@parity.io>"]
[dependencies] [dependencies]
log = "0.3" log = "0.3"

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,10 +1,10 @@
[package] [package]
description = "Parity LES primitives" description = "Parity LES primitives"
homepage = "https://ethcore.io" homepage = "http://parity.io"
license = "GPL-3.0" license = "GPL-3.0"
name = "ethcore-light" name = "ethcore-light"
version = "1.5.0" version = "1.5.0"
authors = ["Ethcore <admin@ethcore.io>"] authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs" build = "build.rs"
[build-dependencies] [build-dependencies]

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify
@ -14,8 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Light client implementation. Used for raw data queries as well as the header //! Light client implementation. Stores data from light sync
//! sync.
use std::sync::Arc; use std::sync::Arc;
@ -29,7 +28,7 @@ use ethcore::transaction::SignedTransaction;
use ethcore::blockchain_info::BlockChainInfo; use ethcore::blockchain_info::BlockChainInfo;
use io::IoChannel; use io::IoChannel;
use util::hash::H256; use util::hash::{H256, H256FastMap};
use util::{Bytes, Mutex}; use util::{Bytes, Mutex};
use provider::Provider; use provider::Provider;
@ -37,9 +36,10 @@ use request;
/// Light client implementation. /// Light client implementation.
pub struct Client { pub struct Client {
engine: Arc<Engine>, _engine: Arc<Engine>,
header_queue: HeaderQueue, header_queue: HeaderQueue,
message_channel: Mutex<IoChannel<ClientIoMessage>>, _message_channel: Mutex<IoChannel<ClientIoMessage>>,
tx_pool: Mutex<H256FastMap<SignedTransaction>>,
} }
impl Client { impl Client {
@ -55,12 +55,17 @@ impl Client {
false false
} }
/// Fetch a vector of all pending transactions. /// Import a local transaction.
pub fn pending_transactions(&self) -> Vec<SignedTransaction> { pub fn import_own_transaction(&self, tx: SignedTransaction) {
vec![] self.tx_pool.lock().insert(tx.hash(), tx);
} }
/// Inquire about the status of a given block. /// Fetch a vector of all pending transactions.
pub fn pending_transactions(&self) -> Vec<SignedTransaction> {
self.tx_pool.lock().values().cloned().collect()
}
/// Inquire about the status of a given block (or header).
pub fn status(&self, _id: BlockId) -> BlockStatus { pub fn status(&self, _id: BlockId) -> BlockStatus {
BlockStatus::Unknown BlockStatus::Unknown
} }

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify
@ -28,8 +28,7 @@
//! It starts by performing a header-only sync, verifying random samples //! It starts by performing a header-only sync, verifying random samples
//! of members of the chain to varying degrees. //! of members of the chain to varying degrees.
// TODO: remove when integrating with the rest of parity. #![deny(missing_docs)]
#![allow(dead_code)]
pub mod client; pub mod client;
pub mod net; pub mod net;

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify
@ -16,7 +16,7 @@
//! I/O and event context generalizations. //! I/O and event context generalizations.
use network::{NetworkContext, PeerId}; use network::{NetworkContext, PeerId, NodeId};
use super::{Announcement, LightProtocol, ReqId}; use super::{Announcement, LightProtocol, ReqId};
use super::error::Error; use super::error::Error;
@ -26,95 +26,113 @@ use request::Request;
/// disconnecting peers. This is used as a generalization of the portions /// disconnecting peers. This is used as a generalization of the portions
/// of a p2p network which the light protocol structure makes use of. /// of a p2p network which the light protocol structure makes use of.
pub trait IoContext { pub trait IoContext {
/// Send a packet to a specific peer. /// Send a packet to a specific peer.
fn send(&self, peer: PeerId, packet_id: u8, packet_body: Vec<u8>); fn send(&self, peer: PeerId, packet_id: u8, packet_body: Vec<u8>);
/// Respond to a peer's message. Only works if this context is a byproduct /// Respond to a peer's message. Only works if this context is a byproduct
/// of a packet handler. /// of a packet handler.
fn respond(&self, packet_id: u8, packet_body: Vec<u8>); fn respond(&self, packet_id: u8, packet_body: Vec<u8>);
/// Disconnect a peer. /// Disconnect a peer.
fn disconnect_peer(&self, peer: PeerId); fn disconnect_peer(&self, peer: PeerId);
/// Disable a peer -- this is a disconnect + a time-out. /// Disable a peer -- this is a disconnect + a time-out.
fn disable_peer(&self, peer: PeerId); fn disable_peer(&self, peer: PeerId);
/// Get a peer's protocol version. /// Get a peer's protocol version.
fn protocol_version(&self, peer: PeerId) -> Option<u8>; fn protocol_version(&self, peer: PeerId) -> Option<u8>;
/// Persistent peer id
fn persistent_peer_id(&self, peer: PeerId) -> Option<NodeId>;
} }
impl<'a> IoContext for NetworkContext<'a> { impl<'a> IoContext for NetworkContext<'a> {
fn send(&self, peer: PeerId, packet_id: u8, packet_body: Vec<u8>) { fn send(&self, peer: PeerId, packet_id: u8, packet_body: Vec<u8>) {
if let Err(e) = self.send(peer, packet_id, packet_body) { if let Err(e) = self.send(peer, packet_id, packet_body) {
debug!(target: "les", "Error sending packet to peer {}: {}", peer, e); debug!(target: "les", "Error sending packet to peer {}: {}", peer, e);
} }
} }
fn respond(&self, packet_id: u8, packet_body: Vec<u8>) { fn respond(&self, packet_id: u8, packet_body: Vec<u8>) {
if let Err(e) = self.respond(packet_id, packet_body) { if let Err(e) = self.respond(packet_id, packet_body) {
debug!(target: "les", "Error responding to peer message: {}", e); debug!(target: "les", "Error responding to peer message: {}", e);
} }
} }
fn disconnect_peer(&self, peer: PeerId) { fn disconnect_peer(&self, peer: PeerId) {
NetworkContext::disconnect_peer(self, peer); NetworkContext::disconnect_peer(self, peer);
} }
fn disable_peer(&self, peer: PeerId) { fn disable_peer(&self, peer: PeerId) {
NetworkContext::disable_peer(self, peer); NetworkContext::disable_peer(self, peer);
} }
fn protocol_version(&self, peer: PeerId) -> Option<u8> { fn protocol_version(&self, peer: PeerId) -> Option<u8> {
self.protocol_version(self.subprotocol_name(), peer) self.protocol_version(self.subprotocol_name(), peer)
} }
fn persistent_peer_id(&self, peer: PeerId) -> Option<NodeId> {
self.session_info(peer).and_then(|info| info.id)
}
} }
/// Context for a protocol event. /// Context for a protocol event.
pub trait EventContext { pub trait EventContext {
/// Get the peer relevant to the event e.g. message sender, /// Get the peer relevant to the event e.g. message sender,
/// disconnected/connected peer. /// disconnected/connected peer.
fn peer(&self) -> PeerId; fn peer(&self) -> PeerId;
/// Make a request from a peer. /// Returns the relevant's peer persistent Id (aka NodeId).
fn request_from(&self, peer: PeerId, request: Request) -> Result<ReqId, Error>; fn persistent_peer_id(&self, peer: PeerId) -> Option<NodeId>;
/// Make an announcement of new capabilities to the rest of the peers. /// Make a request from a peer.
// TODO: maybe just put this on a timer in LightProtocol? fn request_from(&self, peer: PeerId, request: Request) -> Result<ReqId, Error>;
fn make_announcement(&self, announcement: Announcement);
/// Disconnect a peer. /// Make an announcement of new capabilities to the rest of the peers.
fn disconnect_peer(&self, peer: PeerId); // TODO: maybe just put this on a timer in LightProtocol?
fn make_announcement(&self, announcement: Announcement);
/// Disable a peer. /// Disconnect a peer.
fn disable_peer(&self, peer: PeerId); fn disconnect_peer(&self, peer: PeerId);
/// Disable a peer.
fn disable_peer(&self, peer: PeerId);
} }
/// Concrete implementation of `EventContext` over the light protocol struct and /// Concrete implementation of `EventContext` over the light protocol struct and
/// an io context. /// an io context.
pub struct Ctx<'a> { pub struct Ctx<'a> {
/// Io context to enable immediate response to events. /// Io context to enable immediate response to events.
pub io: &'a IoContext, pub io: &'a IoContext,
/// Protocol implementation. /// Protocol implementation.
pub proto: &'a LightProtocol, pub proto: &'a LightProtocol,
/// Relevant peer for event. /// Relevant peer for event.
pub peer: PeerId, pub peer: PeerId,
} }
impl<'a> EventContext for Ctx<'a> { impl<'a> EventContext for Ctx<'a> {
fn peer(&self) -> PeerId { self.peer } fn peer(&self) -> PeerId {
fn request_from(&self, peer: PeerId, request: Request) -> Result<ReqId, Error> { self.peer
self.proto.request_from(self.io, &peer, request) }
}
fn make_announcement(&self, announcement: Announcement) { fn persistent_peer_id(&self, id: PeerId) -> Option<NodeId> {
self.proto.make_announcement(self.io, announcement); self.io.persistent_peer_id(id)
} }
fn disconnect_peer(&self, peer: PeerId) { fn request_from(&self, peer: PeerId, request: Request) -> Result<ReqId, Error> {
self.io.disconnect_peer(peer); self.proto.request_from(self.io, &peer, request)
} }
fn disable_peer(&self, peer: PeerId) { fn make_announcement(&self, announcement: Announcement) {
self.io.disable_peer(peer); self.proto.make_announcement(self.io, announcement);
} }
fn disconnect_peer(&self, peer: PeerId) {
self.io.disconnect_peer(peer);
}
fn disable_peer(&self, peer: PeerId) {
self.io.disable_peer(peer);
}
} }

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify
@ -34,7 +34,7 @@ use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::atomic::{AtomicUsize, Ordering};
use provider::Provider; use provider::Provider;
use request::{self, Request}; use request::{self, HashOrNumber, Request};
use self::buffer_flow::{Buffer, FlowParams}; use self::buffer_flow::{Buffer, FlowParams};
use self::context::Ctx; use self::context::Ctx;
@ -57,13 +57,13 @@ const TIMEOUT_INTERVAL_MS: u64 = 1000;
// minimum interval between updates. // minimum interval between updates.
const UPDATE_INTERVAL_MS: i64 = 5000; const UPDATE_INTERVAL_MS: i64 = 5000;
// Supported protocol versions. /// Supported protocol versions.
pub const PROTOCOL_VERSIONS: &'static [u8] = &[1]; pub const PROTOCOL_VERSIONS: &'static [u8] = &[1];
// Max protocol version. /// Max protocol version.
pub const MAX_PROTOCOL_VERSION: u8 = 1; pub const MAX_PROTOCOL_VERSION: u8 = 1;
// Packet count for LES. /// Packet count for LES.
pub const PACKET_COUNT: u8 = 15; pub const PACKET_COUNT: u8 = 15;
// packet ID definitions. // packet ID definitions.
@ -102,6 +102,18 @@ mod packet {
pub const HEADER_PROOFS: u8 = 0x0e; pub const HEADER_PROOFS: u8 = 0x0e;
} }
// timeouts for different kinds of requests. all values are in milliseconds.
// TODO: variable timeouts based on request count.
mod timeout {
pub const HANDSHAKE: i64 = 2500;
pub const HEADERS: i64 = 5000;
pub const BODIES: i64 = 5000;
pub const RECEIPTS: i64 = 3500;
pub const PROOFS: i64 = 4000;
pub const CONTRACT_CODES: i64 = 5000;
pub const HEADER_PROOFS: i64 = 3500;
}
/// A request id. /// A request id.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ReqId(usize); pub struct ReqId(usize);
@ -111,7 +123,6 @@ pub struct ReqId(usize);
struct PendingPeer { struct PendingPeer {
sent_head: H256, sent_head: H256,
last_update: SteadyTime, last_update: SteadyTime,
proto_version: u8,
} }
// data about each peer. // data about each peer.
@ -122,7 +133,6 @@ struct Peer {
remote_flow: Option<(Buffer, FlowParams)>, remote_flow: Option<(Buffer, FlowParams)>,
sent_head: H256, // last head we've given them. sent_head: H256, // last head we've given them.
last_update: SteadyTime, last_update: SteadyTime,
proto_version: u8,
} }
impl Peer { impl Peer {
@ -443,17 +453,54 @@ impl LightProtocol {
} }
}; };
// if something went wrong, figure out how much to punish the peer.
if let Err(e) = res { if let Err(e) = res {
match e.punishment() { punish(*peer, io, e);
Punishment::None => {} }
Punishment::Disconnect => { }
debug!(target: "les", "Disconnecting peer {}: {}", peer, e);
io.disconnect_peer(*peer) // check timeouts and punish peers.
} fn timeout_check(&self, io: &IoContext) {
Punishment::Disable => { let now = SteadyTime::now();
debug!(target: "les", "Disabling peer {}: {}", peer, e);
io.disable_peer(*peer) // handshake timeout
{
let mut pending = self.pending_peers.write();
let slowpokes: Vec<_> = pending.iter()
.filter(|&(_, ref peer)| {
peer.last_update + Duration::milliseconds(timeout::HANDSHAKE) <= now
})
.map(|(&p, _)| p)
.collect();
for slowpoke in slowpokes {
debug!(target: "les", "Peer {} handshake timed out", slowpoke);
pending.remove(&slowpoke);
io.disconnect_peer(slowpoke);
}
}
// request timeouts
{
for r in self.pending_requests.read().values() {
let kind_timeout = match r.request.kind() {
request::Kind::Headers => timeout::HEADERS,
request::Kind::Bodies => timeout::BODIES,
request::Kind::Receipts => timeout::RECEIPTS,
request::Kind::StateProofs => timeout::PROOFS,
request::Kind::Codes => timeout::CONTRACT_CODES,
request::Kind::HeaderProofs => timeout::HEADER_PROOFS,
};
if r.timestamp + Duration::milliseconds(kind_timeout) <= now {
debug!(target: "les", "Request for {:?} from peer {} timed out",
r.request.kind(), r.peer_id);
// keep the request in the `pending` set for now so
// on_disconnect will pass unfulfilled ReqIds to handlers.
// in the case that a response is received after this, the
// disconnect won't be cancelled but the ReqId won't be
// marked as abandoned.
io.disconnect_peer(r.peer_id);
} }
} }
} }
@ -463,19 +510,37 @@ impl LightProtocol {
impl LightProtocol { impl LightProtocol {
// called when a peer connects. // called when a peer connects.
fn on_connect(&self, peer: &PeerId, io: &IoContext) { fn on_connect(&self, peer: &PeerId, io: &IoContext) {
let peer = *peer; let proto_version = match io.protocol_version(*peer).ok_or(Error::WrongNetwork) {
Ok(pv) => pv,
Err(e) => { punish(*peer, io, e); return }
};
trace!(target: "les", "Peer {} connecting", peer); if PROTOCOL_VERSIONS.iter().find(|x| **x == proto_version).is_none() {
punish(*peer, io, Error::UnsupportedProtocolVersion(proto_version));
match self.send_status(peer, io) { return;
Ok(pending_peer) => {
self.pending_peers.write().insert(peer, pending_peer);
}
Err(e) => {
trace!(target: "les", "Error while sending status: {}", e);
io.disconnect_peer(peer);
}
} }
let chain_info = self.provider.chain_info();
let status = Status {
head_td: chain_info.total_difficulty,
head_hash: chain_info.best_block_hash,
head_num: chain_info.best_block_number,
genesis_hash: chain_info.genesis_hash,
protocol_version: proto_version as u32, // match peer proto version
network_id: self.network_id,
last_head: None,
};
let capabilities = self.capabilities.read().clone();
let status_packet = status::write_handshake(&status, &capabilities, Some(&self.flow_params));
self.pending_peers.write().insert(*peer, PendingPeer {
sent_head: chain_info.best_block_hash,
last_update: SteadyTime::now(),
});
io.send(*peer, packet::STATUS, status_packet);
} }
// called when a peer disconnects. // called when a peer disconnects.
@ -508,38 +573,6 @@ impl LightProtocol {
} }
} }
// send status to a peer.
fn send_status(&self, peer: PeerId, io: &IoContext) -> Result<PendingPeer, Error> {
let proto_version = try!(io.protocol_version(peer).ok_or(Error::WrongNetwork));
if PROTOCOL_VERSIONS.iter().find(|x| **x == proto_version).is_none() {
return Err(Error::UnsupportedProtocolVersion(proto_version));
}
let chain_info = self.provider.chain_info();
let status = Status {
head_td: chain_info.total_difficulty,
head_hash: chain_info.best_block_hash,
head_num: chain_info.best_block_number,
genesis_hash: chain_info.genesis_hash,
protocol_version: proto_version as u32, // match peer proto version
network_id: self.network_id,
last_head: None,
};
let capabilities = self.capabilities.read().clone();
let status_packet = status::write_handshake(&status, &capabilities, Some(&self.flow_params));
io.send(peer, packet::STATUS, status_packet);
Ok(PendingPeer {
sent_head: chain_info.best_block_hash,
last_update: SteadyTime::now(),
proto_version: proto_version,
})
}
// Handle status message from peer. // Handle status message from peer.
fn status(&self, peer: &PeerId, io: &IoContext, data: UntrustedRlp) -> Result<(), Error> { fn status(&self, peer: &PeerId, io: &IoContext, data: UntrustedRlp) -> Result<(), Error> {
let pending = match self.pending_peers.write().remove(peer) { let pending = match self.pending_peers.write().remove(peer) {
@ -570,7 +603,6 @@ impl LightProtocol {
remote_flow: remote_flow, remote_flow: remote_flow,
sent_head: pending.sent_head, sent_head: pending.sent_head,
last_update: pending.last_update, last_update: pending.last_update,
proto_version: pending.proto_version,
})); }));
for handler in &self.handlers { for handler in &self.handlers {
@ -645,18 +677,21 @@ impl LightProtocol {
let mut peer = peer.lock(); let mut peer = peer.lock();
let req_id: u64 = try!(data.val_at(0)); let req_id: u64 = try!(data.val_at(0));
let data = try!(data.at(1));
let block = { let start_block = {
let rlp = try!(data.at(1)); if try!(data.at(0)).size() == 32 {
(try!(rlp.val_at(0)), try!(rlp.val_at(1))) HashOrNumber::Hash(try!(data.val_at(0)))
} else {
HashOrNumber::Number(try!(data.val_at(0)))
}
}; };
let req = request::Headers { let req = request::Headers {
block_num: block.0, start: start_block,
block_hash: block.1, max: ::std::cmp::min(MAX_HEADERS, try!(data.val_at(1))),
max: ::std::cmp::min(MAX_HEADERS, try!(data.val_at(2))), skip: try!(data.val_at(2)),
skip: try!(data.val_at(3)), reverse: try!(data.val_at(3)),
reverse: try!(data.val_at(4)),
}; };
let max_cost = try!(peer.deduct_max(&self.flow_params, request::Kind::Headers, req.max)); let max_cost = try!(peer.deduct_max(&self.flow_params, request::Kind::Headers, req.max));
@ -667,8 +702,8 @@ impl LightProtocol {
let cur_buffer = peer.refund(&self.flow_params, max_cost - actual_cost); let cur_buffer = peer.refund(&self.flow_params, max_cost - actual_cost);
io.respond(packet::BLOCK_HEADERS, { io.respond(packet::BLOCK_HEADERS, {
let mut stream = RlpStream::new_list(response.len() + 2); let mut stream = RlpStream::new_list(3);
stream.append(&req_id).append(&cur_buffer); stream.append(&req_id).append(&cur_buffer).begin_list(response.len());
for header in response { for header in response {
stream.append_raw(&header, 1); stream.append_raw(&header, 1);
@ -683,7 +718,7 @@ impl LightProtocol {
// Receive a response for block headers. // Receive a response for block headers.
fn block_headers(&self, peer: &PeerId, io: &IoContext, raw: UntrustedRlp) -> Result<(), Error> { fn block_headers(&self, peer: &PeerId, io: &IoContext, raw: UntrustedRlp) -> Result<(), Error> {
let req_id = try!(self.pre_verify_response(peer, request::Kind::Headers, &raw)); let req_id = try!(self.pre_verify_response(peer, request::Kind::Headers, &raw));
let raw_headers: Vec<_> = raw.iter().skip(2).map(|x| x.as_raw().to_owned()).collect(); let raw_headers: Vec<_> = try!(raw.at(2)).iter().map(|x| x.as_raw().to_owned()).collect();
for handler in &self.handlers { for handler in &self.handlers {
handler.on_block_headers(&Ctx { handler.on_block_headers(&Ctx {
@ -713,7 +748,7 @@ impl LightProtocol {
let req_id: u64 = try!(data.val_at(0)); let req_id: u64 = try!(data.val_at(0));
let req = request::Bodies { let req = request::Bodies {
block_hashes: try!(data.iter().skip(1).take(MAX_BODIES).map(|x| x.as_val()).collect()) block_hashes: try!(try!(data.at(1)).iter().take(MAX_BODIES).map(|x| x.as_val()).collect())
}; };
let max_cost = try!(peer.deduct_max(&self.flow_params, request::Kind::Bodies, req.block_hashes.len())); let max_cost = try!(peer.deduct_max(&self.flow_params, request::Kind::Bodies, req.block_hashes.len()));
@ -726,8 +761,8 @@ impl LightProtocol {
let cur_buffer = peer.refund(&self.flow_params, max_cost - actual_cost); let cur_buffer = peer.refund(&self.flow_params, max_cost - actual_cost);
io.respond(packet::BLOCK_BODIES, { io.respond(packet::BLOCK_BODIES, {
let mut stream = RlpStream::new_list(response.len() + 2); let mut stream = RlpStream::new_list(3);
stream.append(&req_id).append(&cur_buffer); stream.append(&req_id).append(&cur_buffer).begin_list(response.len());
for body in response { for body in response {
stream.append_raw(&body, 1); stream.append_raw(&body, 1);
@ -742,7 +777,7 @@ impl LightProtocol {
// Receive a response for block bodies. // Receive a response for block bodies.
fn block_bodies(&self, peer: &PeerId, io: &IoContext, raw: UntrustedRlp) -> Result<(), Error> { fn block_bodies(&self, peer: &PeerId, io: &IoContext, raw: UntrustedRlp) -> Result<(), Error> {
let req_id = try!(self.pre_verify_response(peer, request::Kind::Bodies, &raw)); let req_id = try!(self.pre_verify_response(peer, request::Kind::Bodies, &raw));
let raw_bodies: Vec<Bytes> = raw.iter().skip(2).map(|x| x.as_raw().to_owned()).collect(); let raw_bodies: Vec<Bytes> = try!(raw.at(2)).iter().map(|x| x.as_raw().to_owned()).collect();
for handler in &self.handlers { for handler in &self.handlers {
handler.on_block_bodies(&Ctx { handler.on_block_bodies(&Ctx {
@ -772,7 +807,7 @@ impl LightProtocol {
let req_id: u64 = try!(data.val_at(0)); let req_id: u64 = try!(data.val_at(0));
let req = request::Receipts { let req = request::Receipts {
block_hashes: try!(data.iter().skip(1).take(MAX_RECEIPTS).map(|x| x.as_val()).collect()) block_hashes: try!(try!(data.at(1)).iter().take(MAX_RECEIPTS).map(|x| x.as_val()).collect())
}; };
let max_cost = try!(peer.deduct_max(&self.flow_params, request::Kind::Receipts, req.block_hashes.len())); let max_cost = try!(peer.deduct_max(&self.flow_params, request::Kind::Receipts, req.block_hashes.len()));
@ -785,8 +820,8 @@ impl LightProtocol {
let cur_buffer = peer.refund(&self.flow_params, max_cost - actual_cost); let cur_buffer = peer.refund(&self.flow_params, max_cost - actual_cost);
io.respond(packet::RECEIPTS, { io.respond(packet::RECEIPTS, {
let mut stream = RlpStream::new_list(response.len() + 2); let mut stream = RlpStream::new_list(3);
stream.append(&req_id).append(&cur_buffer); stream.append(&req_id).append(&cur_buffer).begin_list(response.len());
for receipts in response { for receipts in response {
stream.append_raw(&receipts, 1); stream.append_raw(&receipts, 1);
@ -801,9 +836,8 @@ impl LightProtocol {
// Receive a response for receipts. // Receive a response for receipts.
fn receipts(&self, peer: &PeerId, io: &IoContext, raw: UntrustedRlp) -> Result<(), Error> { fn receipts(&self, peer: &PeerId, io: &IoContext, raw: UntrustedRlp) -> Result<(), Error> {
let req_id = try!(self.pre_verify_response(peer, request::Kind::Receipts, &raw)); let req_id = try!(self.pre_verify_response(peer, request::Kind::Receipts, &raw));
let raw_receipts: Vec<Vec<Receipt>> = try!(raw let raw_receipts: Vec<Vec<Receipt>> = try!(try!(raw.at(2))
.iter() .iter()
.skip(2)
.map(|x| x.as_val()) .map(|x| x.as_val())
.collect()); .collect());
@ -835,7 +869,7 @@ impl LightProtocol {
let req_id: u64 = try!(data.val_at(0)); let req_id: u64 = try!(data.val_at(0));
let req = { let req = {
let requests: Result<Vec<_>, Error> = data.iter().skip(1).take(MAX_PROOFS).map(|x| { let requests: Result<Vec<_>, Error> = try!(data.at(1)).iter().take(MAX_PROOFS).map(|x| {
Ok(request::StateProof { Ok(request::StateProof {
block: try!(x.val_at(0)), block: try!(x.val_at(0)),
key1: try!(x.val_at(1)), key1: try!(x.val_at(1)),
@ -859,8 +893,8 @@ impl LightProtocol {
let cur_buffer = peer.refund(&self.flow_params, max_cost - actual_cost); let cur_buffer = peer.refund(&self.flow_params, max_cost - actual_cost);
io.respond(packet::PROOFS, { io.respond(packet::PROOFS, {
let mut stream = RlpStream::new_list(response.len() + 2); let mut stream = RlpStream::new_list(3);
stream.append(&req_id).append(&cur_buffer); stream.append(&req_id).append(&cur_buffer).begin_list(response.len());
for proof in response { for proof in response {
stream.append_raw(&proof, 1); stream.append_raw(&proof, 1);
@ -876,8 +910,7 @@ impl LightProtocol {
fn proofs(&self, peer: &PeerId, io: &IoContext, raw: UntrustedRlp) -> Result<(), Error> { fn proofs(&self, peer: &PeerId, io: &IoContext, raw: UntrustedRlp) -> Result<(), Error> {
let req_id = try!(self.pre_verify_response(peer, request::Kind::StateProofs, &raw)); let req_id = try!(self.pre_verify_response(peer, request::Kind::StateProofs, &raw));
let raw_proofs: Vec<Vec<Bytes>> = raw.iter() let raw_proofs: Vec<Vec<Bytes>> = try!(raw.at(2)).iter()
.skip(2)
.map(|x| x.iter().map(|node| node.as_raw().to_owned()).collect()) .map(|x| x.iter().map(|node| node.as_raw().to_owned()).collect())
.collect(); .collect();
@ -909,7 +942,7 @@ impl LightProtocol {
let req_id: u64 = try!(data.val_at(0)); let req_id: u64 = try!(data.val_at(0));
let req = { let req = {
let requests: Result<Vec<_>, Error> = data.iter().skip(1).take(MAX_CODES).map(|x| { let requests: Result<Vec<_>, Error> = try!(data.at(1)).iter().take(MAX_CODES).map(|x| {
Ok(request::ContractCode { Ok(request::ContractCode {
block_hash: try!(x.val_at(0)), block_hash: try!(x.val_at(0)),
account_key: try!(x.val_at(1)), account_key: try!(x.val_at(1)),
@ -931,8 +964,8 @@ impl LightProtocol {
let cur_buffer = peer.refund(&self.flow_params, max_cost - actual_cost); let cur_buffer = peer.refund(&self.flow_params, max_cost - actual_cost);
io.respond(packet::CONTRACT_CODES, { io.respond(packet::CONTRACT_CODES, {
let mut stream = RlpStream::new_list(response.len() + 2); let mut stream = RlpStream::new_list(3);
stream.append(&req_id).append(&cur_buffer); stream.append(&req_id).append(&cur_buffer).begin_list(response.len());
for code in response { for code in response {
stream.append(&code); stream.append(&code);
@ -948,7 +981,7 @@ impl LightProtocol {
fn contract_code(&self, peer: &PeerId, io: &IoContext, raw: UntrustedRlp) -> Result<(), Error> { fn contract_code(&self, peer: &PeerId, io: &IoContext, raw: UntrustedRlp) -> Result<(), Error> {
let req_id = try!(self.pre_verify_response(peer, request::Kind::Codes, &raw)); let req_id = try!(self.pre_verify_response(peer, request::Kind::Codes, &raw));
let raw_code: Vec<Bytes> = try!(raw.iter().skip(2).map(|x| x.as_val()).collect()); let raw_code: Vec<Bytes> = try!(try!(raw.at(2)).iter().map(|x| x.as_val()).collect());
for handler in &self.handlers { for handler in &self.handlers {
handler.on_code(&Ctx { handler.on_code(&Ctx {
@ -978,7 +1011,7 @@ impl LightProtocol {
let req_id: u64 = try!(data.val_at(0)); let req_id: u64 = try!(data.val_at(0));
let req = { let req = {
let requests: Result<Vec<_>, Error> = data.iter().skip(1).take(MAX_PROOFS).map(|x| { let requests: Result<Vec<_>, Error> = try!(data.at(1)).iter().take(MAX_PROOFS).map(|x| {
Ok(request::HeaderProof { Ok(request::HeaderProof {
cht_number: try!(x.val_at(0)), cht_number: try!(x.val_at(0)),
block_number: try!(x.val_at(1)), block_number: try!(x.val_at(1)),
@ -1001,8 +1034,8 @@ impl LightProtocol {
let cur_buffer = peer.refund(&self.flow_params, max_cost - actual_cost); let cur_buffer = peer.refund(&self.flow_params, max_cost - actual_cost);
io.respond(packet::HEADER_PROOFS, { io.respond(packet::HEADER_PROOFS, {
let mut stream = RlpStream::new_list(response.len() + 2); let mut stream = RlpStream::new_list(3);
stream.append(&req_id).append(&cur_buffer); stream.append(&req_id).append(&cur_buffer).begin_list(response.len());
for proof in response { for proof in response {
stream.append_raw(&proof, 1); stream.append_raw(&proof, 1);
@ -1023,9 +1056,8 @@ impl LightProtocol {
)) ))
} }
let req_id = try!(self.pre_verify_response(peer, request::Kind::HeaderProofs, &raw)); let req_id = try!(self.pre_verify_response(peer, request::Kind::HeaderProofs, &raw));
let raw_proofs: Vec<_> = try!(raw.iter().skip(2).map(decode_res).collect()); let raw_proofs: Vec<_> = try!(try!(raw.at(2)).iter().map(decode_res).collect());
for handler in &self.handlers { for handler in &self.handlers {
handler.on_header_proofs(&Ctx { handler.on_header_proofs(&Ctx {
@ -1058,6 +1090,21 @@ impl LightProtocol {
} }
} }
// if something went wrong, figure out how much to punish the peer.
fn punish(peer: PeerId, io: &IoContext, e: Error) {
match e.punishment() {
Punishment::None => {}
Punishment::Disconnect => {
debug!(target: "les", "Disconnecting peer {}: {}", peer, e);
io.disconnect_peer(peer)
}
Punishment::Disable => {
debug!(target: "les", "Disabling peer {}: {}", peer, e);
io.disable_peer(peer)
}
}
}
impl NetworkProtocolHandler for LightProtocol { impl NetworkProtocolHandler for LightProtocol {
fn initialize(&self, io: &NetworkContext) { fn initialize(&self, io: &NetworkContext) {
io.register_timer(TIMEOUT, TIMEOUT_INTERVAL_MS).expect("Error registering sync timer."); io.register_timer(TIMEOUT, TIMEOUT_INTERVAL_MS).expect("Error registering sync timer.");
@ -1075,11 +1122,9 @@ impl NetworkProtocolHandler for LightProtocol {
self.on_disconnect(*peer, io); self.on_disconnect(*peer, io);
} }
fn timeout(&self, _io: &NetworkContext, timer: TimerToken) { fn timeout(&self, io: &NetworkContext, timer: TimerToken) {
match timer { match timer {
TIMEOUT => { TIMEOUT => self.timeout_check(io),
// broadcast transactions to peers.
}
_ => warn!(target: "les", "received timeout on unknown token {}", timer), _ => warn!(target: "les", "received timeout on unknown token {}", timer),
} }
} }
@ -1089,20 +1134,24 @@ impl NetworkProtocolHandler for LightProtocol {
fn encode_request(req: &Request, req_id: usize) -> Vec<u8> { fn encode_request(req: &Request, req_id: usize) -> Vec<u8> {
match *req { match *req {
Request::Headers(ref headers) => { Request::Headers(ref headers) => {
let mut stream = RlpStream::new_list(5); let mut stream = RlpStream::new_list(2);
stream.append(&req_id).begin_list(4);
match headers.start {
HashOrNumber::Hash(ref hash) => stream.append(hash),
HashOrNumber::Number(ref num) => stream.append(num),
};
stream stream
.append(&req_id)
.begin_list(2)
.append(&headers.block_num)
.append(&headers.block_hash)
.append(&headers.max) .append(&headers.max)
.append(&headers.skip) .append(&headers.skip)
.append(&headers.reverse); .append(&headers.reverse);
stream.out() stream.out()
} }
Request::Bodies(ref request) => { Request::Bodies(ref request) => {
let mut stream = RlpStream::new_list(request.block_hashes.len() + 1); let mut stream = RlpStream::new_list(2);
stream.append(&req_id); stream.append(&req_id).begin_list(request.block_hashes.len());
for hash in &request.block_hashes { for hash in &request.block_hashes {
stream.append(hash); stream.append(hash);
@ -1111,8 +1160,8 @@ fn encode_request(req: &Request, req_id: usize) -> Vec<u8> {
stream.out() stream.out()
} }
Request::Receipts(ref request) => { Request::Receipts(ref request) => {
let mut stream = RlpStream::new_list(request.block_hashes.len() + 1); let mut stream = RlpStream::new_list(2);
stream.append(&req_id); stream.append(&req_id).begin_list(request.block_hashes.len());
for hash in &request.block_hashes { for hash in &request.block_hashes {
stream.append(hash); stream.append(hash);
@ -1121,8 +1170,8 @@ fn encode_request(req: &Request, req_id: usize) -> Vec<u8> {
stream.out() stream.out()
} }
Request::StateProofs(ref request) => { Request::StateProofs(ref request) => {
let mut stream = RlpStream::new_list(request.requests.len() + 1); let mut stream = RlpStream::new_list(2);
stream.append(&req_id); stream.append(&req_id).begin_list(request.requests.len());
for proof_req in &request.requests { for proof_req in &request.requests {
stream.begin_list(4) stream.begin_list(4)
@ -1140,8 +1189,8 @@ fn encode_request(req: &Request, req_id: usize) -> Vec<u8> {
stream.out() stream.out()
} }
Request::Codes(ref request) => { Request::Codes(ref request) => {
let mut stream = RlpStream::new_list(request.code_requests.len() + 1); let mut stream = RlpStream::new_list(2);
stream.append(&req_id); stream.append(&req_id).begin_list(request.code_requests.len());
for code_req in &request.code_requests { for code_req in &request.code_requests {
stream.begin_list(2) stream.begin_list(2)
@ -1152,8 +1201,8 @@ fn encode_request(req: &Request, req_id: usize) -> Vec<u8> {
stream.out() stream.out()
} }
Request::HeaderProofs(ref request) => { Request::HeaderProofs(ref request) => {
let mut stream = RlpStream::new_list(request.requests.len() + 1); let mut stream = RlpStream::new_list(2);
stream.append(&req_id); stream.append(&req_id).begin_list(request.requests.len());
for proof_req in &request.requests { for proof_req in &request.requests {
stream.begin_list(3) stream.begin_list(3)

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify
@ -21,7 +21,7 @@ use ethcore::blockchain_info::BlockChainInfo;
use ethcore::client::{BlockChainClient, EachBlockWith, TestBlockChainClient}; use ethcore::client::{BlockChainClient, EachBlockWith, TestBlockChainClient};
use ethcore::ids::BlockId; use ethcore::ids::BlockId;
use ethcore::transaction::SignedTransaction; use ethcore::transaction::SignedTransaction;
use network::PeerId; use network::{PeerId, NodeId};
use net::buffer_flow::FlowParams; use net::buffer_flow::FlowParams;
use net::context::IoContext; use net::context::IoContext;
@ -68,6 +68,10 @@ impl IoContext for Expect {
fn protocol_version(&self, _peer: PeerId) -> Option<u8> { fn protocol_version(&self, _peer: PeerId) -> Option<u8> {
Some(super::MAX_PROTOCOL_VERSION) Some(super::MAX_PROTOCOL_VERSION)
} }
fn persistent_peer_id(&self, _peer: PeerId) -> Option<NodeId> {
None
}
} }
// can't implement directly for Arc due to cross-crate orphan rules. // can't implement directly for Arc due to cross-crate orphan rules.
@ -91,16 +95,27 @@ impl Provider for TestProvider {
} }
fn block_headers(&self, req: request::Headers) -> Vec<Bytes> { fn block_headers(&self, req: request::Headers) -> Vec<Bytes> {
let best_num = self.0.client.chain_info().best_block_number; use request::HashOrNumber;
let start_num = req.block_num; use ethcore::views::HeaderView;
match self.0.client.block_hash(BlockId::Number(req.block_num)) { let best_num = self.chain_info().best_block_number;
Some(hash) if hash == req.block_hash => {} let start_num = match req.start {
_=> { HashOrNumber::Number(start_num) => start_num,
trace!(target: "les_provider", "unknown/non-canonical start block in header request: {:?}", (req.block_num, req.block_hash)); HashOrNumber::Hash(hash) => match self.0.client.block_header(BlockId::Hash(hash)) {
return vec![] None => {
return Vec::new();
}
Some(header) => {
let num = HeaderView::new(&header).number();
if req.max == 1 || self.0.client.block_hash(BlockId::Number(num)) != Some(hash) {
// Non-canonical header or single header requested.
return vec![header];
}
num
}
} }
} };
(0u64..req.max as u64) (0u64..req.max as u64)
.map(|x: u64| x.saturating_mul(req.skip + 1)) .map(|x: u64| x.saturating_mul(req.skip + 1))
@ -250,8 +265,7 @@ fn buffer_overflow() {
// 1000 requests is far too many for the default flow params. // 1000 requests is far too many for the default flow params.
let request = encode_request(&Request::Headers(Headers { let request = encode_request(&Request::Headers(Headers {
block_num: 1, start: 1.into(),
block_hash: provider.client.chain_info().genesis_hash,
max: 1000, max: 1000,
skip: 0, skip: 0,
reverse: false, reverse: false,
@ -284,8 +298,7 @@ fn get_block_headers() {
} }
let request = Headers { let request = Headers {
block_num: 1, start: 1.into(),
block_hash: provider.client.block_hash(BlockId::Number(1)).unwrap(),
max: 10, max: 10,
skip: 0, skip: 0,
reverse: false, reverse: false,
@ -299,9 +312,9 @@ fn get_block_headers() {
let new_buf = *flow_params.limit() - flow_params.compute_cost(request::Kind::Headers, 10); let new_buf = *flow_params.limit() - flow_params.compute_cost(request::Kind::Headers, 10);
let mut response_stream = RlpStream::new_list(12); let mut response_stream = RlpStream::new_list(3);
response_stream.append(&req_id).append(&new_buf); response_stream.append(&req_id).append(&new_buf).begin_list(10);
for header in headers { for header in headers {
response_stream.append_raw(&header, 1); response_stream.append_raw(&header, 1);
} }
@ -346,9 +359,9 @@ fn get_block_bodies() {
let new_buf = *flow_params.limit() - flow_params.compute_cost(request::Kind::Bodies, 10); let new_buf = *flow_params.limit() - flow_params.compute_cost(request::Kind::Bodies, 10);
let mut response_stream = RlpStream::new_list(12); let mut response_stream = RlpStream::new_list(3);
response_stream.append(&req_id).append(&new_buf); response_stream.append(&req_id).append(&new_buf).begin_list(10);
for body in bodies { for body in bodies {
response_stream.append_raw(&body, 1); response_stream.append_raw(&body, 1);
} }
@ -399,9 +412,9 @@ fn get_block_receipts() {
let new_buf = *flow_params.limit() - flow_params.compute_cost(request::Kind::Receipts, receipts.len()); let new_buf = *flow_params.limit() - flow_params.compute_cost(request::Kind::Receipts, receipts.len());
let mut response_stream = RlpStream::new_list(2 + receipts.len()); let mut response_stream = RlpStream::new_list(3);
response_stream.append(&req_id).append(&new_buf); response_stream.append(&req_id).append(&new_buf).begin_list(receipts.len());
for block_receipts in receipts { for block_receipts in receipts {
response_stream.append_raw(&block_receipts, 1); response_stream.append_raw(&block_receipts, 1);
} }
@ -448,9 +461,9 @@ fn get_state_proofs() {
let new_buf = *flow_params.limit() - flow_params.compute_cost(request::Kind::StateProofs, 2); let new_buf = *flow_params.limit() - flow_params.compute_cost(request::Kind::StateProofs, 2);
let mut response_stream = RlpStream::new_list(4); let mut response_stream = RlpStream::new_list(3);
response_stream.append(&req_id).append(&new_buf); response_stream.append(&req_id).append(&new_buf).begin_list(2);
for proof in proofs { for proof in proofs {
response_stream.append_raw(&proof, 1); response_stream.append_raw(&proof, 1);
} }
@ -497,9 +510,9 @@ fn get_contract_code() {
let new_buf = *flow_params.limit() - flow_params.compute_cost(request::Kind::Codes, 2); let new_buf = *flow_params.limit() - flow_params.compute_cost(request::Kind::Codes, 2);
let mut response_stream = RlpStream::new_list(4); let mut response_stream = RlpStream::new_list(3);
response_stream.append(&req_id).append(&new_buf); response_stream.append(&req_id).append(&new_buf).begin_list(2);
for code in codes { for code in codes {
response_stream.append(&code); response_stream.append(&code);
} }

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify
@ -97,16 +97,28 @@ impl<T: ProvingBlockChainClient + ?Sized> Provider for T {
} }
fn block_headers(&self, req: request::Headers) -> Vec<Bytes> { fn block_headers(&self, req: request::Headers) -> Vec<Bytes> {
let best_num = self.chain_info().best_block_number; use request::HashOrNumber;
let start_num = req.block_num; use ethcore::views::HeaderView;
match self.block_hash(BlockId::Number(req.block_num)) { let best_num = self.chain_info().best_block_number;
Some(hash) if hash == req.block_hash => {} let start_num = match req.start {
_=> { HashOrNumber::Number(start_num) => start_num,
trace!(target: "les_provider", "unknown/non-canonical start block in header request: {:?}", (req.block_num, req.block_hash)); HashOrNumber::Hash(hash) => match self.block_header(BlockId::Hash(hash)) {
return vec![] None => {
trace!(target: "les_provider", "Unknown block hash {} requested", hash);
return Vec::new();
}
Some(header) => {
let num = HeaderView::new(&header).number();
if req.max == 1 || self.block_hash(BlockId::Number(num)) != Some(hash) {
// Non-canonical header or single header requested.
return vec![header];
}
num
}
} }
} };
(0u64..req.max as u64) (0u64..req.max as u64)
.map(|x: u64| x.saturating_mul(req.skip + 1)) .map(|x: u64| x.saturating_mul(req.skip + 1))

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify
@ -18,15 +18,34 @@
use util::H256; use util::H256;
/// Either a hash or a number.
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "ipc", derive(Binary))]
pub enum HashOrNumber {
/// Block hash variant.
Hash(H256),
/// Block number variant.
Number(u64),
}
impl From<H256> for HashOrNumber {
fn from(hash: H256) -> Self {
HashOrNumber::Hash(hash)
}
}
impl From<u64> for HashOrNumber {
fn from(num: u64) -> Self {
HashOrNumber::Number(num)
}
}
/// A request for block headers. /// A request for block headers.
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "ipc", derive(Binary))] #[cfg_attr(feature = "ipc", derive(Binary))]
pub struct Headers { pub struct Headers {
/// Starting block number /// Starting block number or hash.
pub block_num: u64, pub start: HashOrNumber,
/// Starting block hash. This and number could be combined but IPC codegen is
/// not robust enough to support it.
pub block_hash: H256,
/// The maximum amount of headers which can be returned. /// The maximum amount of headers which can be returned.
pub max: usize, pub max: usize,
/// The amount of headers to skip between each response entry. /// The amount of headers to skip between each response entry.

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify
@ -266,7 +266,8 @@ impl<'x> OpenBlock<'x> {
r.block.base.header.set_extra_data(extra_data); r.block.base.header.set_extra_data(extra_data);
r.block.base.header.note_dirty(); r.block.base.header.note_dirty();
engine.populate_from_parent(&mut r.block.base.header, parent, gas_range_target.0, gas_range_target.1); let gas_floor_target = ::std::cmp::max(gas_range_target.0, engine.params().min_gas_limit);
engine.populate_from_parent(&mut r.block.base.header, parent, gas_floor_target, gas_range_target.1);
engine.on_new_block(&mut r.block); engine.on_new_block(&mut r.block);
Ok(r) Ok(r)
} }

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd. // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity. // This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify // Parity is free software: you can redistribute it and/or modify

Some files were not shown because too many files have changed in this diff Show More