native: avoid allocations in increaseBalance

This commit is contained in:
Roman Khimov 2021-12-02 15:30:20 +03:00
parent ffeb3b8473
commit a003879b84
2 changed files with 2 additions and 2 deletions

View file

@ -54,7 +54,7 @@ func (g *GAS) increaseBalance(_ *interop.Context, _ util.Uint160, si *state.Stor
err = errors.New("insufficient funds")
}
return err
} else if sign == -1 && acc.Balance.Cmp(new(big.Int).Neg(amount)) == -1 {
} else if sign == -1 && acc.Balance.CmpAbs(amount) == -1 {
return errors.New("insufficient funds")
}
acc.Balance.Add(&acc.Balance, amount)

View file

@ -405,7 +405,7 @@ func (n *NEO) increaseBalance(ic *interop.Context, h util.Uint160, si *state.Sto
if err != nil {
return err
}
if (amount.Sign() == -1 && acc.Balance.Cmp(new(big.Int).Neg(amount)) == -1) ||
if (amount.Sign() == -1 && acc.Balance.CmpAbs(amount) == -1) ||
(amount.Sign() == 0 && checkBal != nil && acc.Balance.Cmp(checkBal) == -1) {
return errors.New("insufficient funds")
}