Skip to content

Commit 42e4e18

Browse files
Gustav Simonssonkaralabe
authored andcommitted
[release 1.4.12] core: short-circuit balance change if zero value
(cherry picked from commit 25ed5fe)
1 parent dfc63c4 commit 42e4e18

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

core/state/state_object.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ func (self *StateObject) Update() {
154154
}
155155

156156
func (c *StateObject) AddBalance(amount *big.Int) {
157+
if amount.Cmp(common.Big0) == 0 {
158+
return
159+
}
157160
c.SetBalance(new(big.Int).Add(c.balance, amount))
158161

159162
if glog.V(logger.Core) {
@@ -162,6 +165,9 @@ func (c *StateObject) AddBalance(amount *big.Int) {
162165
}
163166

164167
func (c *StateObject) SubBalance(amount *big.Int) {
168+
if amount.Cmp(common.Big0) == 0 {
169+
return
170+
}
165171
c.SetBalance(new(big.Int).Sub(c.balance, amount))
166172

167173
if glog.V(logger.Core) {

0 commit comments

Comments
 (0)