aboutsummaryrefslogtreecommitdiffstats
path: root/state
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-13 05:29:10 +0800
committerobscuren <geffobscura@gmail.com>2015-03-13 05:29:10 +0800
commit310ca62285d2d4aefed91efddefeac7e83b7671d (patch)
tree7ae305e8704daa5622f8a5ac470cc132a081d6b3 /state
parent2ae90e1eba9dd98ea56c3b1ca38cb18fcfbbb622 (diff)
downloadgo-tangerine-310ca62285d2d4aefed91efddefeac7e83b7671d.tar.gz
go-tangerine-310ca62285d2d4aefed91efddefeac7e83b7671d.tar.zst
go-tangerine-310ca62285d2d4aefed91efddefeac7e83b7671d.zip
Removed some of that gas pre pay magic
Diffstat (limited to 'state')
-rw-r--r--state/state_object.go33
1 files changed, 18 insertions, 15 deletions
diff --git a/state/state_object.go b/state/state_object.go
index ccbfea391..dccbe8dad 100644
--- a/state/state_object.go
+++ b/state/state_object.go
@@ -38,19 +38,27 @@ func (self Storage) Copy() Storage {
}
type StateObject struct {
+ // State database for storing state changes
db ethutil.Database
- // Address of the object
+ // The state object
+ State *StateDB
+
+ // Address belonging to this account
address []byte
- // Shared attributes
- balance *big.Int
+ // The balance of the account
+ balance *big.Int
+ // The nonce of the account
+ nonce uint64
+ // The code hash if code is present (i.e. a contract)
codeHash []byte
- nonce uint64
- // Contract related attributes
- State *StateDB
- code Code
+ // The code for this account
+ code Code
+ // Temporarily initialisation code
initCode Code
-
+ // Cached storage (flushed when updated)
storage Storage
+ // Temporary prepaid gas, reward after transition
+ prepaid *big.Int
// Total gas pool is the total amount of gas currently
// left if this object is the coinbase. Gas is directly
@@ -77,6 +85,7 @@ func NewStateObject(addr []byte, db ethutil.Database) *StateObject {
object.State = New(nil, db) //New(trie.New(ethutil.Config.Db, ""))
object.storage = make(Storage)
object.gasPool = new(big.Int)
+ object.prepaid = new(big.Int)
return object
}
@@ -103,6 +112,7 @@ func NewStateObjectFromBytes(address, data []byte, db ethutil.Database) *StateOb
object.State = New(extobject.Root, db)
object.storage = make(map[string]*ethutil.Value)
object.gasPool = new(big.Int)
+ object.prepaid = new(big.Int)
object.code, _ = db.Get(extobject.CodeHash)
return object
@@ -230,8 +240,6 @@ func (self *StateObject) BuyGas(gas, price *big.Int) error {
rGas := new(big.Int).Set(gas)
rGas.Mul(rGas, price)
- self.AddBalance(rGas)
-
self.dirty = true
return nil
@@ -239,11 +247,6 @@ func (self *StateObject) BuyGas(gas, price *big.Int) error {
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.balance.Sub(self.balance, rGas)
}
func (self *StateObject) Copy() *StateObject {