aboutsummaryrefslogtreecommitdiffstats
path: root/xeth/state.go
blob: bb729db33432cf08f27a9909c7595b261c65288c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package xeth

import (
    "github.com/ethereum/go-ethereum/ethutil"
    "github.com/ethereum/go-ethereum/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(ethutil.FromHex(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(ethutil.FromHex(addr))
    if object == nil {
        object = state.NewStateObject(ethutil.FromHex(addr), self.xeth.eth.StateDb())
    }

    return object
}