Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
use common BasicAccount type
Browse files Browse the repository at this point in the history
  • Loading branch information
rphmeier committed Jan 5, 2017
1 parent 8446a83 commit 75b5acf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
23 changes: 5 additions & 18 deletions ethcore/light/src/on_demand/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use std::collections::HashMap;

use ethcore::basic_account::BasicAccount;
use ethcore::encoded;
use ethcore::receipt::Receipt;

Expand All @@ -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 {
Expand Down Expand Up @@ -94,7 +81,7 @@ enum Pending {
HeaderByHash(request::HeaderByHash, Sender<encoded::Header>),
Block(request::Body, Sender<encoded::Block>),
BlockReceipts(request::BlockReceipts, Sender<Vec<Receipt>>),
Account(request::Account, Sender<Account>),
Account(request::Account, Sender<BasicAccount>),
}

/// On demand request service. See module docs for more details.
Expand Down Expand Up @@ -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<Account> {
pub fn account(&self, ctx: &BasicContext, req: request::Account) -> Response<BasicAccount> {
let (sender, receiver) = oneshot::channel();
self.dispatch_account(ctx, req, sender);
Response(receiver)
}

fn dispatch_account(&self, ctx: &BasicContext, req: request::Account, sender: Sender<Account>) {
fn dispatch_account(&self, ctx: &BasicContext, req: request::Account, sender: Sender<BasicAccount>) {
let num = req.header.number();
let les_req = LesRequest::StateProofs(les_request::StateProofs {
requests: vec![les_request::StateProof {
Expand Down
3 changes: 1 addition & 2 deletions ethcore/light/src/on_demand/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

//! Request types, verification, and verification errors.
use ethcore::basic_account::BasicAccount;
use ethcore::encoded;
use ethcore::receipt::Receipt;

Expand All @@ -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 {
Expand Down

0 comments on commit 75b5acf

Please sign in to comment.