forked from mirror/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
695 B
34 lines
695 B
10 years ago
|
package xeth
|
||
10 years ago
|
|
||
10 years ago
|
import "github.com/ethereum/go-ethereum/state"
|
||
10 years ago
|
|
||
10 years ago
|
type State struct {
|
||
10 years ago
|
xeth *XEth
|
||
|
state *state.StateDB
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
func NewState(xeth *XEth, statedb *state.StateDB) *State {
|
||
|
return &State{xeth, statedb}
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
func (self *State) State() *state.StateDB {
|
||
10 years ago
|
return self.state
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
func (self *State) Get(addr string) *Object {
|
||
10 years ago
|
return &Object{self.state.GetStateObject(fromHex(addr))}
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
func (self *State) SafeGet(addr string) *Object {
|
||
10 years ago
|
return &Object{self.safeGet(addr)}
|
||
|
}
|
||
|
|
||
10 years ago
|
func (self *State) safeGet(addr string) *state.StateObject {
|
||
10 years ago
|
object := self.state.GetStateObject(fromHex(addr))
|
||
10 years ago
|
if object == nil {
|
||
10 years ago
|
object = state.NewStateObject(fromHex(addr), self.xeth.eth.Db())
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
return object
|
||
10 years ago
|
}
|