Save the BeaconChain
to store on state update
This commit is contained in:
parent
faa682a9b5
commit
b28fa3d20b
@ -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(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user