Fix store block read metrics
This commit is contained in:
parent
b076b07022
commit
a3e464078a
@ -9,25 +9,25 @@ impl<T: EthSpec> StoreItem for BeaconBlock<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn as_store_bytes(&self) -> Vec<u8> {
|
fn as_store_bytes(&self) -> Vec<u8> {
|
||||||
let timer = metrics::start_timer(&metrics::BEACON_STATE_WRITE_TIMES);
|
let timer = metrics::start_timer(&metrics::BEACON_BLOCK_WRITE_TIMES);
|
||||||
let bytes = self.as_ssz_bytes();
|
let bytes = self.as_ssz_bytes();
|
||||||
|
|
||||||
metrics::stop_timer(timer);
|
metrics::stop_timer(timer);
|
||||||
metrics::inc_counter(&metrics::BEACON_STATE_WRITE_COUNT);
|
metrics::inc_counter(&metrics::BEACON_BLOCK_WRITE_COUNT);
|
||||||
metrics::inc_counter_by(&metrics::BEACON_STATE_WRITE_BYTES, bytes.len() as i64);
|
metrics::inc_counter_by(&metrics::BEACON_BLOCK_WRITE_BYTES, bytes.len() as i64);
|
||||||
|
|
||||||
bytes
|
bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_store_bytes(bytes: &mut [u8]) -> Result<Self, Error> {
|
fn from_store_bytes(bytes: &mut [u8]) -> Result<Self, Error> {
|
||||||
let timer = metrics::start_timer(&metrics::BEACON_STATE_READ_TIMES);
|
let timer = metrics::start_timer(&metrics::BEACON_BLOCK_READ_TIMES);
|
||||||
|
|
||||||
let len = bytes.len();
|
let len = bytes.len();
|
||||||
let result = Self::from_ssz_bytes(bytes).map_err(Into::into);
|
let result = Self::from_ssz_bytes(bytes).map_err(Into::into);
|
||||||
|
|
||||||
metrics::stop_timer(timer);
|
metrics::stop_timer(timer);
|
||||||
metrics::inc_counter(&metrics::BEACON_STATE_READ_COUNT);
|
metrics::inc_counter(&metrics::BEACON_BLOCK_READ_COUNT);
|
||||||
metrics::inc_counter_by(&metrics::BEACON_STATE_READ_BYTES, len as i64);
|
metrics::inc_counter_by(&metrics::BEACON_BLOCK_READ_BYTES, len as i64);
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user