Fix a crash from ValildatorState type when restarting it with persistent db such as goleveldb.
@@ -92,14 +92,18 @@ func (m *manager) ProposeTransition(parent module.Transition, bi module.BlockInf
func (m *manager) CreateInitialTransition(result []byte,
valList module.ValidatorList,
) (module.Transition, error) {
- var vl state.ValidatorState
- var ok bool
+ var vs state.ValidatorState
if valList != nil {
- if vl, ok = valList.(state.ValidatorState); !ok {
- log.Panicln("Unsupported ValidatorState implementation")
+ switch v := valList.(type) {
+ case state.ValidatorSnapshot:
+ vs = state.ValidatorStateFromSnapshot(v)
+ case state.ValidatorState:
+ vs = v
+ default:
+ log.Panicln("Unsupported VadliatorState implementation")
}
}
- return newInitTransition(m.db, result, vl, m.cm, m.eem, m.chain)
+ return newInitTransition(m.db, result, vs, m.cm, m.eem, m.chain)
}
// CreateTransition creates a Transition following parent Transition with txs
