diff options
Diffstat (limited to 'xeth/state.go')
-rw-r--r-- | xeth/state.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/xeth/state.go b/xeth/state.go new file mode 100644 index 000000000..669cf91e6 --- /dev/null +++ b/xeth/state.go @@ -0,0 +1,36 @@ +package xeth + +import ( + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/state" +) + +type State struct { + xeth *XEth + state *state.StateDB +} + +func NewState(xeth *XEth, statedb *state.StateDB) *State { + return &State{xeth, statedb} +} + +func (self *State) State() *state.StateDB { + return self.state +} + +func (self *State) Get(addr string) *Object { + return &Object{self.state.GetStateObject(common.HexToAddress(addr))} +} + +func (self *State) SafeGet(addr string) *Object { + return &Object{self.safeGet(addr)} +} + +func (self *State) safeGet(addr string) *state.StateObject { + object := self.state.GetStateObject(common.HexToAddress(addr)) + if object == nil { + object = state.NewStateObject(common.HexToAddress(addr), self.xeth.backend.StateDb()) + } + + return object +} |