math: remove panics in safe math ops (#7962)

* math: remove panics in safe math ops

* fix docs

* fix lint
This commit is contained in:
Sam Kleinman
2022-02-22 18:34:17 +00:00
committed by GitHub
parent 926c469fcc
commit 912751cf93
4 changed files with 40 additions and 26 deletions
+5 -1
View File
@@ -504,8 +504,12 @@ func (store dbStore) LoadValidators(height int64) (*types.ValidatorSet, error) {
if err != nil {
return nil, err
}
h, err := tmmath.SafeConvertInt32(height - lastStoredHeight)
if err != nil {
return nil, err
}
vs.IncrementProposerPriority(tmmath.SafeConvertInt32(height - lastStoredHeight)) // mutate
vs.IncrementProposerPriority(h) // mutate
vi2, err := vs.ToProto()
if err != nil {
return nil, err