Update icstate.State.totalDelegationVarDB when P-Rep goes to inactive status
@@ -510,6 +510,7 @@ func (s *State) DisablePRep(owner module.Address, status Status, blockHeight int
return errors.Errorf("PRep not found: %s", owner)
}
+ oldStatus := ps.Status()
oldGrade, err := ps.DisableAs(status)
if err != nil {
return err
@@ -519,6 +520,11 @@ func (s *State) DisablePRep(owner module.Address, status Status, blockHeight int
return err
}
}
+ if oldStatus == Active && oldStatus != status {
+ if err = s.SetTotalDelegation(new(big.Int).Sub(s.GetTotalDelegation(), ps.Delegated())); err != nil {
+ return err
+ }
+ }
return nil
}
