mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-08 03:51:22 +00:00
91cb14ac41
* Remove redundant method * Pull out a method out of a struct * More precise db access abstractions * Move fake trait method out of it * cargo fmt * Fix compilation error after refactoring * Move another fake method out the Store trait * Get rid of superfluous method * Fix refactoring bug * Rename: SimpleStoreItem -> StoreItem * Get rid of the confusing DiskStore type alias * Get rid of SimpleDiskStore type alias * Correction: A method took both self and a ref to Self
27 lines
692 B
Rust
27 lines
692 B
Rust
use crate::head_tracker::SszHeadTracker;
|
|
use ssz::{Decode, Encode};
|
|
use ssz_derive::{Decode, Encode};
|
|
use store::{DBColumn, Error as StoreError, StoreItem};
|
|
use types::Hash256;
|
|
|
|
#[derive(Clone, Encode, Decode)]
|
|
pub struct PersistedBeaconChain {
|
|
pub canonical_head_block_root: Hash256,
|
|
pub genesis_block_root: Hash256,
|
|
pub ssz_head_tracker: SszHeadTracker,
|
|
}
|
|
|
|
impl StoreItem for PersistedBeaconChain {
|
|
fn db_column() -> DBColumn {
|
|
DBColumn::BeaconChain
|
|
}
|
|
|
|
fn as_store_bytes(&self) -> Vec<u8> {
|
|
self.as_ssz_bytes()
|
|
}
|
|
|
|
fn from_store_bytes(bytes: &[u8]) -> Result<Self, StoreError> {
|
|
Self::from_ssz_bytes(bytes).map_err(Into::into)
|
|
}
|
|
}
|