소스 검색

Merge pull request #3035 from Gustav-Simonsson/zero_value_transfer_noop

core/state: short-circuit balance change if zero value
Péter Szilágyi 9 년 전
부모
커밋
e859f36967
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      core/state/state_object.go

+ 6 - 0
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) {