mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
Don't save nil head state (#4799)
* Don't save nil head state * Update head
This commit is contained in:
parent
70cb06d50f
commit
16a0c9f463
@ -155,7 +155,12 @@ func (s *Service) HeadState(ctx context.Context) (*state.BeaconState, error) {
|
||||
defer s.headLock.RUnlock()
|
||||
|
||||
if s.headState == nil {
|
||||
return s.beaconDB.HeadState(ctx)
|
||||
headState, err := s.beaconDB.HeadState(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.headState = headState
|
||||
return headState, nil
|
||||
}
|
||||
|
||||
return s.headState.Copy(), nil
|
||||
|
@ -64,6 +64,9 @@ func (s *Service) saveHead(ctx context.Context, headRoot [32]byte) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not retrieve head state in DB")
|
||||
}
|
||||
if headState == nil {
|
||||
return errors.New("cannot save nil head state")
|
||||
}
|
||||
|
||||
s.headLock.Lock()
|
||||
defer s.headLock.Unlock()
|
||||
|
Loading…
Reference in New Issue
Block a user