From ae09a0009014f2a507acfaeb0015beba1cd00d29 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Wed, 8 May 2019 17:06:39 +1000 Subject: [PATCH] Update `db` crate for new `BeaconStateTypes` --- beacon_node/db/src/stores/beacon_state_store.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/beacon_node/db/src/stores/beacon_state_store.rs b/beacon_node/db/src/stores/beacon_state_store.rs index bb046a113..5a5af33d3 100644 --- a/beacon_node/db/src/stores/beacon_state_store.rs +++ b/beacon_node/db/src/stores/beacon_state_store.rs @@ -2,7 +2,7 @@ use super::STATES_DB_COLUMN as DB_COLUMN; use super::{ClientDB, DBError}; use ssz::decode; use std::sync::Arc; -use types::{BeaconState, Hash256}; +use types::{BeaconState, BeaconStateTypes, FoundationBeaconState, Hash256}; pub struct BeaconStateStore where @@ -19,11 +19,14 @@ impl BeaconStateStore { Self { db } } - pub fn get_deserialized(&self, hash: &Hash256) -> Result, DBError> { + pub fn get_deserialized( + &self, + hash: &Hash256, + ) -> Result>, DBError> { match self.get(&hash)? { None => Ok(None), Some(ssz) => { - let state = decode::(&ssz).map_err(|_| DBError { + let state = decode::>(&ssz).map_err(|_| DBError { message: "Bad State SSZ.".to_string(), })?; Ok(Some(state)) @@ -50,7 +53,7 @@ mod tests { let store = BeaconStateStore::new(db.clone()); let mut rng = XorShiftRng::from_seed([42; 16]); - let state = BeaconState::random_for_test(&mut rng); + let state: FoundationBeaconState = BeaconState::random_for_test(&mut rng); let state_root = state.canonical_root(); store.put(&state_root, &ssz_encode(&state)).unwrap();