From 3bfdefbacc448027bf3bd94ea19592662c0f2e13 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 4 Oct 2016 11:38:20 +0200 Subject: [PATCH] core: fix refund --- core/state/statedb.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index 13738798eb..00e95867c2 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -235,6 +235,18 @@ func (self *StateDB) AddRefund(gas *big.Int) { self.refund.Add(self.refund, gas) } +func (s *StateDB) GetRefund() *big.Int { + var refund *big.Int + if s.MarkedTransition { + return new(big.Int) + } else if s.parent == nil { + refund = new(big.Int) + } else { + refund = s.parent.GetRefund() + } + return refund.Add(refund, s.refund) +} + func (self *StateDB) HasAccount(addr common.Address) bool { return self.GetStateObject(addr) != nil } @@ -488,10 +500,6 @@ func (self *StateDB) Set(state *StateDB) { */ } -func (self *StateDB) GetRefund() *big.Int { - return self.refund -} - // IntermediateRoot computes the current root hash of the state trie. // It is called in between transactions to get the root hash that // goes into transaction receipts.