Regen historical using ArchivedPointRoot then State (#5845)

* Regen from ArchivedPointRoot and State
* Merge branch 'master' into fix-regen-historical-states
This commit is contained in:
terence tsao
2020-05-13 17:10:36 -07:00
committed by GitHub
parent 70c6dbeb68
commit dc20f3d72b

View File

@@ -43,18 +43,11 @@ func (kv *Store) regenHistoricalStates(ctx context.Context) error {
}
if lastArchivedIndex > 0 {
archivedIndexStart := lastArchivedIndex - 1
wantedSlotBelow := archivedIndexStart*slotsPerArchivedPoint + 1
states, err := kv.HighestSlotStatesBelow(ctx, wantedSlotBelow)
archivedRoot := kv.ArchivedPointRoot(ctx, archivedIndexStart)
currentState, err := kv.State(ctx, archivedRoot)
if err != nil {
return err
}
if len(states) == 0 {
return errors.New("states can't be empty")
}
if states[0] == nil {
return errors.New("nil last state")
}
currentState = states[0]
startSlot = currentState.Slot()
}