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-02-10 23:19:36 +00:00
|
|
|
impl<T: EthSpec> SimpleStoreItem 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);
|
|
|
|
metrics::inc_counter_by(&metrics::BEACON_BLOCK_WRITE_BYTES, bytes.len() as i64);
|
|
|
|
|
|
|
|
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);
|
|
|
|
metrics::inc_counter_by(&metrics::BEACON_BLOCK_READ_BYTES, len as i64);
|
|
|
|
|
|
|
|
result
|
2019-05-20 08:01:51 +00:00
|
|
|
}
|
|
|
|
}
|