State metrics possible changes (#5168)

* Registering state from overlay.

* fix

* fix2

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
cheme
2020-04-01 19:46:40 +02:00
committed by GitHub
parent a8aedfa16f
commit 58578af074
17 changed files with 232 additions and 33 deletions
@@ -206,13 +206,16 @@ pub trait Backend<H: Hasher>: std::fmt::Debug {
(root, txs)
}
/// Register stats from overlay of state machine.
///
/// By default nothing is registered.
fn register_overlay_stats(&mut self, _stats: &crate::stats::StateMachineStats);
/// Query backend usage statistics (i/o, memory)
///
/// Not all implementations are expected to be able to do this. In the
/// case when they don't, empty statistics is returned.
fn usage_info(&self) -> UsageInfo {
UsageInfo::empty()
}
fn usage_info(&self) -> UsageInfo;
/// Wipe the state database.
fn wipe(&self) -> Result<(), Self::Error> {
@@ -308,10 +311,12 @@ impl<'a, T: Backend<H>, H: Hasher> Backend<H> for &'a T {
(*self).for_key_values_with_prefix(prefix, f);
}
fn register_overlay_stats(&mut self, _stats: &crate::stats::StateMachineStats) { }
fn usage_info(&self) -> UsageInfo {
(*self).usage_info()
}
}
}
/// Trait that allows consolidate two transactions together.
pub trait Consolidate {