stub implementation of provider for client

This commit is contained in:
Robert Habermeier 2016-10-27 15:09:17 +02:00
parent 4b82392371
commit a7e420d9ec
4 changed files with 57 additions and 3 deletions

View File

@ -136,6 +136,7 @@ pub mod miner;
pub mod snapshot;
pub mod action_params;
pub mod db;
pub mod light;
#[macro_use] pub mod evm;
mod cache_manager;

View File

@ -34,7 +34,7 @@ use io::IoChannel;
use util::hash::H256;
use util::Bytes;
/// A light client.
/// Light client implementation.
pub struct Client {
engine: Arc<Engine>,
header_queue: HeaderQueue,
@ -68,4 +68,34 @@ impl Client {
pub fn queue_info(&self) -> QueueInfo {
self.header_queue.queue_info()
}
}
impl Provider for Client {
fn block_headers(&self, block: H256, skip: usize, max: usize, reverse: bool) -> Vec<Bytes> {
Vec::new()
}
fn block_bodies(&self, blocks: Vec<H256>) -> Vec<Bytes> {
Vec::new()
}
fn receipts(&self, blocks: Vec<H256>) -> Vec<Bytes> {
Vec::new()
}
fn proofs(&self, requests: Vec<(H256, ProofRequest)>) -> Vec<Bytes> {
Vec::new()
}
fn code(&self, accounts: Vec<(H256, H256)>) -> Vec<Bytes> {
Vec::new()
}
fn header_proofs(&self, requests: Vec<CHTProofRequest>) -> Vec<Bytes> {
Vec::new()
}
fn pending_transactions(&self) -> Vec<SignedTransaction> {
Vec::new()
}
}

View File

@ -1,3 +1,19 @@
// 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
@ -12,8 +28,9 @@
//! It starts by performing a header-only sync, verifying every header in
//! the chain.
mod provider;
mod client;
mod provider;
mod sync;
pub use self::client::Client;
pub use self::provider::{CHTProofRequest, ProofRequest, Provider};
pub use self::provider::{CHTProofRequest, ProofRequest, Provider};

View File

@ -19,12 +19,15 @@
pub use proof_request::{CHTProofRequest, ProofRequest};
use transaction::SignedTransaction;
use util::Bytes;
use util::hash::H256;
/// Defines the operations that a provider for `LES` must fulfill.
///
/// These are defined at [1], but may be subject to change.
/// Requests which can't be fulfilled should return an empty RLP list.
///
/// [1]: https://github.com/ethcore/parity/wiki/Light-Ethereum-Subprotocol-(LES)
pub trait Provider {
@ -54,4 +57,7 @@ pub trait Provider {
/// Provide header proofs from the Canonical Hash Tries.
fn header_proofs(&self, requests: Vec<CHTProofRequest>) -> Vec<Bytes>;
/// Provide pending transactions.
fn pending_transactions(&self) -> Vec<SignedTransaction>;
}