forked from cerc-io/plugeth
Remove redundant fields
This commit is contained in:
parent
ad420d099a
commit
b9b7442b74
33
xeth/xeth.go
33
xeth/xeth.go
@ -57,9 +57,6 @@ func (dummyFrontend) ConfirmTransaction(*types.Transaction) bool { return true }
|
|||||||
|
|
||||||
type XEth struct {
|
type XEth struct {
|
||||||
backend *eth.Ethereum
|
backend *eth.Ethereum
|
||||||
blockProcessor *core.BlockProcessor
|
|
||||||
chainManager *core.ChainManager
|
|
||||||
accountManager *accounts.Manager
|
|
||||||
state *State
|
state *State
|
||||||
whisper *Whisper
|
whisper *Whisper
|
||||||
|
|
||||||
@ -87,9 +84,6 @@ type XEth struct {
|
|||||||
func New(eth *eth.Ethereum, frontend Frontend) *XEth {
|
func New(eth *eth.Ethereum, frontend Frontend) *XEth {
|
||||||
xeth := &XEth{
|
xeth := &XEth{
|
||||||
backend: eth,
|
backend: eth,
|
||||||
blockProcessor: eth.BlockProcessor(),
|
|
||||||
chainManager: eth.ChainManager(),
|
|
||||||
accountManager: eth.AccountManager(),
|
|
||||||
whisper: NewWhisper(eth.Whisper()),
|
whisper: NewWhisper(eth.Whisper()),
|
||||||
quit: make(chan struct{}),
|
quit: make(chan struct{}),
|
||||||
filterManager: filter.NewFilterManager(eth.EventMux()),
|
filterManager: filter.NewFilterManager(eth.EventMux()),
|
||||||
@ -103,7 +97,7 @@ func New(eth *eth.Ethereum, frontend Frontend) *XEth {
|
|||||||
if frontend == nil {
|
if frontend == nil {
|
||||||
xeth.frontend = dummyFrontend{}
|
xeth.frontend = dummyFrontend{}
|
||||||
}
|
}
|
||||||
xeth.state = NewState(xeth, xeth.chainManager.TransState())
|
xeth.state = NewState(xeth, xeth.backend.ChainManager().TransState())
|
||||||
go xeth.start()
|
go xeth.start()
|
||||||
go xeth.filterManager.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 {
|
func (self *XEth) WithState(statedb *state.StateDB) *XEth {
|
||||||
xeth := &XEth{
|
xeth := &XEth{
|
||||||
backend: self.backend,
|
backend: self.backend,
|
||||||
blockProcessor: self.blockProcessor,
|
|
||||||
chainManager: self.chainManager,
|
|
||||||
whisper: self.whisper,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xeth.state = NewState(xeth, statedb)
|
xeth.state = NewState(xeth, statedb)
|
||||||
@ -187,14 +178,14 @@ func (self *XEth) Whisper() *Whisper { return self.whisper }
|
|||||||
|
|
||||||
func (self *XEth) BlockByHash(strHash string) *Block {
|
func (self *XEth) BlockByHash(strHash string) *Block {
|
||||||
hash := common.HexToHash(strHash)
|
hash := common.HexToHash(strHash)
|
||||||
block := self.chainManager.GetBlock(hash)
|
block := self.backend.ChainManager().GetBlock(hash)
|
||||||
|
|
||||||
return NewBlock(block)
|
return NewBlock(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *XEth) EthBlockByHash(strHash string) *types.Block {
|
func (self *XEth) EthBlockByHash(strHash string) *types.Block {
|
||||||
hash := common.HexToHash(strHash)
|
hash := common.HexToHash(strHash)
|
||||||
block := self.chainManager.GetBlock(hash)
|
block := self.backend.ChainManager().GetBlock(hash)
|
||||||
|
|
||||||
return block
|
return block
|
||||||
}
|
}
|
||||||
@ -214,10 +205,10 @@ func (self *XEth) BlockByNumber(num int64) *Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if num == -1 {
|
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 {
|
func (self *XEth) EthBlockByNumber(num int64) *types.Block {
|
||||||
@ -227,10 +218,10 @@ func (self *XEth) EthBlockByNumber(num int64) *types.Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if num == -1 {
|
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 {
|
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) {
|
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{
|
msg := callmsg{
|
||||||
from: statedb.GetOrNewStateObject(common.HexToAddress(fromStr)),
|
from: statedb.GetOrNewStateObject(common.HexToAddress(fromStr)),
|
||||||
to: common.HexToAddress(toStr),
|
to: common.HexToAddress(toStr),
|
||||||
@ -547,8 +538,8 @@ func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr st
|
|||||||
msg.gasPrice = defaultGasPrice
|
msg.gasPrice = defaultGasPrice
|
||||||
}
|
}
|
||||||
|
|
||||||
block := self.chainManager.CurrentBlock()
|
block := self.backend.ChainManager().CurrentBlock()
|
||||||
vmenv := core.NewEnv(statedb, self.chainManager, msg, block)
|
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)
|
res, err := vmenv.Call(msg.from, msg.to, msg.data, msg.gas, msg.gasPrice, msg.value)
|
||||||
return common.ToHex(res), err
|
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)
|
tx = types.NewTransactionMessage(to, value.BigInt(), gas, price, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
state := self.chainManager.TxState()
|
state := self.backend.ChainManager().TxState()
|
||||||
nonce := state.NewNonce(from)
|
nonce := state.NewNonce(from)
|
||||||
tx.SetNonce(nonce)
|
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 {
|
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 err == accounts.ErrLocked {
|
||||||
if didUnlock {
|
if didUnlock {
|
||||||
return fmt.Errorf("sender account still locked after successful unlock")
|
return fmt.Errorf("sender account still locked after successful unlock")
|
||||||
|
Loading…
Reference in New Issue
Block a user