Fix bug when resuming from DB prior to genesis (#946)

* Use default client genesis if no chain in store

* Always use resume if there is a beacon chain
This commit is contained in:
Paul Hauner
2020-04-01 17:41:59 +11:00
committed by GitHub
parent 0759806c89
commit 88d37e96fa
3 changed files with 34 additions and 1 deletions

View File

@@ -178,6 +178,19 @@ where
.map_err(|e| format!("DB error whilst reading eth1 cache: {:?}", e))
}
/// Returns true if `self.store` contains a persisted beacon chain.
pub fn store_contains_beacon_chain(&self) -> Result<bool, String> {
let store = self
.store
.clone()
.ok_or_else(|| "load_from_store requires a store.".to_string())?;
Ok(store
.get::<PersistedBeaconChain>(&Hash256::from_slice(&BEACON_CHAIN_DB_KEY))
.map_err(|e| format!("DB error when reading persisted beacon chain: {:?}", e))?
.is_some())
}
/// Attempt to load an existing chain from the builder's `Store`.
///
/// May initialize several components; including the op_pool and finalized checkpoints.