Add beacon chain persistence metric
This commit is contained in:
parent
42d300bdc3
commit
78db947e6e
@ -199,6 +199,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
|
|
||||||
/// Attempt to save this instance to `self.store`.
|
/// Attempt to save this instance to `self.store`.
|
||||||
pub fn persist(&self) -> Result<(), Error> {
|
pub fn persist(&self) -> Result<(), Error> {
|
||||||
|
let timer = metrics::start_timer(&metrics::PERSIST_CHAIN);
|
||||||
|
|
||||||
let p: PersistedBeaconChain<T> = PersistedBeaconChain {
|
let p: PersistedBeaconChain<T> = PersistedBeaconChain {
|
||||||
canonical_head: self.canonical_head.read().clone(),
|
canonical_head: self.canonical_head.read().clone(),
|
||||||
op_pool: PersistedOperationPool::from_operation_pool(&self.op_pool),
|
op_pool: PersistedOperationPool::from_operation_pool(&self.op_pool),
|
||||||
@ -209,6 +211,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
let key = Hash256::from_slice(&BEACON_CHAIN_DB_KEY.as_bytes());
|
let key = Hash256::from_slice(&BEACON_CHAIN_DB_KEY.as_bytes());
|
||||||
self.store.put(&key, &p)?;
|
self.store.put(&key, &p)?;
|
||||||
|
|
||||||
|
metrics::stop_timer(timer);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,4 +138,10 @@ lazy_static! {
|
|||||||
*/
|
*/
|
||||||
pub static ref UPDATE_HEAD_TIMES: Result<Histogram> =
|
pub static ref UPDATE_HEAD_TIMES: Result<Histogram> =
|
||||||
try_create_histogram("update_head_times", "Time taken to update the canonical head");
|
try_create_histogram("update_head_times", "Time taken to update the canonical head");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Persisting BeaconChain to disk
|
||||||
|
*/
|
||||||
|
pub static ref PERSIST_CHAIN: Result<Histogram> =
|
||||||
|
try_create_histogram("persist_chain", "Time taken to update the canonical head");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user