Skip to content

Commit

Permalink
feat: derive default for TracingInspector (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored May 1, 2024
1 parent 3d2077e commit 34b575a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/tracing/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::collections::HashSet;
///
/// Use [TracingInspectorConfig::default_parity] or [TracingInspectorConfig::default_geth] to get
/// the default configs for specific styles of traces.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
pub struct TracingInspectorConfig {
/// Whether to record every individual opcode level step.
pub record_steps: bool,
Expand Down Expand Up @@ -236,9 +236,10 @@ impl TracingInspectorConfig {
}

/// How much of the stack to record. Nothing, just the items pushed, or the full stack
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
pub enum StackSnapshotType {
/// Don't record stack snapshots
#[default]
None,
/// Record only the items pushed to the stack
Pushes,
Expand Down
12 changes: 2 additions & 10 deletions src/tracing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub use mux::{Error as MuxError, MuxInspector};
/// The [TracingInspector] keeps track of everything by:
/// 1. start tracking steps/calls on [Inspector::step] and [Inspector::call]
/// 2. complete steps/calls on [Inspector::step_end] and [Inspector::call_end]
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Default)]
pub struct TracingInspector {
/// Configures what and how the inspector records traces.
config: TracingInspectorConfig,
Expand All @@ -82,15 +82,7 @@ pub struct TracingInspector {
impl TracingInspector {
/// Returns a new instance for the given config
pub fn new(config: TracingInspectorConfig) -> Self {
Self {
config,
traces: Default::default(),
trace_stack: vec![],
step_stack: vec![],
last_call_return_data: None,
gas_inspector: Default::default(),
spec_id: None,
}
Self { config, ..Default::default() }
}

/// Resets the inspector to its initial state of [Self::new].
Expand Down

0 comments on commit 34b575a

Please sign in to comment.