From b28fa3d20b7d826e23edd8da570601fe3b940f7e Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Mon, 27 May 2019 17:22:27 +1000 Subject: [PATCH] Save the `BeaconChain` to store on state update --- beacon_node/beacon_chain/src/beacon_chain.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index ca089789d..eb79da1f5 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -347,6 +347,9 @@ impl BeaconChain { /// 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) -> Result<(), Error> { let present_slot = match self.slot_clock.present_slot() { Ok(Some(slot)) => slot, @@ -362,6 +365,8 @@ impl BeaconChain { *self.state.write() = state; + self.persist()?; + Ok(()) }