Save the BeaconChain to store on state update

This commit is contained in:
Paul Hauner 2019-05-27 17:22:27 +10:00
parent faa682a9b5
commit b28fa3d20b
No known key found for this signature in database
GPG Key ID: 5E2CFF9B75FA63DF

View File

@ -347,6 +347,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
/// state and calling `catchup_state` as it will not result in an old state being installed and
/// then having it iteratively updated -- in such a case it's possible for another thread to
/// find the state at an old slot.
///
/// Also persists the `BeaconChain` to the store, in the case the client does not exit
/// gracefully.
pub fn update_state(&self, mut state: BeaconState<T::EthSpec>) -> Result<(), Error> {
let present_slot = match self.slot_clock.present_slot() {
Ok(Some(slot)) => slot,
@ -362,6 +365,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
*self.state.write() = state;
self.persist()?;
Ok(())
}