use super::*;
impl ExecutionResult {
pub fn is_success(&self) -> bool {
self.success && self.exception.is_none()
}
pub fn gas_efficiency(&self) -> f64 {
if self.gas_limit == 0 {
0.0
} else {
(self.gas_used as f64) / (self.gas_limit as f64)
}
}
pub fn gas_remaining(&self) -> u64 {
self.gas_limit.saturating_sub(self.gas_used)
}
pub fn out_of_gas(&self) -> bool {
matches!(
self.exception,
Some(RuntimeException {
exception_type: ExceptionType::OutOfGas,
..
})
)
}
pub fn return_string(&self) -> Option<String> {
String::from_utf8(self.return_data.clone()).ok()
}
pub fn return_hex(&self) -> String {
hex::encode(&self.return_data)
}
pub fn has_state_changes(&self) -> bool {
!self.state_changes.is_empty()
}
pub fn log_count(&self) -> usize {
self.logs.len()
}
}