mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-23 06:44:35 +00:00
Optimise beacon chain persistence (#851)
* Unfinished progress * Update more persistence code * Start fixing tests * Combine persist head and fork choice * Persist head on reorg * Gracefully handle op pool and eth1 cache missing * Fix test failure * Address Michael's comments
This commit is contained in:
@@ -2,7 +2,9 @@ use crate::attestation_id::AttestationId;
|
||||
use crate::OperationPool;
|
||||
use parking_lot::RwLock;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use ssz::{Decode, Encode};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use store::{DBColumn, Error as StoreError, SimpleStoreItem};
|
||||
use types::*;
|
||||
|
||||
/// SSZ-serializable version of `OperationPool`.
|
||||
@@ -99,3 +101,17 @@ impl<T: EthSpec> PersistedOperationPool<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> SimpleStoreItem for PersistedOperationPool<T> {
|
||||
fn db_column() -> DBColumn {
|
||||
DBColumn::OpPool
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user