core: fix refund

This commit is contained in:
Jeffrey Wilcke 2016-10-04 11:38:20 +02:00
parent fc3ee373ab
commit 3bfdefbacc

View file

@ -235,6 +235,18 @@ func (self *StateDB) AddRefund(gas *big.Int) {
self.refund.Add(self.refund, gas) 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 { func (self *StateDB) HasAccount(addr common.Address) bool {
return self.GetStateObject(addr) != nil 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. // IntermediateRoot computes the current root hash of the state trie.
// It is called in between transactions to get the root hash that // It is called in between transactions to get the root hash that
// goes into transaction receipts. // goes into transaction receipts.