diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-09-26 13:47:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-26 13:47:20 +0800 |
commit | e859f3696783ec75d9bb39c0c66eda3a88cea8c6 (patch) | |
tree | 7d06c1d29d01855277a9930b10d3fb7a254f19d1 /core | |
parent | 3778f1bf778366cea1232f2a54135e8153d65c97 (diff) | |
parent | 25ed5feddadea8201974bfacb2a57d060b697acb (diff) | |
download | go-tangerine-e859f3696783ec75d9bb39c0c66eda3a88cea8c6.tar go-tangerine-e859f3696783ec75d9bb39c0c66eda3a88cea8c6.tar.gz go-tangerine-e859f3696783ec75d9bb39c0c66eda3a88cea8c6.tar.bz2 go-tangerine-e859f3696783ec75d9bb39c0c66eda3a88cea8c6.tar.lz go-tangerine-e859f3696783ec75d9bb39c0c66eda3a88cea8c6.tar.xz go-tangerine-e859f3696783ec75d9bb39c0c66eda3a88cea8c6.tar.zst go-tangerine-e859f3696783ec75d9bb39c0c66eda3a88cea8c6.zip |
Merge pull request #3035 from Gustav-Simonsson/zero_value_transfer_noop
core/state: short-circuit balance change if zero value
Diffstat (limited to 'core')
-rw-r--r-- | core/state/state_object.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/core/state/state_object.go b/core/state/state_object.go index c5462316d..9f0ce5b4b 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -152,6 +152,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) { @@ -160,6 +163,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) { |