From 75b5acf21dff78fe03aaec71bca6748bcc87bffe Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Thu, 5 Jan 2017 13:26:14 +0100 Subject: [PATCH] use common BasicAccount type --- ethcore/light/src/on_demand/mod.rs | 23 +++++------------------ ethcore/light/src/on_demand/request.rs | 3 +-- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/ethcore/light/src/on_demand/mod.rs b/ethcore/light/src/on_demand/mod.rs index 218a866a3..aadb43c0e 100644 --- a/ethcore/light/src/on_demand/mod.rs +++ b/ethcore/light/src/on_demand/mod.rs @@ -20,6 +20,7 @@ use std::collections::HashMap; +use ethcore::basic_account::BasicAccount; use ethcore::encoded; use ethcore::receipt::Receipt; @@ -28,25 +29,11 @@ use futures::sync::oneshot; use network::PeerId; use net::{Handler, Status, Capabilities, Announcement, EventContext, BasicContext, ReqId}; -use util::{Bytes, H256, U256, RwLock}; +use util::{Bytes, RwLock}; use types::les_request::{self as les_request, Request as LesRequest}; pub mod request; -/// Basic account data. -// TODO: [rob] unify with similar struct in `snapshot`. -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct Account { - /// Balance in Wei - pub balance: U256, - /// Storage trie root. - pub storage_root: H256, - /// Code hash - pub code_hash: H256, - /// Nonce - pub nonce: U256, -} - /// Errors which can occur while trying to fulfill a request. #[derive(Debug, Clone, Copy, PartialEq)] pub enum Error { @@ -94,7 +81,7 @@ enum Pending { HeaderByHash(request::HeaderByHash, Sender), Block(request::Body, Sender), BlockReceipts(request::BlockReceipts, Sender>), - Account(request::Account, Sender), + Account(request::Account, Sender), } /// On demand request service. See module docs for more details. @@ -283,13 +270,13 @@ impl OnDemand { /// Request an account by address and block header -- which gives a hash to query and a state root /// to verify against. - pub fn account(&self, ctx: &BasicContext, req: request::Account) -> Response { + pub fn account(&self, ctx: &BasicContext, req: request::Account) -> Response { let (sender, receiver) = oneshot::channel(); self.dispatch_account(ctx, req, sender); Response(receiver) } - fn dispatch_account(&self, ctx: &BasicContext, req: request::Account, sender: Sender) { + fn dispatch_account(&self, ctx: &BasicContext, req: request::Account, sender: Sender) { let num = req.header.number(); let les_req = LesRequest::StateProofs(les_request::StateProofs { requests: vec![les_request::StateProof { diff --git a/ethcore/light/src/on_demand/request.rs b/ethcore/light/src/on_demand/request.rs index 52383e721..f483c6fdd 100644 --- a/ethcore/light/src/on_demand/request.rs +++ b/ethcore/light/src/on_demand/request.rs @@ -16,6 +16,7 @@ //! Request types, verification, and verification errors. +use ethcore::basic_account::BasicAccount; use ethcore::encoded; use ethcore::receipt::Receipt; @@ -25,8 +26,6 @@ use util::memorydb::MemoryDB; use util::sha3::Hashable; use util::trie::{Trie, TrieDB, TrieError}; -use super::Account as BasicAccount; - /// Errors in verification. #[derive(Debug, PartialEq)] pub enum Error {