diff options
author | obscuren <geffobscura@gmail.com> | 2015-02-27 03:21:41 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-02-27 03:21:41 +0800 |
commit | 76f6d75ef867e754264834fc7171d1a12f24c5bb (patch) | |
tree | a9531d9e14c15abd72625a98a21a9b988dc32319 /xeth | |
parent | b2a225a52e45315f3ec90e11707fefa6059d13f5 (diff) | |
parent | fa7deb10f636d89f668249b78792f8cc48146ee8 (diff) | |
download | dexon-76f6d75ef867e754264834fc7171d1a12f24c5bb.tar dexon-76f6d75ef867e754264834fc7171d1a12f24c5bb.tar.gz dexon-76f6d75ef867e754264834fc7171d1a12f24c5bb.tar.bz2 dexon-76f6d75ef867e754264834fc7171d1a12f24c5bb.tar.lz dexon-76f6d75ef867e754264834fc7171d1a12f24c5bb.tar.xz dexon-76f6d75ef867e754264834fc7171d1a12f24c5bb.tar.zst dexon-76f6d75ef867e754264834fc7171d1a12f24c5bb.zip |
Merge branch 'master' into hotfix/0.8.5-2
Diffstat (limited to 'xeth')
-rw-r--r-- | xeth/state.go (renamed from xeth/world.go) | 13 | ||||
-rw-r--r-- | xeth/xeth.go | 22 |
2 files changed, 25 insertions, 10 deletions
diff --git a/xeth/world.go b/xeth/state.go index 9cbdd9461..e2562613c 100644 --- a/xeth/world.go +++ b/xeth/state.go @@ -3,19 +3,20 @@ package xeth import "github.com/ethereum/go-ethereum/state" type State struct { - xeth *XEth + xeth *XEth + state *state.StateDB } -func NewState(xeth *XEth) *State { - return &State{xeth} +func NewState(xeth *XEth, statedb *state.StateDB) *State { + return &State{xeth, statedb} } func (self *State) State() *state.StateDB { - return self.xeth.chainManager.TransState() + return self.state } func (self *State) Get(addr string) *Object { - return &Object{self.State().GetStateObject(fromHex(addr))} + return &Object{self.state.GetStateObject(fromHex(addr))} } func (self *State) SafeGet(addr string) *Object { @@ -23,7 +24,7 @@ func (self *State) SafeGet(addr string) *Object { } func (self *State) safeGet(addr string) *state.StateObject { - object := self.State().GetStateObject(fromHex(addr)) + object := self.state.GetStateObject(fromHex(addr)) if object == nil { object = state.NewStateObject(fromHex(addr), self.xeth.eth.Db()) } diff --git a/xeth/xeth.go b/xeth/xeth.go index 2985ce982..d4c188fec 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -17,6 +17,7 @@ import ( "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/p2p" + "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/whisper" ) @@ -54,13 +55,26 @@ func New(eth Backend) *XEth { whisper: NewWhisper(eth.Whisper()), miner: eth.Miner(), } - xeth.state = NewState(xeth) + xeth.state = NewState(xeth, xeth.chainManager.TransState()) return xeth } -func (self *XEth) Backend() Backend { return self.eth } -func (self *XEth) State() *State { return self.state } +func (self *XEth) Backend() Backend { return self.eth } +func (self *XEth) UseState(statedb *state.StateDB) *XEth { + xeth := &XEth{ + eth: self.eth, + blockProcessor: self.blockProcessor, + chainManager: self.chainManager, + whisper: self.whisper, + miner: self.miner, + } + + xeth.state = NewState(xeth, statedb) + return xeth +} +func (self *XEth) State() *State { return self.state } + func (self *XEth) Whisper() *Whisper { return self.whisper } func (self *XEth) Miner() *miner.Miner { return self.miner } @@ -229,7 +243,7 @@ func (self *XEth) Call(toStr, valueStr, gasStr, gasPriceStr, dataStr string) (st } var ( - statedb = self.chainManager.TransState() + statedb = self.State().State() //self.chainManager.TransState() key = self.eth.KeyManager().KeyPair() from = statedb.GetOrNewStateObject(key.Address()) block = self.chainManager.CurrentBlock() |