Remove redundant fields

This commit is contained in:
Taylor Gerring 2015-03-24 16:08:18 +01:00
parent ad420d099a
commit b9b7442b74

View File

@ -57,9 +57,6 @@ func (dummyFrontend) ConfirmTransaction(*types.Transaction) bool { return true }
type XEth struct {
backend *eth.Ethereum
blockProcessor *core.BlockProcessor
chainManager *core.ChainManager
accountManager *accounts.Manager
state *State
whisper *Whisper
@ -87,9 +84,6 @@ type XEth struct {
func New(eth *eth.Ethereum, frontend Frontend) *XEth {
xeth := &XEth{
backend: eth,
blockProcessor: eth.BlockProcessor(),
chainManager: eth.ChainManager(),
accountManager: eth.AccountManager(),
whisper: NewWhisper(eth.Whisper()),
quit: make(chan struct{}),
filterManager: filter.NewFilterManager(eth.EventMux()),
@ -103,7 +97,7 @@ func New(eth *eth.Ethereum, frontend Frontend) *XEth {
if frontend == nil {
xeth.frontend = dummyFrontend{}
}
xeth.state = NewState(xeth, xeth.chainManager.TransState())
xeth.state = NewState(xeth, xeth.backend.ChainManager().TransState())
go xeth.start()
go xeth.filterManager.Start()
@ -173,9 +167,6 @@ func (self *XEth) Backend() *eth.Ethereum { return self.backend }
func (self *XEth) WithState(statedb *state.StateDB) *XEth {
xeth := &XEth{
backend: self.backend,
blockProcessor: self.blockProcessor,
chainManager: self.chainManager,
whisper: self.whisper,
}
xeth.state = NewState(xeth, statedb)
@ -187,14 +178,14 @@ func (self *XEth) Whisper() *Whisper { return self.whisper }
func (self *XEth) BlockByHash(strHash string) *Block {
hash := common.HexToHash(strHash)
block := self.chainManager.GetBlock(hash)
block := self.backend.ChainManager().GetBlock(hash)
return NewBlock(block)
}
func (self *XEth) EthBlockByHash(strHash string) *types.Block {
hash := common.HexToHash(strHash)
block := self.chainManager.GetBlock(hash)
block := self.backend.ChainManager().GetBlock(hash)
return block
}
@ -214,10 +205,10 @@ func (self *XEth) BlockByNumber(num int64) *Block {
}
if num == -1 {
return NewBlock(self.chainManager.CurrentBlock())
return NewBlock(self.backend.ChainManager().CurrentBlock())
}
return NewBlock(self.chainManager.GetBlockByNumber(uint64(num)))
return NewBlock(self.backend.ChainManager().GetBlockByNumber(uint64(num)))
}
func (self *XEth) EthBlockByNumber(num int64) *types.Block {
@ -227,10 +218,10 @@ func (self *XEth) EthBlockByNumber(num int64) *types.Block {
}
if num == -1 {
return self.chainManager.CurrentBlock()
return self.backend.ChainManager().CurrentBlock()
}
return self.chainManager.GetBlockByNumber(uint64(num))
return self.backend.ChainManager().GetBlockByNumber(uint64(num))
}
func (self *XEth) Block(v interface{}) *Block {
@ -530,7 +521,7 @@ func (self *XEth) PushTx(encodedTx string) (string, error) {
}
func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr string) (string, error) {
statedb := self.State().State() //self.chainManager.TransState()
statedb := self.State().State() //self.eth.ChainManager().TransState()
msg := callmsg{
from: statedb.GetOrNewStateObject(common.HexToAddress(fromStr)),
to: common.HexToAddress(toStr),
@ -547,8 +538,8 @@ func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr st
msg.gasPrice = defaultGasPrice
}
block := self.chainManager.CurrentBlock()
vmenv := core.NewEnv(statedb, self.chainManager, msg, block)
block := self.backend.ChainManager().CurrentBlock()
vmenv := core.NewEnv(statedb, self.backend.ChainManager(), msg, block)
res, err := vmenv.Call(msg.from, msg.to, msg.data, msg.gas, msg.gasPrice, msg.value)
return common.ToHex(res), err
@ -609,7 +600,7 @@ func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeSt
tx = types.NewTransactionMessage(to, value.BigInt(), gas, price, data)
}
state := self.chainManager.TxState()
state := self.backend.ChainManager().TxState()
nonce := state.NewNonce(from)
tx.SetNonce(nonce)
@ -630,7 +621,7 @@ func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeSt
}
func (self *XEth) sign(tx *types.Transaction, from common.Address, didUnlock bool) error {
sig, err := self.accountManager.Sign(accounts.Account{Address: from.Bytes()}, tx.Hash().Bytes())
sig, err := self.backend.AccountManager().Sign(accounts.Account{Address: from.Bytes()}, tx.Hash().Bytes())
if err == accounts.ErrLocked {
if didUnlock {
return fmt.Errorf("sender account still locked after successful unlock")