resolved remaining issues & error binary serialization

This commit is contained in:
Nikolay Volf 2016-05-15 00:51:02 +03:00
parent 2d992d0c29
commit 483687b6bf
7 changed files with 27 additions and 9 deletions

View File

@ -61,7 +61,7 @@ pub struct Executed {
} }
/// Result of executing the transaction. /// Result of executing the transaction.
#[derive(PartialEq, Debug)] #[derive(PartialEq, Debug, Binary)]
pub enum ExecutionError { pub enum ExecutionError {
/// Returned when there gas paid for transaction execution is /// Returned when there gas paid for transaction execution is
/// lower than base gas required. /// lower than base gas required.

View File

@ -28,6 +28,7 @@ use log_entry::{LogEntry, LocalizedLogEntry};
use ipc::binary::BinaryConvertError; use ipc::binary::BinaryConvertError;
use std::mem; use std::mem;
use std::collections::VecDeque; use std::collections::VecDeque;
use rustc_serialize::hex::FromHex;
/// Information describing execution of a transaction. /// Information describing execution of a transaction.
#[derive(Default, Debug, Clone, Binary)] #[derive(Default, Debug, Clone, Binary)]

View File

@ -29,6 +29,8 @@ use ethjson;
use ipc::binary::BinaryConvertError; use ipc::binary::BinaryConvertError;
use std::mem; use std::mem;
use std::collections::VecDeque; use std::collections::VecDeque;
use rustc_serialize::hex::FromHex;
use util::crypto::KeyPair;
#[derive(Debug, Clone, PartialEq, Eq, Binary)] #[derive(Debug, Clone, PartialEq, Eq, Binary)]
/// Transaction action type. /// Transaction action type.

View File

@ -382,6 +382,8 @@ fn fields_sequence(
use syntax::parse::token; use syntax::parse::token;
use syntax::ast::TokenTree::Token; use syntax::ast::TokenTree::Token;
let named_members = fields.iter().any(|f| f.ident.is_some());
::quasi::parse_expr_panic(&mut ::syntax::parse::new_parser_from_tts( ::quasi::parse_expr_panic(&mut ::syntax::parse::new_parser_from_tts(
ext_cx.parse_sess(), ext_cx.parse_sess(),
ext_cx.cfg(), ext_cx.cfg(),
@ -389,7 +391,12 @@ fn fields_sequence(
let _sp = ext_cx.call_site(); let _sp = ext_cx.call_site();
let mut tt = ::std::vec::Vec::new(); let mut tt = ::std::vec::Vec::new();
tt.push(Token(_sp, token::Ident(variant_ident.clone()))); tt.push(Token(_sp, token::Ident(variant_ident.clone())));
tt.push(Token(_sp, token::OpenDelim(token::Paren))); if named_members {
tt.push(Token(_sp, token::OpenDelim(token::Brace)));
}
else {
tt.push(Token(_sp, token::OpenDelim(token::Paren)));
}
for (idx, field) in fields.iter().enumerate() { for (idx, field) in fields.iter().enumerate() {
if field.ident.is_some() { if field.ident.is_some() {
@ -450,8 +457,12 @@ fn fields_sequence(
tt.push(Token(_sp, token::CloseDelim(token::Paren))); tt.push(Token(_sp, token::CloseDelim(token::Paren)));
tt.push(Token(_sp, token::Comma)); tt.push(Token(_sp, token::Comma));
} }
tt.push(Token(_sp, token::CloseDelim(token::Paren))); if named_members {
tt.push(Token(_sp, token::CloseDelim(token::Brace)));
}
else {
tt.push(Token(_sp, token::CloseDelim(token::Paren)));
}
tt tt
}) })
).unwrap() ).unwrap()
@ -620,7 +631,6 @@ fn binary_expr_variant(
.map(|(id, field)|(field.ident.unwrap(), builder.pat().ref_id(id)))) .map(|(id, field)|(field.ident.unwrap(), builder.pat().ref_id(id))))
.build(); .build();
let binary_expr = try!(binary_expr_struct( let binary_expr = try!(binary_expr_struct(
cx, cx,
&builder, &builder,
@ -640,7 +650,7 @@ fn binary_expr_variant(
let buffer = &mut buffer[1..]; let buffer = &mut buffer[1..];
$write_expr $write_expr
}), }),
read: quote_arm!(cx, $pat => { $read_expr } ), read: quote_arm!(cx, $variant_index_ident => { $read_expr } ),
}) })
}, },
} }

View File

@ -17,7 +17,7 @@
//! Binary representation of types //! Binary representation of types
use util::bytes::Populatable; use util::bytes::Populatable;
use util::numbers::{U256, H256, H2048, Address}; use util::numbers::{U256, U512, H256, H2048, Address};
use std::mem; use std::mem;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::ops::Range; use std::ops::Range;
@ -422,6 +422,7 @@ binary_fixed_size!(usize);
binary_fixed_size!(i32); binary_fixed_size!(i32);
binary_fixed_size!(bool); binary_fixed_size!(bool);
binary_fixed_size!(U256); binary_fixed_size!(U256);
binary_fixed_size!(U512);
binary_fixed_size!(H256); binary_fixed_size!(H256);
binary_fixed_size!(H2048); binary_fixed_size!(H2048);
binary_fixed_size!(Address); binary_fixed_size!(Address);

View File

@ -36,3 +36,9 @@ pub struct DoubleRoot {
pub struct ReferenceStruct<'a> { pub struct ReferenceStruct<'a> {
pub ref_data: &'a u64, pub ref_data: &'a u64,
} }
#[derive(Binary, PartialEq, Debug)]
pub enum EnumWithStruct {
Left,
Right { how_much: u64 },
}

View File

@ -16,9 +16,7 @@
#![allow(dead_code)] #![allow(dead_code)]
extern crate bincode;
extern crate ethcore_ipc as ipc; extern crate ethcore_ipc as ipc;
extern crate serde;
extern crate ethcore_devtools as devtools; extern crate ethcore_devtools as devtools;
extern crate semver; extern crate semver;
extern crate nanomsg; extern crate nanomsg;