ethcore public interface cleanup

This commit is contained in:
debris 2016-02-02 15:55:44 +01:00
parent 30dc9d857d
commit cb98cbcd4b
6 changed files with 16 additions and 36 deletions

View File

@ -44,6 +44,7 @@ pub enum Error {
}, },
/// Returned on evm internal error. Should never be ignored during development. /// Returned on evm internal error. Should never be ignored during development.
/// Likely to cause consensus issues. /// Likely to cause consensus issues.
#[allow(dead_code)] // created only by jit
Internal, Internal,
} }

View File

@ -1,4 +1,6 @@
//! Evm factory. //! Evm factory.
//!
//! TODO: consider spliting it into two separate files.
use std::fmt; use std::fmt;
use evm::Evm; use evm::Evm;
@ -6,6 +8,7 @@ use evm::Evm;
/// TODO [Tomusdrw] Please document me /// TODO [Tomusdrw] Please document me
pub enum VMType { pub enum VMType {
/// TODO [Tomusdrw] Please document me /// TODO [Tomusdrw] Please document me
#[allow(dead_code)] // crated only by jit
Jit, Jit,
/// TODO [Tomusdrw] Please document me /// TODO [Tomusdrw] Please document me
Interpreter Interpreter
@ -20,6 +23,7 @@ impl fmt::Display for VMType {
} }
} }
#[cfg(test)]
impl VMType { impl VMType {
/// Return all possible VMs (JIT, Interpreter) /// Return all possible VMs (JIT, Interpreter)
#[cfg(feature="jit")] #[cfg(feature="jit")]
@ -53,6 +57,7 @@ impl Factory {
} }
/// Create new instance of specific `VMType` factory /// Create new instance of specific `VMType` factory
#[cfg(test)]
pub fn new(evm: VMType) -> Factory { pub fn new(evm: VMType) -> Factory {
Factory { Factory {
evm: evm evm: evm
@ -93,6 +98,7 @@ fn test_create_vm() {
} }
/// Create tests by injecting different VM factories /// Create tests by injecting different VM factories
#[macro_export]
macro_rules! evm_test( macro_rules! evm_test(
($name_test: ident: $name_jit: ident, $name_int: ident) => { ($name_test: ident: $name_jit: ident, $name_int: ident) => {
#[test] #[test]
@ -108,6 +114,7 @@ macro_rules! evm_test(
); );
/// Create ignored tests by injecting different VM factories /// Create ignored tests by injecting different VM factories
#[macro_export]
macro_rules! evm_test_ignore( macro_rules! evm_test_ignore(
($name_test: ident: $name_jit: ident, $name_int: ident) => { ($name_test: ident: $name_jit: ident, $name_int: ident) => {
#[test] #[test]

View File

@ -129,7 +129,7 @@ impl<'a> Executive<'a> {
let mut substate = Substate::new(); let mut substate = Substate::new();
let res = match *t.action() { let res = match t.action {
Action::Create => { Action::Create => {
let new_address = contract_address(&sender, &nonce); let new_address = contract_address(&sender, &nonce);
let params = ActionParams { let params = ActionParams {

View File

@ -86,7 +86,7 @@ pub mod views;
mod common; mod common;
mod basic_types; mod basic_types;
mod evm; #[macro_use] mod evm;
mod log_entry; mod log_entry;
mod env_info; mod env_info;
mod pod_account; mod pod_account;

View File

@ -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<H256> {
&self.topics
}
/// Returns reference to data.
pub fn data(&self) -> &Bytes {
&self.data
}
/// Calculates the bloom of this log entry. /// Calculates the bloom of this log entry.
pub fn bloom(&self) -> LogBloom { pub fn bloom(&self) -> LogBloom {
self.topics.iter().fold(LogBloom::from_bloomed(&self.address.sha3()), |b, t| b.with_bloomed(&t.sha3())) self.topics.iter().fold(LogBloom::from_bloomed(&self.address.sha3()), |b, t| b.with_bloomed(&t.sha3()))

View File

@ -22,17 +22,17 @@ impl Default for Action {
/// or contract creation operation. /// or contract creation operation.
#[derive(Default, Debug, Clone)] #[derive(Default, Debug, Clone)]
pub struct Transaction { pub struct Transaction {
/// TODO [debris] Please document me /// Nonce.
pub nonce: U256, pub nonce: U256,
/// TODO [debris] Please document me /// Gas price.
pub gas_price: U256, pub gas_price: U256,
/// TODO [debris] Please document me /// Gas paid up front for transaction execution.
pub gas: U256, pub gas: U256,
/// TODO [debris] Please document me /// Action, can be either call or contract create.
pub action: Action, pub action: Action,
/// TODO [debris] Please document me /// Transfered value.
pub value: U256, pub value: U256,
/// TODO [Gav Wood] Please document me /// Transaction data.
pub data: Bytes, pub data: Bytes,
// signature // 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. /// Append object into RLP stream, optionally with or without the signature.
pub fn rlp_append_opt(&self, s: &mut RlpStream, with_seal: Seal) { pub fn rlp_append_opt(&self, s: &mut RlpStream, with_seal: Seal) {
s.begin_list(6 + match with_seal { Seal::With => 3, _ => 0 }); s.begin_list(6 + match with_seal { Seal::With => 3, _ => 0 });