ExecutedBlock cleanup (#7991)

* ExecutedBlock cleanup

* authority round makes only one call to note_rewards

* move Tracing from block to trace module

* removed BlockRef
This commit is contained in:
Marek Kotewicz
2018-02-27 18:22:56 +01:00
committed by GitHub
parent 6445f12c2d
commit df63341eb4
10 changed files with 138 additions and 183 deletions

View File

@@ -30,7 +30,7 @@ pub use self::executive_tracer::{ExecutiveTracer, ExecutiveVMTracer};
pub use self::import::ImportRequest;
pub use self::localized::LocalizedTrace;
pub use self::types::{filter, flat, localized, trace};
pub use self::types::{filter, flat, localized, trace, Tracing};
pub use self::types::error::Error as TraceError;
pub use self::types::trace::{VMTrace, VMOperation, VMExecutedOperation, MemoryDiff, StorageDiff, RewardType};
pub use self::types::flat::{FlatTrace, FlatTransactionTraces, FlatBlockTraces};

View File

@@ -21,3 +21,37 @@ pub mod filter;
pub mod flat;
pub mod trace;
pub mod localized;
use self::flat::FlatTransactionTraces;
/// Container for block traces.
#[derive(Clone)]
pub enum Tracing {
/// This variant should be used when tracing is enabled.
Enabled(Vec<FlatTransactionTraces>),
/// Tracing is disabled.
Disabled,
}
impl Tracing {
/// Creates new instance of enabled tracing object.
pub fn enabled() -> Self {
Tracing::Enabled(Default::default())
}
/// Returns true if tracing is enabled.
pub fn is_enabled(&self) -> bool {
match *self {
Tracing::Enabled(_) => true,
Tracing::Disabled => false,
}
}
/// Drain all traces.
pub fn drain(self) -> Vec<FlatTransactionTraces> {
match self {
Tracing::Enabled(traces) => traces,
Tracing::Disabled => vec![],
}
}
}