<commit_before>use crate::*;
use ssz::{Decode, Encode};

mod beacon_state;

impl<T: EthSpec> StoreItem for BeaconBlock<T> {
    fn db_column() -> DBColumn {
        DBColumn::BeaconBlock
    }

    fn as_store_bytes(&self) -> Vec<u8> {
        let timer = metrics::start_timer(&metrics::BEACON_STATE_WRITE_TIMES);
        let bytes = self.as_ssz_bytes();

        metrics::stop_timer(timer);
        metrics::inc_counter(&metrics::BEACON_STATE_WRITE_COUNT);
        metrics::inc_counter_by(&metrics::BEACON_STATE_WRITE_BYTES, bytes.len() as i64);

        bytes
    }

    fn from_store_bytes(bytes: &mut [u8]) -> Result<Self, Error> {
        let timer = metrics::start_timer(&metrics::BEACON_STATE_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_STATE_READ_COUNT);
        metrics::inc_counter_by(&metrics::BEACON_STATE_READ_BYTES, len as i64);

        result
    }
}
<commit_msg>Fix store block read metrics<commit_after>use crate::*;
use ssz::{Decode, Encode};

mod beacon_state;

impl<T: EthSpec> StoreItem for BeaconBlock<T> {
    fn db_column() -> DBColumn {
        DBColumn::BeaconBlock
    }

    fn as_store_bytes(&self) -> Vec<u8> {
        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
    }

    fn from_store_bytes(bytes: &mut [u8]) -> Result<Self, Error> {
        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
    }
}

{'fraction_non_alphanumeric': 0.13166746756367131, 'fraction_numerical': 0.005766458433445459, 'mean_word_length': 3.636971046770601, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '792485', 'n_tokens_mistral': 709, 'n_tokens_neox': 690, 'n_words': 112}