diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2017-02-23 06:29:59 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-02-23 06:29:59 +0800 |
commit | 024d41d0c2660d8f1dfbeb14921c7109e30493a2 (patch) | |
tree | a2b4ed630b84084c7f439d1539ed0551ec729cbd /core/vm/contract.go | |
parent | 46ec4357e73dd0c43951d11638d9aed94f8ffd29 (diff) | |
download | dexon-024d41d0c2660d8f1dfbeb14921c7109e30493a2.tar.gz dexon-024d41d0c2660d8f1dfbeb14921c7109e30493a2.tar.zst dexon-024d41d0c2660d8f1dfbeb14921c7109e30493a2.zip |
core, core/state, core/vm: remove exported account getters (#3618)
Removed exported statedb object accessors, reducing the chance for nasty
bugs to creep in. It's also ugly and unnecessary to have these methods.
Diffstat (limited to 'core/vm/contract.go')
-rw-r--r-- | core/vm/contract.go | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/core/vm/contract.go b/core/vm/contract.go index 091106d84..66748e821 100644 --- a/core/vm/contract.go +++ b/core/vm/contract.go @@ -25,11 +25,20 @@ import ( // ContractRef is a reference to the contract's backing object type ContractRef interface { Address() common.Address - Value() *big.Int - SetCode(common.Hash, []byte) - ForEachStorage(callback func(key, value common.Hash) bool) } +// AccountRef implements ContractRef. +// +// Account references are used during EVM initialisation and +// it's primary use is to fetch addresses. Removing this object +// proves difficult because of the cached jump destinations which +// are fetched from the parent contract (i.e. the caller), which +// is a ContractRef. +type AccountRef common.Address + +// Address casts AccountRef to a Address +func (ar AccountRef) Address() common.Address { return (common.Address)(ar) } + // Contract represents an ethereum contract in the state database. It contains // the the contract code, calling arguments. Contract implements ContractRef type Contract struct { @@ -69,7 +78,8 @@ func NewContract(caller ContractRef, object ContractRef, value *big.Int, gas uin // Gas should be a pointer so it can safely be reduced through the run // This pointer will be off the state transition c.Gas = gas - c.value = new(big.Int).Set(value) + // ensures a value is set + c.value = value return c } @@ -80,7 +90,10 @@ func (c *Contract) AsDelegate() *Contract { c.DelegateCall = true // NOTE: caller must, at all times be a contract. It should never happen // that caller is something other than a Contract. - c.CallerAddress = c.caller.(*Contract).CallerAddress + parent := c.caller.(*Contract) + c.CallerAddress = parent.CallerAddress + c.value = parent.value + return c } @@ -138,9 +151,3 @@ func (self *Contract) SetCallCode(addr *common.Address, hash common.Hash, code [ self.CodeHash = hash self.CodeAddr = addr } - -// EachStorage iterates the contract's storage and calls a method for every key -// value pair. -func (self *Contract) ForEachStorage(cb func(key, value common.Hash) bool) { - self.caller.ForEachStorage(cb) -} |