Fix wrong ImportByForce flag impl
Fix wrong state transition to stopped state
Fix unexpected error callback on verify failure
@@ -238,15 +238,15 @@ func (it *importTask) onExecute(err error) {
func (it *importTask) _onExecute(err error) {
if it.state == executingIn {
+ var tr *transition
if err != nil {
if it.flags&module.ImportByForce > 0 {
- it.stop()
- it.in, err = it.in.sync(it.block.Result(), it.block.NextValidatorsHash(), it)
- if err != nil {
- it.cb(nil, err)
+ tr, err = it.in.sync(it.block.Result(), it.block.NextValidatorsHash(), it)
+ if err == nil {
+ it.in.dispose()
+ it.in = tr
return
}
- return
}
it.stop()
it.cb(nil, err)
@@ -256,10 +256,10 @@ func (it *importTask) _onExecute(err error) {
if err != nil {
// verification cannot fail in forced sync case
if it.flags&module.ImportByForce > 0 {
- it.stop()
- it.in, err = it.in.sync(it.block.Result(), it.block.NextValidatorsHash(), it)
- if err != nil {
- it.cb(nil, err)
+ tr, err = it.in.sync(it.block.Result(), it.block.NextValidatorsHash(), it)
+ if err == nil {
+ it.in.dispose()
+ it.in = tr
return
}
}
