Skip to content

Commit

Permalink
Merge pull request ethereum#3035 from Gustav-Simonsson/zero_value_tra…
Browse files Browse the repository at this point in the history
…nsfer_noop

core/state: short-circuit balance change if zero value
  • Loading branch information
karalabe authored Sep 26, 2016
2 parents 3778f1b + 25ed5fe commit e859f36
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit e859f36

Please sign in to comment.