clean up errors
This commit is contained in:
parent
11e6b08f02
commit
8c2c048444
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -289,6 +289,7 @@ dependencies = [
|
|||||||
"ethcore-ipc 1.4.0",
|
"ethcore-ipc 1.4.0",
|
||||||
"ethcore-ipc-codegen 1.4.0",
|
"ethcore-ipc-codegen 1.4.0",
|
||||||
"ethcore-ipc-nano 1.4.0",
|
"ethcore-ipc-nano 1.4.0",
|
||||||
|
"ethcore-network 1.5.0",
|
||||||
"ethcore-util 1.5.0",
|
"ethcore-util 1.5.0",
|
||||||
"ethjson 0.1.0",
|
"ethjson 0.1.0",
|
||||||
"ethkey 0.2.0",
|
"ethkey 0.2.0",
|
||||||
|
@ -41,6 +41,7 @@ ethcore-ipc-nano = { path = "../ipc/nano" }
|
|||||||
rlp = { path = "../util/rlp" }
|
rlp = { path = "../util/rlp" }
|
||||||
lru-cache = "0.1.0"
|
lru-cache = "0.1.0"
|
||||||
ethcore-bloom-journal = { path = "../util/bloom" }
|
ethcore-bloom-journal = { path = "../util/bloom" }
|
||||||
|
ethcore-network = { path = "../util/network" }
|
||||||
|
|
||||||
[dependencies.hyper]
|
[dependencies.hyper]
|
||||||
git = "https://github.com/ethcore/hyper"
|
git = "https://github.com/ethcore/hyper"
|
||||||
|
@ -1229,7 +1229,7 @@ impl BlockChainClient for Client {
|
|||||||
|
|
||||||
fn pruning_info(&self) -> PruningInfo {
|
fn pruning_info(&self) -> PruningInfo {
|
||||||
PruningInfo {
|
PruningInfo {
|
||||||
earliest_chain: self.chain.read().first_block().unwrap_or(1),
|
earliest_chain: self.chain.read().first_block_number().unwrap_or(1),
|
||||||
earliest_state: self.state_db.lock().journal_db().earliest_era().unwrap_or(0),
|
earliest_state: self.state_db.lock().journal_db().earliest_era().unwrap_or(0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -655,7 +655,7 @@ impl BlockChainClient for TestBlockChainClient {
|
|||||||
fn pruning_info(&self) -> PruningInfo {
|
fn pruning_info(&self) -> PruningInfo {
|
||||||
PruningInfo {
|
PruningInfo {
|
||||||
earliest_chain: 1,
|
earliest_chain: 1,
|
||||||
earlest_state: 1,
|
earliest_state: 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,7 @@ extern crate rlp;
|
|||||||
extern crate ethcore_bloom_journal as bloom_journal;
|
extern crate ethcore_bloom_journal as bloom_journal;
|
||||||
extern crate byteorder;
|
extern crate byteorder;
|
||||||
extern crate transient_hashmap;
|
extern crate transient_hashmap;
|
||||||
|
extern crate ethcore_network as network;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
@ -138,6 +139,7 @@ pub mod snapshot;
|
|||||||
pub mod action_params;
|
pub mod action_params;
|
||||||
pub mod db;
|
pub mod db;
|
||||||
pub mod verification;
|
pub mod verification;
|
||||||
|
pub mod light;
|
||||||
#[macro_use] pub mod evm;
|
#[macro_use] pub mod evm;
|
||||||
|
|
||||||
mod cache_manager;
|
mod cache_manager;
|
||||||
|
@ -19,21 +19,21 @@
|
|||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use ethcore::engines::Engine;
|
use engines::Engine;
|
||||||
use ethcore::ids::BlockID;
|
use ids::BlockID;
|
||||||
use ethcore::service::ClientIoMessage;
|
use service::ClientIoMessage;
|
||||||
use ethcore::block_import_error::BlockImportError;
|
use block_import_error::BlockImportError;
|
||||||
use ethcore::block_status::BlockStatus;
|
use block_status::BlockStatus;
|
||||||
use ethcore::verification::queue::{HeaderQueue, QueueInfo};
|
use verification::queue::{HeaderQueue, QueueInfo};
|
||||||
use ethcore::transaction::SignedTransaction;
|
use transaction::SignedTransaction;
|
||||||
use ethcore::blockchain_info::BlockChainInfo;
|
use blockchain_info::BlockChainInfo;
|
||||||
|
|
||||||
use io::IoChannel;
|
use io::IoChannel;
|
||||||
use util::hash::H256;
|
use util::hash::H256;
|
||||||
use util::{Bytes, Mutex};
|
use util::{Bytes, Mutex};
|
||||||
|
|
||||||
use provider::Provider;
|
use light::provider::Provider;
|
||||||
use request;
|
use light::request;
|
||||||
|
|
||||||
/// Light client implementation.
|
/// Light client implementation.
|
||||||
pub struct Client {
|
pub struct Client {
|
||||||
|
@ -34,7 +34,5 @@
|
|||||||
pub mod client;
|
pub mod client;
|
||||||
pub mod net;
|
pub mod net;
|
||||||
pub mod provider;
|
pub mod provider;
|
||||||
pub mod request;
|
|
||||||
|
|
||||||
#[macro_use]
|
pub use types::les_request as request;
|
||||||
extern crate log;
|
|
@ -23,7 +23,7 @@
|
|||||||
//! This module provides an interface for configuration of buffer
|
//! This module provides an interface for configuration of buffer
|
||||||
//! flow costs and recharge rates.
|
//! flow costs and recharge rates.
|
||||||
|
|
||||||
use request;
|
use light::request;
|
||||||
use super::packet;
|
use super::packet;
|
||||||
use super::error::Error;
|
use super::error::Error;
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ use util::RwLock;
|
|||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::sync::atomic::AtomicUsize;
|
use std::sync::atomic::AtomicUsize;
|
||||||
|
|
||||||
use provider::Provider;
|
use light::provider::Provider;
|
||||||
use request::{self, Request};
|
use light::request::{self, Request};
|
||||||
|
|
||||||
use self::buffer_flow::{Buffer, FlowParams};
|
use self::buffer_flow::{Buffer, FlowParams};
|
||||||
use self::error::{Error, Punishment};
|
use self::error::{Error, Punishment};
|
||||||
@ -287,11 +287,14 @@ impl LightProtocol {
|
|||||||
self.flow_params.recharge(&mut present_buffer);
|
self.flow_params.recharge(&mut present_buffer);
|
||||||
let req_id: u64 = try!(data.val_at(0));
|
let req_id: u64 = try!(data.val_at(0));
|
||||||
|
|
||||||
|
let block = {
|
||||||
|
let rlp = try!(data.at(1));
|
||||||
|
(try!(rlp.val_at(0)), try!(rlp.val_at(1)))
|
||||||
|
};
|
||||||
|
|
||||||
let req = request::Headers {
|
let req = request::Headers {
|
||||||
block: {
|
block_num: block.0,
|
||||||
let rlp = try!(data.at(1));
|
block_hash: block.1,
|
||||||
(try!(rlp.val_at(0)), try!(rlp.val_at(1)))
|
|
||||||
},
|
|
||||||
max: ::std::cmp::min(MAX_HEADERS, try!(data.val_at(2))),
|
max: ::std::cmp::min(MAX_HEADERS, try!(data.val_at(2))),
|
||||||
skip: try!(data.val_at(3)),
|
skip: try!(data.val_at(3)),
|
||||||
reverse: try!(data.val_at(4)),
|
reverse: try!(data.val_at(4)),
|
||||||
|
@ -17,14 +17,14 @@
|
|||||||
//! A provider for the LES protocol. This is typically a full node, who can
|
//! A provider for the LES protocol. This is typically a full node, who can
|
||||||
//! give as much data as necessary to its peers.
|
//! give as much data as necessary to its peers.
|
||||||
|
|
||||||
use ethcore::client::BlockChainClient;
|
use client::BlockChainClient;
|
||||||
use ethcore::transaction::SignedTransaction;
|
use transaction::SignedTransaction;
|
||||||
use ethcore::blockchain_info::BlockChainInfo;
|
use blockchain_info::BlockChainInfo;
|
||||||
|
|
||||||
use rlp::EMPTY_LIST_RLP;
|
use rlp::EMPTY_LIST_RLP;
|
||||||
use util::{Bytes, H256};
|
use util::{Bytes, H256};
|
||||||
|
|
||||||
use request;
|
use light::request;
|
||||||
|
|
||||||
/// Defines the operations that a provider for `LES` must fulfill.
|
/// Defines the operations that a provider for `LES` must fulfill.
|
||||||
///
|
///
|
||||||
@ -40,8 +40,8 @@ pub trait Provider: Send + Sync {
|
|||||||
fn reorg_depth(&self, a: &H256, b: &H256) -> Option<u64>;
|
fn reorg_depth(&self, a: &H256, b: &H256) -> Option<u64>;
|
||||||
|
|
||||||
/// Earliest block where state queries are available.
|
/// Earliest block where state queries are available.
|
||||||
/// All states between this value and
|
/// If `None`, no state queries are servable.
|
||||||
fn earliest_state(&self) -> u64;
|
fn earliest_state(&self) -> Option<u64>;
|
||||||
|
|
||||||
/// Provide a list of headers starting at the requested block,
|
/// Provide a list of headers starting at the requested block,
|
||||||
/// possibly in reverse and skipping `skip` at a time.
|
/// possibly in reverse and skipping `skip` at a time.
|
||||||
@ -83,11 +83,11 @@ impl<T: BlockChainClient + ?Sized> Provider for T {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn reorg_depth(&self, a: &H256, b: &H256) -> Option<u64> {
|
fn reorg_depth(&self, a: &H256, b: &H256) -> Option<u64> {
|
||||||
self.tree_route.map(|route| route.index as u64)
|
self.tree_route(a, b).map(|route| route.index as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn earliest_state(&self) -> u64 {
|
fn earliest_state(&self) -> Option<u64> {
|
||||||
self.pruning_info().earliest_state
|
Some(self.pruning_info().earliest_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block_headers(&self, req: request::Headers) -> Vec<Bytes> {
|
fn block_headers(&self, req: request::Headers) -> Vec<Bytes> {
|
||||||
@ -95,16 +95,18 @@ impl<T: BlockChainClient + ?Sized> Provider for T {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn block_bodies(&self, req: request::Bodies) -> Vec<Bytes> {
|
fn block_bodies(&self, req: request::Bodies) -> Vec<Bytes> {
|
||||||
|
use ids::BlockID;
|
||||||
|
|
||||||
req.block_hashes.into_iter()
|
req.block_hashes.into_iter()
|
||||||
.map(|hash| self.block_body(hash.into()))
|
.map(|hash| self.block_body(BlockID::Hash(hash)))
|
||||||
.map(|body| body.unwrap_or_else(|| EMPTY_LIST_RLP.into()))
|
.map(|body| body.unwrap_or_else(|| EMPTY_LIST_RLP.to_vec()))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn receipts(&self, req: request::Receipts) -> Vec<Bytes> {
|
fn receipts(&self, req: request::Receipts) -> Vec<Bytes> {
|
||||||
req.block_hashes.into_iter()
|
req.block_hashes.into_iter()
|
||||||
.map(|hash| self.block_receipts(&hash)
|
.map(|hash| self.block_receipts(&hash))
|
||||||
.map(|receipts| receips.unwrap_or_else(|| EMPTY_LIST_RLP.into()))
|
.map(|receipts| receipts.unwrap_or_else(|| EMPTY_LIST_RLP.to_vec()))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,12 +114,16 @@ impl<T: BlockChainClient + ?Sized> Provider for T {
|
|||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn code(&self, req: request::ContractCodes) -> Vec<Bytes>;
|
fn code(&self, req: request::ContractCodes) -> Vec<Bytes> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
fn header_proofs(&self, req: request::HeaderProofs) -> Vec<Bytes> {
|
fn header_proofs(&self, req: request::HeaderProofs) -> Vec<Bytes> {
|
||||||
// TODO: [rob] implement CHT stuff on `ethcore` side.
|
// TODO: [rob] implement CHT stuff on `ethcore` side.
|
||||||
req.requests.into_iter().map(|_| EMPTY_LIST_RLP.into()).collect()
|
req.requests.into_iter().map(|_| EMPTY_LIST_RLP.to_vec()).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pending_transactions(&self) -> Vec<SignedTransaction>;
|
fn pending_transactions(&self) -> Vec<SignedTransaction> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
}
|
}
|
@ -16,15 +16,16 @@
|
|||||||
|
|
||||||
//! LES request types.
|
//! LES request types.
|
||||||
|
|
||||||
// TODO: make IPC compatible.
|
|
||||||
|
|
||||||
use util::H256;
|
use util::H256;
|
||||||
|
|
||||||
/// A request for block headers.
|
/// A request for block headers.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, Binary)]
|
||||||
pub struct Headers {
|
pub struct Headers {
|
||||||
/// Block information for the request being made.
|
/// Starting block number
|
||||||
pub block: (u64, H256),
|
pub block_num: u64,
|
||||||
|
/// 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.
|
||||||
@ -34,7 +35,7 @@ pub struct Headers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A request for specific block bodies.
|
/// A request for specific block bodies.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, Binary)]
|
||||||
pub struct Bodies {
|
pub struct Bodies {
|
||||||
/// Hashes which bodies are being requested for.
|
/// Hashes which bodies are being requested for.
|
||||||
pub block_hashes: Vec<H256>
|
pub block_hashes: Vec<H256>
|
||||||
@ -44,14 +45,14 @@ pub struct Bodies {
|
|||||||
///
|
///
|
||||||
/// This request is answered with a list of transaction receipts for each block
|
/// This request is answered with a list of transaction receipts for each block
|
||||||
/// requested.
|
/// requested.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, Binary)]
|
||||||
pub struct Receipts {
|
pub struct Receipts {
|
||||||
/// Block hashes to return receipts for.
|
/// Block hashes to return receipts for.
|
||||||
pub block_hashes: Vec<H256>,
|
pub block_hashes: Vec<H256>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A request for a state proof
|
/// A request for a state proof
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, Binary)]
|
||||||
pub struct StateProof {
|
pub struct StateProof {
|
||||||
/// Block hash to query state from.
|
/// Block hash to query state from.
|
||||||
pub block: H256,
|
pub block: H256,
|
||||||
@ -65,21 +66,30 @@ pub struct StateProof {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A request for state proofs.
|
/// A request for state proofs.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, Binary)]
|
||||||
pub struct StateProofs {
|
pub struct StateProofs {
|
||||||
/// All the proof requests.
|
/// All the proof requests.
|
||||||
pub requests: Vec<StateProof>,
|
pub requests: Vec<StateProof>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A request for contract code.
|
/// A request for contract code.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, Binary)]
|
||||||
|
pub struct ContractCode {
|
||||||
|
/// Block hash
|
||||||
|
pub block_hash: H256,
|
||||||
|
/// Account key (== sha3(address))
|
||||||
|
pub account_key: H256,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A request for contract code.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Binary)]
|
||||||
pub struct ContractCodes {
|
pub struct ContractCodes {
|
||||||
/// Block hash and account key (== sha3(address)) pairs to fetch code for.
|
/// Block hash and account key (== sha3(address)) pairs to fetch code for.
|
||||||
pub code_requests: Vec<(H256, H256)>,
|
pub code_requests: Vec<ContractCode>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A request for a header proof from the Canonical Hash Trie.
|
/// A request for a header proof from the Canonical Hash Trie.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, Binary)]
|
||||||
pub struct HeaderProof {
|
pub struct HeaderProof {
|
||||||
/// Number of the CHT.
|
/// Number of the CHT.
|
||||||
pub cht_number: u64,
|
pub cht_number: u64,
|
||||||
@ -90,14 +100,14 @@ pub struct HeaderProof {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A request for header proofs from the CHT.
|
/// A request for header proofs from the CHT.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, Binary)]
|
||||||
pub struct HeaderProofs {
|
pub struct HeaderProofs {
|
||||||
/// All the proof requests.
|
/// All the proof requests.
|
||||||
pub requests: Vec<HeaderProofs>,
|
pub requests: Vec<HeaderProofs>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Kinds of requests.
|
/// Kinds of requests.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Binary)]
|
||||||
pub enum Kind {
|
pub enum Kind {
|
||||||
/// Requesting headers.
|
/// Requesting headers.
|
||||||
Headers,
|
Headers,
|
||||||
@ -114,7 +124,7 @@ pub enum Kind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Encompasses all possible types of requests in a single structure.
|
/// Encompasses all possible types of requests in a single structure.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, Binary)]
|
||||||
pub enum Request {
|
pub enum Request {
|
||||||
/// Requesting headers.
|
/// Requesting headers.
|
||||||
Headers(Headers),
|
Headers(Headers),
|
@ -34,3 +34,5 @@ pub mod block_import_error;
|
|||||||
pub mod restoration_status;
|
pub mod restoration_status;
|
||||||
pub mod snapshot_manifest;
|
pub mod snapshot_manifest;
|
||||||
pub mod mode;
|
pub mod mode;
|
||||||
|
pub mod pruning_info;
|
||||||
|
pub mod les_request;
|
@ -24,7 +24,7 @@
|
|||||||
#[derive(Debug, Clone, Binary)]
|
#[derive(Debug, Clone, Binary)]
|
||||||
pub struct PruningInfo {
|
pub struct PruningInfo {
|
||||||
/// The first block which everything can be served after.
|
/// The first block which everything can be served after.
|
||||||
pub earliest_chain: u64
|
pub earliest_chain: u64,
|
||||||
/// The first block where state requests may be served.
|
/// The first block where state requests may be served.
|
||||||
pub earliest_state: u64
|
pub earliest_state: u64,
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user