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 /light/vm_env.go | |
parent | 46ec4357e73dd0c43951d11638d9aed94f8ffd29 (diff) | |
download | go-tangerine-024d41d0c2660d8f1dfbeb14921c7109e30493a2.tar go-tangerine-024d41d0c2660d8f1dfbeb14921c7109e30493a2.tar.gz go-tangerine-024d41d0c2660d8f1dfbeb14921c7109e30493a2.tar.bz2 go-tangerine-024d41d0c2660d8f1dfbeb14921c7109e30493a2.tar.lz go-tangerine-024d41d0c2660d8f1dfbeb14921c7109e30493a2.tar.xz go-tangerine-024d41d0c2660d8f1dfbeb14921c7109e30493a2.tar.zst go-tangerine-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 'light/vm_env.go')
-rw-r--r-- | light/vm_env.go | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/light/vm_env.go b/light/vm_env.go index d2cc7e960..ebd229de8 100644 --- a/light/vm_env.go +++ b/light/vm_env.go @@ -21,7 +21,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "golang.org/x/net/context" ) @@ -64,27 +63,10 @@ func (self *VMState) RevertToSnapshot(idx int) { self.snapshots = self.snapshots[:idx] } -// GetAccount returns the account object of the given account or nil if the -// account does not exist -func (s *VMState) GetAccount(addr common.Address) vm.Account { - so, err := s.state.GetStateObject(s.ctx, addr) - s.errHandler(err) - if err != nil { - // return a dummy state object to avoid panics - so = s.state.newStateObject(addr) - } - return so -} - // CreateAccount creates creates a new account object and takes ownership. -func (s *VMState) CreateAccount(addr common.Address) vm.Account { - so, err := s.state.CreateStateObject(s.ctx, addr) +func (s *VMState) CreateAccount(addr common.Address) { + _, err := s.state.CreateStateObject(s.ctx, addr) s.errHandler(err) - if err != nil { - // return a dummy state object to avoid panics - so = s.state.newStateObject(addr) - } - return so } // AddBalance adds the given amount to the balance of the specified account @@ -99,6 +81,15 @@ func (s *VMState) SubBalance(addr common.Address, amount *big.Int) { s.errHandler(err) } +// ForEachStorage calls a callback function for every key/value pair found +// in the local storage cache. Note that unlike core/state.StateObject, +// light.StateObject only returns cached values and doesn't download the +// entire storage tree. +func (s *VMState) ForEachStorage(addr common.Address, cb func(key, value common.Hash) bool) { + err := s.state.ForEachStorage(s.ctx, addr, cb) + s.errHandler(err) +} + // GetBalance retrieves the balance from the given address or 0 if the account does // not exist func (s *VMState) GetBalance(addr common.Address) *big.Int { |