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.
This commit is contained in:
committed by
Felix Lange
parent
46ec4357e7
commit
024d41d0c2
@ -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 {
|
||||
|
Reference in New Issue
Block a user