2019-05-20 08:01:51 +00:00
|
|
|
use crate::*;
|
|
|
|
use ssz::{Decode, Encode};
|
|
|
|
|
2019-11-26 23:54:46 +00:00
|
|
|
pub mod beacon_state;
|
|
|
|
pub mod partial_beacon_state;
|
2019-06-04 03:13:58 +00:00
|
|
|
|
2020-05-31 22:13:49 +00:00
|
|
|
impl<T: EthSpec> StoreItem for SignedBeaconBlock<T> {
|
2019-05-20 08:01:51 +00:00
|
|
|
fn db_column() -> DBColumn {
|
|
|
|
DBColumn::BeaconBlock
|
|
|
|
}
|
|
|
|
|
|
|
|
fn as_store_bytes(&self) -> Vec<u8> {
|
2019-08-19 11:02:34 +00:00
|
|
|
let timer = metrics::start_timer(&metrics::BEACON_BLOCK_WRITE_TIMES);
|
|
|
|
let bytes = self.as_ssz_bytes();
|
|
|
|
|
|
|
|
metrics::stop_timer(timer);
|
|
|
|
metrics::inc_counter(&metrics::BEACON_BLOCK_WRITE_COUNT);
|
2020-12-07 08:20:33 +00:00
|
|
|
metrics::inc_counter_by(&metrics::BEACON_BLOCK_WRITE_BYTES, bytes.len() as u64);
|
2019-08-19 11:02:34 +00:00
|
|
|
|
|
|
|
bytes
|
2019-05-20 08:01:51 +00:00
|
|
|
}
|
|
|
|
|
2019-11-26 23:54:46 +00:00
|
|
|
fn from_store_bytes(bytes: &[u8]) -> Result<Self, Error> {
|
2019-08-19 11:02:34 +00:00
|
|
|
let timer = metrics::start_timer(&metrics::BEACON_BLOCK_READ_TIMES);
|
|
|
|
|
|
|
|
let len = bytes.len();
|
|
|
|
let result = Self::from_ssz_bytes(bytes).map_err(Into::into);
|
|
|
|
|
|
|
|
metrics::stop_timer(timer);
|
|
|
|
metrics::inc_counter(&metrics::BEACON_BLOCK_READ_COUNT);
|
2020-12-07 08:20:33 +00:00
|
|
|
metrics::inc_counter_by(&metrics::BEACON_BLOCK_READ_BYTES, len as u64);
|
2019-08-19 11:02:34 +00:00
|
|
|
|
|
|
|
result
|
2019-05-20 08:01:51 +00:00
|
|
|
}
|
|
|
|
}
|