light client sync stubs
This commit is contained in:
parent
ed06572bd4
commit
8d7244c09f
@ -39,57 +39,33 @@ pub struct Client {
|
|||||||
engine: Arc<Engine>,
|
engine: Arc<Engine>,
|
||||||
header_queue: HeaderQueue,
|
header_queue: HeaderQueue,
|
||||||
message_channel: IoChannel<ClientIoMessage>,
|
message_channel: IoChannel<ClientIoMessage>,
|
||||||
transaction_queue: TransactionQueue,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Client {
|
impl Client {
|
||||||
/// Import a header as rlp-encoded bytes.
|
/// Import a header as rlp-encoded bytes.
|
||||||
fn import_header(&self, bytes: Bytes) -> Result<H256, BlockImportError> {
|
pub fn import_header(&self, bytes: Bytes) -> Result<H256, BlockImportError> {
|
||||||
let header = ::rlp::decode(&bytes);
|
let header = ::rlp::decode(&bytes);
|
||||||
|
|
||||||
self.header_queue.import(header).map_err(Into::into)
|
self.header_queue.import(header).map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the block is already known (but not necessarily part of the canonical chain)
|
/// Whether the block is already known (but not necessarily part of the canonical chain)
|
||||||
fn is_known(&self, id: BlockID) -> bool {
|
pub fn is_known(&self, id: BlockID) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fetch a vector of all pending transactions.
|
/// Fetch a vector of all pending transactions.
|
||||||
fn pending_transactions(&self) -> Vec<SignedTransaction> {
|
pub fn pending_transactions(&self) -> Vec<SignedTransaction> {
|
||||||
self.transaction_queue.top_transactions()
|
vec![]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inquire about the status of a given block.
|
/// Inquire about the status of a given block.
|
||||||
fn status(&self, id: BlockID) -> BlockStatus {
|
pub fn status(&self, id: BlockID) -> BlockStatus {
|
||||||
BlockStatus::Unknown
|
BlockStatus::Unknown
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// stub implementation, can be partially implemented using LRU-caches
|
/// Get the header queue info.
|
||||||
// but will almost definitely never be able to provide complete responses.
|
pub fn queue_info(&self) -> QueueInfo {
|
||||||
impl Provider for Client {
|
self.header_queue.queue_info()
|
||||||
fn block_headers(&self, _block: H256, _skip: usize, _max: usize, _reverse: bool) -> Vec<Bytes> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn block_bodies(&self, _blocks: Vec<H256>) -> Vec<Bytes> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn receipts(&self, _blocks: Vec<H256>) -> Vec<Bytes> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn proofs(&self, _requests: Vec<(H256, ProofRequest)>) -> Vec<Bytes> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn code(&self, _accounts: Vec<(H256, H256)>) -> Vec<Bytes> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn header_proofs(&self, _requests: Vec<CHTProofRequest>) -> Vec<Bytes> {
|
|
||||||
vec![]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,4 +15,5 @@
|
|||||||
mod provider;
|
mod provider;
|
||||||
mod client;
|
mod client;
|
||||||
|
|
||||||
|
pub use self::client::Client;
|
||||||
pub use self::provider::{CHTProofRequest, ProofRequest, Provider};
|
pub use self::provider::{CHTProofRequest, ProofRequest, Provider};
|
||||||
|
@ -50,6 +50,7 @@ mod chain;
|
|||||||
mod blocks;
|
mod blocks;
|
||||||
mod sync_io;
|
mod sync_io;
|
||||||
mod snapshot;
|
mod snapshot;
|
||||||
|
mod light;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
27
sync/src/light/mod.rs
Normal file
27
sync/src/light/mod.rs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// 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/>.
|
||||||
|
|
||||||
|
//! LES Protocol Version 1 implementation.
|
||||||
|
//!
|
||||||
|
//! This uses a "Provider" to answer requests.
|
||||||
|
|
||||||
|
use ethcore::light::{Client, Provider};
|
||||||
|
|
||||||
|
/// This handles synchronization of the header chain for a light client.
|
||||||
|
pub struct Chain {
|
||||||
|
client: Client,
|
||||||
|
peers: Vec<Peer>,
|
||||||
|
}
|
@ -18,7 +18,7 @@ use network::{NetworkContext, PeerId, PacketId, NetworkError};
|
|||||||
use ethcore::client::BlockChainClient;
|
use ethcore::client::BlockChainClient;
|
||||||
use ethcore::snapshot::SnapshotService;
|
use ethcore::snapshot::SnapshotService;
|
||||||
|
|
||||||
/// IO interface for the syning handler.
|
/// IO interface for the syncing handler.
|
||||||
/// Provides peer connection management and an interface to the blockchain client.
|
/// Provides peer connection management and an interface to the blockchain client.
|
||||||
// TODO: ratings
|
// TODO: ratings
|
||||||
pub trait SyncIo {
|
pub trait SyncIo {
|
||||||
@ -38,7 +38,7 @@ pub trait SyncIo {
|
|||||||
fn peer_info(&self, peer_id: PeerId) -> String {
|
fn peer_info(&self, peer_id: PeerId) -> String {
|
||||||
peer_id.to_string()
|
peer_id.to_string()
|
||||||
}
|
}
|
||||||
/// Maximum mutuallt supported ETH protocol version
|
/// Maximum mutually supported ETH protocol version
|
||||||
fn eth_protocol_version(&self, peer_id: PeerId) -> u8;
|
fn eth_protocol_version(&self, peer_id: PeerId) -> u8;
|
||||||
/// Returns if the chain block queue empty
|
/// Returns if the chain block queue empty
|
||||||
fn is_chain_queue_empty(&self) -> bool {
|
fn is_chain_queue_empty(&self) -> bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user