aboutsummaryrefslogblamecommitdiffstats
path: root/xeth/state.go
blob: 669cf91e62a6665f62d4599bd58258c6b8c97731 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
            
 
        
                                                
                                                    
 
 
                   

                            

 

                                                          

 
                                           
                         

 
                                             
                                                                            

 
                                                 


                                          
                                                            
                                                                      
                          
                                                                                                     

         
                     
 
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
}