From 6d41402dcee01e4e1d03f461b5566df3dfe8e080 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Tue, 24 Mar 2015 15:36:39 +0100 Subject: [PATCH] Backend no longer needed to resolve import cycle --- xeth/xeth.go | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/xeth/xeth.go b/xeth/xeth.go index 98f5f5b36..3cf3b6d61 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -15,12 +15,10 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/event/filter" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/miner" - "github.com/ethereum/go-ethereum/p2p" - "github.com/ethereum/go-ethereum/whisper" ) var ( @@ -30,30 +28,6 @@ var ( defaultGas = big.NewInt(90000) //500000 ) -// to resolve the import cycle -type Backend interface { - BlockProcessor() *core.BlockProcessor - ChainManager() *core.ChainManager - AccountManager() *accounts.Manager - TxPool() *core.TxPool - PeerCount() int - IsListening() bool - Peers() []*p2p.Peer - BlockDb() common.Database - StateDb() common.Database - ExtraDb() common.Database - EventMux() *event.TypeMux - Whisper() *whisper.Whisper - Miner() *miner.Miner - - IsMining() bool - StartMining() error - StopMining() - Version() string - ProtocolVersion() int - NetworkId() int -} - // Frontend should be implemented by users of XEth. Its methods are // called whenever XEth makes a decision that requires user input. type Frontend interface { @@ -82,7 +56,7 @@ func (dummyFrontend) UnlockAccount([]byte) bool { return false func (dummyFrontend) ConfirmTransaction(*types.Transaction) bool { return true } type XEth struct { - eth Backend + eth *eth.Ethereum blockProcessor *core.BlockProcessor chainManager *core.ChainManager accountManager *accounts.Manager @@ -110,7 +84,7 @@ type XEth struct { // New creates an XEth that uses the given frontend. // If a nil Frontend is provided, a default frontend which // confirms all transactions will be used. -func New(eth Backend, frontend Frontend) *XEth { +func New(eth *eth.Ethereum, frontend Frontend) *XEth { xeth := &XEth{ eth: eth, blockProcessor: eth.BlockProcessor(), @@ -195,7 +169,7 @@ func (self *XEth) AtStateNum(num int64) *XEth { return self.WithState(st) } -func (self *XEth) Backend() Backend { return self.eth } +func (self *XEth) Backend() *eth.Ethereum { return self.eth } func (self *XEth) WithState(statedb *state.StateDB) *XEth { xeth := &XEth{ eth: self.eth,