From 562e591ed39e977c51cd0fa0517e0c2e7b6aeb9d Mon Sep 17 00:00:00 2001 From: NikVolf Date: Wed, 29 Jun 2016 20:59:13 +0300 Subject: [PATCH] more missing serializaers --- ethcore/src/client/client.rs.in | 6 +++--- ethcore/src/types/account_diff.rs | 11 ++++++++++- ethcore/src/types/ids.rs | 11 ++++++----- ethcore/src/types/state_diff.rs | 7 ++++++- ethcore/src/types/tree_route.rs | 5 ++++- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/ethcore/src/client/client.rs.in b/ethcore/src/client/client.rs.in index 2a26bbd59..ddd401835 100644 --- a/ethcore/src/client/client.rs.in +++ b/ethcore/src/client/client.rs.in @@ -477,7 +477,7 @@ impl Client { } } -#[derive(Ipc)] +//#[derive(Ipc)] impl BlockChainClient for Client { fn call(&self, t: &SignedTransaction, analytics: CallAnalytics) -> Result { let header = self.block_header(BlockID::Latest).unwrap(); @@ -577,8 +577,8 @@ impl BlockChainClient for Client { } fn uncle(&self, id: UncleID) -> Option
{ - let index = id.1; - self.block(id.0).and_then(|block| BlockView::new(&block).uncle_at(index)) + let index = id.position; + self.block(id.block).and_then(|block| BlockView::new(&block).uncle_at(index)) } fn transaction_receipt(&self, id: TransactionID) -> Option { diff --git a/ethcore/src/types/account_diff.rs b/ethcore/src/types/account_diff.rs index abcac9a8b..5071c2f7e 100644 --- a/ethcore/src/types/account_diff.rs +++ b/ethcore/src/types/account_diff.rs @@ -16,8 +16,13 @@ //! Diff between two accounts. -use util::*; +use util::numbers::*; +use std::cmp::*; +use std::fmt; use ipc::binary::{BinaryConvertError, BinaryConvertable}; +use util::Bytes; +use std::collections::{VecDeque, BTreeMap}; +use std::mem; #[derive(Debug, PartialEq, Eq, Clone, Binary)] /// Diff type for specifying a change (or not). @@ -95,6 +100,8 @@ impl AccountDiff { // TODO: refactor into something nicer. fn interpreted_hash(u: &H256) -> String { + use util::bytes::*; + if u <= &H256::from(0xffffffff) { format!("{} = 0x{:x}", U256::from(u.as_slice()).low_u32(), U256::from(u.as_slice()).low_u32()) } else if u <= &H256::from(u64::max_value()) { @@ -108,6 +115,8 @@ fn interpreted_hash(u: &H256) -> String { impl fmt::Display for AccountDiff { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use util::bytes::*; + match self.nonce { Diff::Born(ref x) => try!(write!(f, " non {}", x)), Diff::Changed(ref pre, ref post) => try!(write!(f, "#{} ({} {} {})", post, pre, if pre > post {"-"} else {"+"}, *max(pre, post) - * min(pre, post))), diff --git a/ethcore/src/types/ids.rs b/ethcore/src/types/ids.rs index 0a492735c..c08ab4116 100644 --- a/ethcore/src/types/ids.rs +++ b/ethcore/src/types/ids.rs @@ -47,6 +47,7 @@ pub enum TransactionID { } /// Uniquely identifies Trace. +#[derive(Binary)] pub struct TraceId { /// Transaction pub transaction: TransactionID, @@ -55,10 +56,10 @@ pub struct TraceId { } /// Uniquely identifies Uncle. -#[derive(Debug)] -pub struct UncleID ( +#[derive(Debug, Binary)] +pub struct UncleID { /// Block id. - pub BlockID, + pub block: BlockID, /// Position in block. - pub usize -); + pub position: usize +} diff --git a/ethcore/src/types/state_diff.rs b/ethcore/src/types/state_diff.rs index f61a55b01..e341b8436 100644 --- a/ethcore/src/types/state_diff.rs +++ b/ethcore/src/types/state_diff.rs @@ -16,8 +16,13 @@ //! State diff module. -use util::*; +use util::numbers::*; use account_diff::*; +use ipc::binary::BinaryConvertError; +use std::mem; +use std::fmt; +use std::ops::*; +use std::collections::{VecDeque, BTreeMap}; #[derive(Debug, PartialEq, Eq, Clone, Binary)] /// Expression for the delta between two system states. Encoded the diff --git a/ethcore/src/types/tree_route.rs b/ethcore/src/types/tree_route.rs index 2ad0aa240..37413be57 100644 --- a/ethcore/src/types/tree_route.rs +++ b/ethcore/src/types/tree_route.rs @@ -17,9 +17,12 @@ //! Tree route info type definition use util::numbers::H256; +use ipc::BinaryConvertError; +use std::collections::VecDeque; +use std::mem; /// Represents a tree route between `from` block and `to` block: -#[derive(Debug)] +#[derive(Debug, Binary)] pub struct TreeRoute { /// A vector of hashes of all blocks, ordered from `from` to `to`. pub blocks: Vec,