aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/state_object.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-16 18:25:18 +0800
committerobscuren <geffobscura@gmail.com>2014-06-16 18:25:18 +0800
commit0d7763283952a57e5421565cdda19ecabe3222f7 (patch)
tree859f056bb7587dabca96f54e7dc5213f3563cbb6 /ethchain/state_object.go
parent8b15732c1e8a1a666ae7469bc43d989918ce754a (diff)
downloadgo-tangerine-0d7763283952a57e5421565cdda19ecabe3222f7.tar
go-tangerine-0d7763283952a57e5421565cdda19ecabe3222f7.tar.gz
go-tangerine-0d7763283952a57e5421565cdda19ecabe3222f7.tar.bz2
go-tangerine-0d7763283952a57e5421565cdda19ecabe3222f7.tar.lz
go-tangerine-0d7763283952a57e5421565cdda19ecabe3222f7.tar.xz
go-tangerine-0d7763283952a57e5421565cdda19ecabe3222f7.tar.zst
go-tangerine-0d7763283952a57e5421565cdda19ecabe3222f7.zip
Refund gas
Diffstat (limited to 'ethchain/state_object.go')
-rw-r--r--ethchain/state_object.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/ethchain/state_object.go b/ethchain/state_object.go
index 337c5a394..2c9dfb713 100644
--- a/ethchain/state_object.go
+++ b/ethchain/state_object.go
@@ -163,6 +163,15 @@ func (self *StateObject) BuyGas(gas, price *big.Int) error {
return nil
}
+func (self *StateObject) RefundGas(gas, price *big.Int) {
+ self.gasPool.Add(self.gasPool, gas)
+
+ rGas := new(big.Int).Set(gas)
+ rGas.Mul(rGas, price)
+
+ self.Amount.Sub(self.Amount, rGas)
+}
+
func (self *StateObject) Copy() *StateObject {
stCopy := &StateObject{}
stCopy.address = make([]byte, len(self.address))