aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGustav Simonsson <gustav.simonsson@gmail.com>2016-09-26 13:25:50 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-09-26 13:49:59 +0800
commit42e4e1866728de5725cfdfbcb612b42f3e569c2a (patch)
tree62428c8af9af3b32fb0415ec2382af59b59ba121 /core
parentdfc63c49c7462014e6ab87db41c308aebb7b176a (diff)
downloadgo-tangerine-42e4e1866728de5725cfdfbcb612b42f3e569c2a.tar
go-tangerine-42e4e1866728de5725cfdfbcb612b42f3e569c2a.tar.gz
go-tangerine-42e4e1866728de5725cfdfbcb612b42f3e569c2a.tar.bz2
go-tangerine-42e4e1866728de5725cfdfbcb612b42f3e569c2a.tar.lz
go-tangerine-42e4e1866728de5725cfdfbcb612b42f3e569c2a.tar.xz
go-tangerine-42e4e1866728de5725cfdfbcb612b42f3e569c2a.tar.zst
go-tangerine-42e4e1866728de5725cfdfbcb612b42f3e569c2a.zip
[release 1.4.12] core: short-circuit balance change if zero value
(cherry picked from commit 25ed5feddadea8201974bfacb2a57d060b697acb)
Diffstat (limited to 'core')
-rw-r--r--core/state/state_object.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/state/state_object.go b/core/state/state_object.go
index 20da1006f..7a7f6c04b 100644
--- a/core/state/state_object.go
+++ b/core/state/state_object.go
@@ -154,6 +154,9 @@ func (self *StateObject) Update() {
}
func (c *StateObject) AddBalance(amount *big.Int) {
+ if amount.Cmp(common.Big0) == 0 {
+ return
+ }
c.SetBalance(new(big.Int).Add(c.balance, amount))
if glog.V(logger.Core) {
@@ -162,6 +165,9 @@ func (c *StateObject) AddBalance(amount *big.Int) {
}
func (c *StateObject) SubBalance(amount *big.Int) {
+ if amount.Cmp(common.Big0) == 0 {
+ return
+ }
c.SetBalance(new(big.Int).Sub(c.balance, amount))
if glog.V(logger.Core) {