Merge pull request #862 from ethcore/trace_styles

simplified trace from functions, removed clippy warnings
This commit is contained in:
Marek Kotewicz 2016-04-01 11:49:05 +02:00
commit 7f1a1b7b96
2 changed files with 15 additions and 6 deletions

View File

@ -27,6 +27,15 @@ pub enum ActionValue {
Apparent(U256)
}
impl ActionValue {
/// Returns action value as U256.
pub fn value(&self) -> U256 {
match *self {
ActionValue::Transfer(x) | ActionValue::Apparent(x) => x
}
}
}
// TODO: should be a trait, possible to avoid cloning everything from a Transaction(/View).
/// Action (call/create) input params. Everything else should be specified in Externalities.
#[derive(Clone, Debug)]

View File

@ -90,9 +90,9 @@ impl TraceAction {
TraceAction::Call(TraceCall {
from: p.sender.clone(),
to: p.address.clone(),
value: match p.value { ActionValue::Transfer(ref x) | ActionValue::Apparent(ref x) => x.clone() },
gas: p.gas.clone(),
input: p.data.clone().unwrap_or(vec![]),
value: p.value.value(),
gas: p.gas,
input: p.data.clone().unwrap_or_else(Vec::new),
result: None,
})
}
@ -101,9 +101,9 @@ impl TraceAction {
pub fn from_create(p: &ActionParams) -> TraceAction {
TraceAction::Create(TraceCreate {
from: p.sender.clone(),
value: match p.value { ActionValue::Transfer(ref x) | ActionValue::Apparent(ref x) => x.clone() },
gas: p.gas.clone(),
init: p.code.clone().unwrap_or(vec![]),
value: p.value.value(),
gas: p.gas,
init: p.code.clone().unwrap_or_else(Vec::new),
result: None,
})
}