Commit 25ed5fed authored by Gustav Simonsson's avatar Gustav Simonsson

core/state: short-circuit balance change if zero value

parent 3778f1bf
...@@ -152,6 +152,9 @@ func (self *StateObject) Update() { ...@@ -152,6 +152,9 @@ func (self *StateObject) Update() {
} }
func (c *StateObject) AddBalance(amount *big.Int) { func (c *StateObject) AddBalance(amount *big.Int) {
if amount.Cmp(common.Big0) == 0 {
return
}
c.SetBalance(new(big.Int).Add(c.balance, amount)) c.SetBalance(new(big.Int).Add(c.balance, amount))
if glog.V(logger.Core) { if glog.V(logger.Core) {
...@@ -160,6 +163,9 @@ func (c *StateObject) AddBalance(amount *big.Int) { ...@@ -160,6 +163,9 @@ func (c *StateObject) AddBalance(amount *big.Int) {
} }
func (c *StateObject) SubBalance(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)) c.SetBalance(new(big.Int).Sub(c.balance, amount))
if glog.V(logger.Core) { if glog.V(logger.Core) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment