aboutsummaryrefslogtreecommitdiffstats
path: root/xeth
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-02-26 18:14:54 +0800
committerobscuren <geffobscura@gmail.com>2015-02-26 18:14:54 +0800
commit5ab0eaa06d2f5879b9b22778988410bd0c73dcc0 (patch)
tree79c73ac58048497ec40f1654396634e0d292d394 /xeth
parent52ccaa605e2a693bda64ac7d9fadf88d669ac446 (diff)
downloaddexon-5ab0eaa06d2f5879b9b22778988410bd0c73dcc0.tar.gz
dexon-5ab0eaa06d2f5879b9b22778988410bd0c73dcc0.tar.zst
dexon-5ab0eaa06d2f5879b9b22778988410bd0c73dcc0.zip
wip
Diffstat (limited to 'xeth')
-rw-r--r--xeth/world.go32
-rw-r--r--xeth/xeth.go22
2 files changed, 18 insertions, 36 deletions
diff --git a/xeth/world.go b/xeth/world.go
deleted file mode 100644
index 9cbdd9461..000000000
--- a/xeth/world.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package xeth
-
-import "github.com/ethereum/go-ethereum/state"
-
-type State struct {
- xeth *XEth
-}
-
-func NewState(xeth *XEth) *State {
- return &State{xeth}
-}
-
-func (self *State) State() *state.StateDB {
- return self.xeth.chainManager.TransState()
-}
-
-func (self *State) Get(addr string) *Object {
- return &Object{self.State().GetStateObject(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(fromHex(addr))
- if object == nil {
- object = state.NewStateObject(fromHex(addr), self.xeth.eth.Db())
- }
-
- return object
-}
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()