diff options
author | Matthew Wampler-Doty <matthew.wampler.doty@gmail.com> | 2015-02-28 05:13:31 +0800 |
---|---|---|
committer | Matthew Wampler-Doty <matthew.wampler.doty@gmail.com> | 2015-02-28 05:13:31 +0800 |
commit | 3820a65299831331f215e158d287fe3df3b69ea6 (patch) | |
tree | cf7b435109c646aac576ed98eefefb57e1f27223 /xeth/xeth.go | |
parent | 8653db6df0018d08212493e3a3df4677162bdd8f (diff) | |
parent | 0efd6a881afac0b3082f3b1e8780e3438eea5b02 (diff) | |
download | dexon-3820a65299831331f215e158d287fe3df3b69ea6.tar dexon-3820a65299831331f215e158d287fe3df3b69ea6.tar.gz dexon-3820a65299831331f215e158d287fe3df3b69ea6.tar.bz2 dexon-3820a65299831331f215e158d287fe3df3b69ea6.tar.lz dexon-3820a65299831331f215e158d287fe3df3b69ea6.tar.xz dexon-3820a65299831331f215e158d287fe3df3b69ea6.tar.zst dexon-3820a65299831331f215e158d287fe3df3b69ea6.zip |
Merge branch 'publictests' of github.com:ebuchman/go-ethereum into ethash_pow
Diffstat (limited to 'xeth/xeth.go')
-rw-r--r-- | xeth/xeth.go | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go index f3569e454..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() @@ -277,7 +291,7 @@ func (self *XEth) Transact(toStr, valueStr, gasStr, gasPriceStr, codeStr string) } var err error - state := self.eth.ChainManager().TransState() + state := self.eth.ChainManager().TxState() if balance := state.GetBalance(key.Address()); balance.Cmp(tx.Value()) < 0 { return "", fmt.Errorf("insufficient balance. balance=%v tx=%v", balance, tx.Value()) } @@ -288,13 +302,11 @@ func (self *XEth) Transact(toStr, valueStr, gasStr, gasPriceStr, codeStr string) //fmt.Printf("create tx: %x %v\n", tx.Hash()[:4], tx.Nonce()) - /* - // Do some pre processing for our "pre" events and hooks - block := self.chainManager.NewBlock(key.Address()) - coinbase := state.GetOrNewStateObject(key.Address()) - coinbase.SetGasPool(block.GasLimit()) - self.blockProcessor.ApplyTransactions(coinbase, state, block, types.Transactions{tx}, true) - */ + // Do some pre processing for our "pre" events and hooks + //block := self.chainManager.NewBlock(key.Address()) + //coinbase := state.GetOrNewStateObject(key.Address()) + //coinbase.SetGasPool(block.GasLimit()) + //self.blockProcessor.ApplyTransactions(coinbase, state, block, types.Transactions{tx}, true) err = self.eth.TxPool().Add(tx) if err != nil { |