cfx_executor/stack/resources.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
use crate::{
executive_observer::TracerTrait, stack::CallStackInfo, state::State,
};
/// The global resources and utilities shared across all frames.
pub struct RuntimeRes<'a> {
/// The ledger state including information such as the balance of each
/// account.
pub state: &'a mut State,
/// Metadata about the frame call stack.
pub callstack: &'a mut CallStackInfo,
/// A tool for recording information about the execution as it proceeds.
/// The data captured by the tracer is not used for consensus-critical
/// operations.
pub tracer: &'a mut dyn TracerTrait,
}
#[cfg(test)]
pub mod runtime_res_test {
use super::RuntimeRes;
use crate::stack::CallStackInfo;
use super::State;
pub struct OwnedRuntimeRes<'a> {
state: &'a mut State,
callstack: CallStackInfo,
tracer: (),
}
impl<'a> From<&'a mut State> for OwnedRuntimeRes<'a> {
fn from(state: &'a mut State) -> Self {
OwnedRuntimeRes {
state,
callstack: CallStackInfo::new(),
tracer: (),
}
}
}
impl<'a> OwnedRuntimeRes<'a> {
pub fn as_res<'b>(&'b mut self) -> RuntimeRes<'b> {
RuntimeRes {
state: &mut self.state,
callstack: &mut self.callstack,
tracer: &mut self.tracer,
}
}
}
}