From cb98cbcd4b13dca3db5ff88b7b63bfb48e80209c Mon Sep 17 00:00:00 2001 From: debris Date: Tue, 2 Feb 2016 15:55:44 +0100 Subject: [PATCH] ethcore public interface cleanup --- ethcore/src/evm/evm.rs | 1 + ethcore/src/evm/factory.rs | 7 +++++++ ethcore/src/executive.rs | 2 +- ethcore/src/lib.rs | 2 +- ethcore/src/log_entry.rs | 15 --------------- ethcore/src/transaction.rs | 25 ++++++------------------- 6 files changed, 16 insertions(+), 36 deletions(-) diff --git a/ethcore/src/evm/evm.rs b/ethcore/src/evm/evm.rs index b90ea5f97..b74cb3140 100644 --- a/ethcore/src/evm/evm.rs +++ b/ethcore/src/evm/evm.rs @@ -44,6 +44,7 @@ pub enum Error { }, /// Returned on evm internal error. Should never be ignored during development. /// Likely to cause consensus issues. + #[allow(dead_code)] // created only by jit Internal, } diff --git a/ethcore/src/evm/factory.rs b/ethcore/src/evm/factory.rs index cf78a9692..a113f7f4b 100644 --- a/ethcore/src/evm/factory.rs +++ b/ethcore/src/evm/factory.rs @@ -1,4 +1,6 @@ //! Evm factory. +//! +//! TODO: consider spliting it into two separate files. use std::fmt; use evm::Evm; @@ -6,6 +8,7 @@ use evm::Evm; /// TODO [Tomusdrw] Please document me pub enum VMType { /// TODO [Tomusdrw] Please document me + #[allow(dead_code)] // crated only by jit Jit, /// TODO [Tomusdrw] Please document me Interpreter @@ -20,6 +23,7 @@ impl fmt::Display for VMType { } } +#[cfg(test)] impl VMType { /// Return all possible VMs (JIT, Interpreter) #[cfg(feature="jit")] @@ -53,6 +57,7 @@ impl Factory { } /// Create new instance of specific `VMType` factory + #[cfg(test)] pub fn new(evm: VMType) -> Factory { Factory { evm: evm @@ -93,6 +98,7 @@ fn test_create_vm() { } /// Create tests by injecting different VM factories +#[macro_export] macro_rules! evm_test( ($name_test: ident: $name_jit: ident, $name_int: ident) => { #[test] @@ -108,6 +114,7 @@ macro_rules! evm_test( ); /// Create ignored tests by injecting different VM factories +#[macro_export] macro_rules! evm_test_ignore( ($name_test: ident: $name_jit: ident, $name_int: ident) => { #[test] diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index d824ccc2c..1471bdca3 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -129,7 +129,7 @@ impl<'a> Executive<'a> { let mut substate = Substate::new(); - let res = match *t.action() { + let res = match t.action { Action::Create => { let new_address = contract_address(&sender, &nonce); let params = ActionParams { diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index b4e7655a2..fcaabac55 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -86,7 +86,7 @@ pub mod views; mod common; mod basic_types; -mod evm; +#[macro_use] mod evm; mod log_entry; mod env_info; mod pod_account; diff --git a/ethcore/src/log_entry.rs b/ethcore/src/log_entry.rs index 8141549a3..165c6985e 100644 --- a/ethcore/src/log_entry.rs +++ b/ethcore/src/log_entry.rs @@ -31,21 +31,6 @@ impl LogEntry { } } - /// Returns reference to address. - pub fn address(&self) -> &Address { - &self.address - } - - /// Returns reference to topics. - pub fn topics(&self) -> &Vec { - &self.topics - } - - /// Returns reference to data. - pub fn data(&self) -> &Bytes { - &self.data - } - /// Calculates the bloom of this log entry. pub fn bloom(&self) -> LogBloom { self.topics.iter().fold(LogBloom::from_bloomed(&self.address.sha3()), |b, t| b.with_bloomed(&t.sha3())) diff --git a/ethcore/src/transaction.rs b/ethcore/src/transaction.rs index 18aa07c57..61c17a755 100644 --- a/ethcore/src/transaction.rs +++ b/ethcore/src/transaction.rs @@ -22,17 +22,17 @@ impl Default for Action { /// or contract creation operation. #[derive(Default, Debug, Clone)] pub struct Transaction { - /// TODO [debris] Please document me + /// Nonce. pub nonce: U256, - /// TODO [debris] Please document me + /// Gas price. pub gas_price: U256, - /// TODO [debris] Please document me + /// Gas paid up front for transaction execution. pub gas: U256, - /// TODO [debris] Please document me + /// Action, can be either call or contract create. pub action: Action, - /// TODO [debris] Please document me + /// Transfered value. pub value: U256, - /// TODO [Gav Wood] Please document me + /// Transaction data. pub data: Bytes, // signature @@ -98,19 +98,6 @@ impl Transaction { } } - /// Get the nonce of the transaction. - pub fn nonce(&self) -> &U256 { &self.nonce } - /// Get the gas price of the transaction. - pub fn gas_price(&self) -> &U256 { &self.gas_price } - /// Get the gas of the transaction. - pub fn gas(&self) -> &U256 { &self.gas } - /// Get the action of the transaction (Create or Call). - pub fn action(&self) -> &Action { &self.action } - /// Get the value of the transaction. - pub fn value(&self) -> &U256 { &self.value } - /// Get the data of the transaction. - pub fn data(&self) -> &Bytes { &self.data } - /// Append object into RLP stream, optionally with or without the signature. pub fn rlp_append_opt(&self, s: &mut RlpStream, with_seal: Seal) { s.begin_list(6 + match with_seal { Seal::With => 3, _ => 0 });