Move code to right module.

This commit is contained in:
Gav Wood 2016-03-19 22:37:11 +01:00
parent 7bba745f8b
commit 2cb1937e1e
2 changed files with 26 additions and 25 deletions

View File

@ -65,31 +65,6 @@ impl Substate {
}
}
impl TraceAction {
/// Compose a `TraceAction` from an `ActionParams`, knowing that the action is a call.
pub fn from_call(p: &ActionParams) -> 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![]),
result: None,
})
}
/// Compose a `TraceAction` from an `ActionParams`, knowing that the action is a create.
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![]),
result: None,
})
}
}
#[cfg(test)]
mod tests {
use super::*;

View File

@ -83,3 +83,29 @@ impl Default for Trace {
}
}
}
impl TraceAction {
/// Compose a `TraceAction` from an `ActionParams`, knowing that the action is a call.
pub fn from_call(p: &ActionParams) -> 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![]),
result: None,
})
}
/// Compose a `TraceAction` from an `ActionParams`, knowing that the action is a create.
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![]),
result: None,
})
}
}