This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* stub implementations of light client trait * Light provider trait * light client sync stubs * LES boilerplate * stub implementation of provider for client * skeleton and request traits * request definitions * new_list -> begin_list * handle unknown packet * revise light implementation strategy * make verification module public * Move all light client work to own crate * experiment with answering requests * buffer flow scaffolding * remove LESv2 requests * buffer flow basics, implement cost table * begin status module * implement handshake parsing and creation * implement announcement serialization * errors, punishment, and handshake * handle announcements * making announcements, clean up warnings * allow dead code temporarily
- Loading branch information
Showing
18 changed files
with
1,821 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
description = "Parity LES primitives" | ||
homepage = "https://ethcore.io" | ||
license = "GPL-3.0" | ||
name = "ethcore-light" | ||
version = "1.5.0" | ||
authors = ["Ethcore <admin@ethcore.io>"] | ||
|
||
[dependencies] | ||
log = "0.3" | ||
ethcore = { path = ".." } | ||
ethcore-util = { path = "../../util" } | ||
ethcore-network = { path = "../../util/network" } | ||
ethcore-io = { path = "../../util/io" } | ||
rlp = { path = "../../util/rlp" } | ||
time = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// Copyright 2015, 2016 Ethcore (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! Light client implementation. Used for raw data queries as well as the header | ||
//! sync. | ||
use std::sync::Arc; | ||
|
||
use ethcore::engines::Engine; | ||
use ethcore::ids::BlockID; | ||
use ethcore::service::ClientIoMessage; | ||
use ethcore::block_import_error::BlockImportError; | ||
use ethcore::block_status::BlockStatus; | ||
use ethcore::verification::queue::{HeaderQueue, QueueInfo}; | ||
use ethcore::transaction::SignedTransaction; | ||
use ethcore::blockchain_info::BlockChainInfo; | ||
|
||
use io::IoChannel; | ||
use util::hash::H256; | ||
use util::{Bytes, Mutex}; | ||
|
||
use provider::Provider; | ||
use request; | ||
|
||
/// Light client implementation. | ||
pub struct Client { | ||
engine: Arc<Engine>, | ||
header_queue: HeaderQueue, | ||
message_channel: Mutex<IoChannel<ClientIoMessage>>, | ||
} | ||
|
||
impl Client { | ||
/// Import a header as rlp-encoded bytes. | ||
pub fn import_header(&self, bytes: Bytes) -> Result<H256, BlockImportError> { | ||
let header = ::rlp::decode(&bytes); | ||
|
||
self.header_queue.import(header).map_err(Into::into) | ||
} | ||
|
||
/// Whether the block is already known (but not necessarily part of the canonical chain) | ||
pub fn is_known(&self, _id: BlockID) -> bool { | ||
false | ||
} | ||
|
||
/// Fetch a vector of all pending transactions. | ||
pub fn pending_transactions(&self) -> Vec<SignedTransaction> { | ||
vec![] | ||
} | ||
|
||
/// Inquire about the status of a given block. | ||
pub fn status(&self, _id: BlockID) -> BlockStatus { | ||
BlockStatus::Unknown | ||
} | ||
|
||
/// Get the header queue info. | ||
pub fn queue_info(&self) -> QueueInfo { | ||
self.header_queue.queue_info() | ||
} | ||
} | ||
|
||
// dummy implementation -- may draw from canonical cache further on. | ||
impl Provider for Client { | ||
fn chain_info(&self) -> BlockChainInfo { | ||
unimplemented!() | ||
} | ||
|
||
fn reorg_depth(&self, _a: &H256, _b: &H256) -> Option<u64> { | ||
None | ||
} | ||
|
||
fn earliest_state(&self) -> Option<u64> { | ||
None | ||
} | ||
|
||
fn block_headers(&self, _req: request::Headers) -> Vec<Bytes> { | ||
Vec::new() | ||
} | ||
|
||
fn block_bodies(&self, _req: request::Bodies) -> Vec<Bytes> { | ||
Vec::new() | ||
} | ||
|
||
fn receipts(&self, _req: request::Receipts) -> Vec<Bytes> { | ||
Vec::new() | ||
} | ||
|
||
fn proofs(&self, _req: request::StateProofs) -> Vec<Bytes> { | ||
Vec::new() | ||
} | ||
|
||
fn code(&self, _req: request::ContractCodes) -> Vec<Bytes> { | ||
Vec::new() | ||
} | ||
|
||
fn header_proofs(&self, _req: request::HeaderProofs) -> Vec<Bytes> { | ||
Vec::new() | ||
} | ||
|
||
fn pending_transactions(&self) -> Vec<SignedTransaction> { | ||
Vec::new() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2015, 2016 Ethcore (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! Light client logic and implementation. | ||
//! | ||
//! A "light" client stores very little chain-related data locally | ||
//! unlike a full node, which stores all blocks, headers, receipts, and more. | ||
//! | ||
//! This enables the client to have a much lower resource footprint in | ||
//! exchange for the cost of having to ask the network for state data | ||
//! while responding to queries. This makes a light client unsuitable for | ||
//! low-latency applications, but perfectly suitable for simple everyday | ||
//! use-cases like sending transactions from a personal account. | ||
//! | ||
//! It starts by performing a header-only sync, verifying random samples | ||
//! of members of the chain to varying degrees. | ||
// TODO: remove when integrating with parity. | ||
#![allow(dead_code)] | ||
|
||
pub mod client; | ||
pub mod net; | ||
pub mod provider; | ||
pub mod request; | ||
|
||
extern crate ethcore_util as util; | ||
extern crate ethcore_network as network; | ||
extern crate ethcore_io as io; | ||
extern crate ethcore; | ||
extern crate rlp; | ||
extern crate time; | ||
|
||
#[macro_use] | ||
extern crate log; |
Oops, something went wrong.