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:
Paul Hauner
2020-03-06 16:09:41 +11:00
committed by GitHub
parent a87e8c55fc
commit 8c5bcfe53a
14 changed files with 297 additions and 119 deletions

View File

@@ -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)
}
}