diff options
-rw-r--r-- | cmd/utils/flags.go | 2 | ||||
-rw-r--r-- | dex/api_backend.go | 4 | ||||
-rw-r--r-- | dex/backend.go | 20 | ||||
-rw-r--r-- | dex/config.go | 2 | ||||
-rw-r--r-- | dex/handler.go | 4 | ||||
-rw-r--r-- | dex/handler_test.go | 2 | ||||
-rw-r--r-- | dex/helper_test.go | 2 | ||||
-rw-r--r-- | dex/protocol_test.go | 2 | ||||
-rw-r--r-- | dex/sync.go | 2 | ||||
-rw-r--r-- | eth/api_backend.go | 4 | ||||
-rw-r--r-- | eth/backend.go | 20 | ||||
-rw-r--r-- | internal/ethapi/backend.go | 8 | ||||
-rw-r--r-- | les/api_backend.go | 4 | ||||
-rw-r--r-- | les/backend.go | 12 |
14 files changed, 46 insertions, 42 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 514899699..fd5ea757d 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -41,8 +41,8 @@ import ( "github.com/dexon-foundation/dexon/crypto" "github.com/dexon-foundation/dexon/dashboard" "github.com/dexon-foundation/dexon/dex" + "github.com/dexon-foundation/dexon/dex/downloader" "github.com/dexon-foundation/dexon/eth" - "github.com/dexon-foundation/dexon/eth/downloader" "github.com/dexon-foundation/dexon/eth/gasprice" "github.com/dexon-foundation/dexon/ethdb" "github.com/dexon-foundation/dexon/ethstats" diff --git a/dex/api_backend.go b/dex/api_backend.go index c6c1d214d..9929b062d 100644 --- a/dex/api_backend.go +++ b/dex/api_backend.go @@ -29,8 +29,8 @@ import ( "github.com/dexon-foundation/dexon/core/state" "github.com/dexon-foundation/dexon/core/types" "github.com/dexon-foundation/dexon/core/vm" - "github.com/dexon-foundation/dexon/eth/downloader" "github.com/dexon-foundation/dexon/eth/gasprice" + "github.com/dexon-foundation/dexon/internal/ethapi" "github.com/dexon-foundation/dexon/ethdb" "github.com/dexon-foundation/dexon/event" @@ -186,7 +186,7 @@ func (b *DexAPIBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.S return b.dex.TxPool().SubscribeNewTxsEvent(ch) } -func (b *DexAPIBackend) Downloader() *downloader.Downloader { +func (b *DexAPIBackend) Downloader() ethapi.Downloader { return b.dex.Downloader() } diff --git a/dex/backend.go b/dex/backend.go index 36b28345c..8fe9e9ea3 100644 --- a/dex/backend.go +++ b/dex/backend.go @@ -33,7 +33,7 @@ import ( "github.com/dexon-foundation/dexon/core/rawdb" "github.com/dexon-foundation/dexon/core/vm" "github.com/dexon-foundation/dexon/dex/blockdb" - "github.com/dexon-foundation/dexon/eth/downloader" + "github.com/dexon-foundation/dexon/dex/downloader" "github.com/dexon-foundation/dexon/eth/filters" "github.com/dexon-foundation/dexon/eth/gasprice" "github.com/dexon-foundation/dexon/ethdb" @@ -266,12 +266,12 @@ func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Data return db, nil } -func (d *Dexon) AccountManager() *accounts.Manager { return d.accountManager } -func (d *Dexon) BlockChain() *core.BlockChain { return d.blockchain } -func (d *Dexon) TxPool() *core.TxPool { return d.txPool } -func (d *Dexon) DexVersion() int { return int(d.protocolManager.SubProtocols[0].Version) } -func (d *Dexon) EventMux() *event.TypeMux { return d.eventMux } -func (d *Dexon) Engine() consensus.Engine { return d.engine } -func (d *Dexon) ChainDb() ethdb.Database { return d.chainDb } -func (d *Dexon) Downloader() *downloader.Downloader { return d.protocolManager.downloader } -func (d *Dexon) NetVersion() uint64 { return d.networkID } +func (d *Dexon) AccountManager() *accounts.Manager { return d.accountManager } +func (d *Dexon) BlockChain() *core.BlockChain { return d.blockchain } +func (d *Dexon) TxPool() *core.TxPool { return d.txPool } +func (d *Dexon) DexVersion() int { return int(d.protocolManager.SubProtocols[0].Version) } +func (d *Dexon) EventMux() *event.TypeMux { return d.eventMux } +func (d *Dexon) Engine() consensus.Engine { return d.engine } +func (d *Dexon) ChainDb() ethdb.Database { return d.chainDb } +func (d *Dexon) Downloader() ethapi.Downloader { return d.protocolManager.downloader } +func (d *Dexon) NetVersion() uint64 { return d.networkID } diff --git a/dex/config.go b/dex/config.go index b90a344c8..b6ce76992 100644 --- a/dex/config.go +++ b/dex/config.go @@ -26,7 +26,7 @@ import ( "time" "github.com/dexon-foundation/dexon/core" - "github.com/dexon-foundation/dexon/eth/downloader" + "github.com/dexon-foundation/dexon/dex/downloader" "github.com/dexon-foundation/dexon/eth/gasprice" "github.com/dexon-foundation/dexon/params" ) diff --git a/dex/handler.go b/dex/handler.go index a1a158560..d66403fe6 100644 --- a/dex/handler.go +++ b/dex/handler.go @@ -54,8 +54,8 @@ import ( "github.com/dexon-foundation/dexon/core" "github.com/dexon-foundation/dexon/core/types" "github.com/dexon-foundation/dexon/crypto" - "github.com/dexon-foundation/dexon/eth/downloader" - "github.com/dexon-foundation/dexon/eth/fetcher" + "github.com/dexon-foundation/dexon/dex/downloader" + "github.com/dexon-foundation/dexon/dex/fetcher" "github.com/dexon-foundation/dexon/ethdb" "github.com/dexon-foundation/dexon/event" "github.com/dexon-foundation/dexon/log" diff --git a/dex/handler_test.go b/dex/handler_test.go index 981362bb5..dc1ea1d73 100644 --- a/dex/handler_test.go +++ b/dex/handler_test.go @@ -27,7 +27,7 @@ import ( "github.com/dexon-foundation/dexon/core/state" "github.com/dexon-foundation/dexon/core/types" "github.com/dexon-foundation/dexon/crypto" - "github.com/dexon-foundation/dexon/eth/downloader" + "github.com/dexon-foundation/dexon/dex/downloader" "github.com/dexon-foundation/dexon/ethdb" "github.com/dexon-foundation/dexon/p2p" "github.com/dexon-foundation/dexon/params" diff --git a/dex/helper_test.go b/dex/helper_test.go index 9a135d3e3..f57f3eff4 100644 --- a/dex/helper_test.go +++ b/dex/helper_test.go @@ -33,7 +33,7 @@ import ( "github.com/dexon-foundation/dexon/core/types" "github.com/dexon-foundation/dexon/core/vm" "github.com/dexon-foundation/dexon/crypto" - "github.com/dexon-foundation/dexon/eth/downloader" + "github.com/dexon-foundation/dexon/dex/downloader" "github.com/dexon-foundation/dexon/ethdb" "github.com/dexon-foundation/dexon/event" "github.com/dexon-foundation/dexon/p2p" diff --git a/dex/protocol_test.go b/dex/protocol_test.go index b0e89230a..64d7fa3e7 100644 --- a/dex/protocol_test.go +++ b/dex/protocol_test.go @@ -34,7 +34,7 @@ import ( "github.com/dexon-foundation/dexon/common" "github.com/dexon-foundation/dexon/core/types" "github.com/dexon-foundation/dexon/crypto" - "github.com/dexon-foundation/dexon/eth/downloader" + "github.com/dexon-foundation/dexon/dex/downloader" "github.com/dexon-foundation/dexon/p2p" "github.com/dexon-foundation/dexon/rlp" ) diff --git a/dex/sync.go b/dex/sync.go index 5af6076bc..b6a8035d4 100644 --- a/dex/sync.go +++ b/dex/sync.go @@ -23,7 +23,7 @@ import ( "github.com/dexon-foundation/dexon/common" "github.com/dexon-foundation/dexon/core/types" - "github.com/dexon-foundation/dexon/eth/downloader" + "github.com/dexon-foundation/dexon/dex/downloader" "github.com/dexon-foundation/dexon/log" "github.com/dexon-foundation/dexon/p2p/enode" ) diff --git a/eth/api_backend.go b/eth/api_backend.go index 631f04169..1c27b5d5c 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -28,10 +28,10 @@ import ( "github.com/dexon-foundation/dexon/core/state" "github.com/dexon-foundation/dexon/core/types" "github.com/dexon-foundation/dexon/core/vm" - "github.com/dexon-foundation/dexon/eth/downloader" "github.com/dexon-foundation/dexon/eth/gasprice" "github.com/dexon-foundation/dexon/ethdb" "github.com/dexon-foundation/dexon/event" + "github.com/dexon-foundation/dexon/internal/ethapi" "github.com/dexon-foundation/dexon/params" "github.com/dexon-foundation/dexon/rpc" ) @@ -189,7 +189,7 @@ func (b *EthAPIBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.S return b.eth.TxPool().SubscribeNewTxsEvent(ch) } -func (b *EthAPIBackend) Downloader() *downloader.Downloader { +func (b *EthAPIBackend) Downloader() ethapi.Downloader { return b.eth.Downloader() } diff --git a/eth/backend.go b/eth/backend.go index a6a558823..90cfa1a9a 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -462,16 +462,16 @@ func (s *Ethereum) StopMining() { func (s *Ethereum) IsMining() bool { return s.miner.Mining() } func (s *Ethereum) Miner() *miner.Miner { return s.miner } -func (s *Ethereum) AccountManager() *accounts.Manager { return s.accountManager } -func (s *Ethereum) BlockChain() *core.BlockChain { return s.blockchain } -func (s *Ethereum) TxPool() *core.TxPool { return s.txPool } -func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux } -func (s *Ethereum) Engine() consensus.Engine { return s.engine } -func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb } -func (s *Ethereum) IsListening() bool { return true } // Always listening -func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) } -func (s *Ethereum) NetVersion() uint64 { return s.networkID } -func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader } +func (s *Ethereum) AccountManager() *accounts.Manager { return s.accountManager } +func (s *Ethereum) BlockChain() *core.BlockChain { return s.blockchain } +func (s *Ethereum) TxPool() *core.TxPool { return s.txPool } +func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux } +func (s *Ethereum) Engine() consensus.Engine { return s.engine } +func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb } +func (s *Ethereum) IsListening() bool { return true } // Always listening +func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) } +func (s *Ethereum) NetVersion() uint64 { return s.networkID } +func (s *Ethereum) Downloader() ethapi.Downloader { return s.protocolManager.downloader } // Protocols implements node.Service, returning all the currently configured // network protocols to start. diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go index 2b4e6f0fc..801b55d5c 100644 --- a/internal/ethapi/backend.go +++ b/internal/ethapi/backend.go @@ -21,24 +21,28 @@ import ( "context" "math/big" + ethereum "github.com/dexon-foundation/dexon" "github.com/dexon-foundation/dexon/accounts" "github.com/dexon-foundation/dexon/common" "github.com/dexon-foundation/dexon/core" "github.com/dexon-foundation/dexon/core/state" "github.com/dexon-foundation/dexon/core/types" "github.com/dexon-foundation/dexon/core/vm" - "github.com/dexon-foundation/dexon/eth/downloader" "github.com/dexon-foundation/dexon/ethdb" "github.com/dexon-foundation/dexon/event" "github.com/dexon-foundation/dexon/params" "github.com/dexon-foundation/dexon/rpc" ) +type Downloader interface { + Progress() ethereum.SyncProgress +} + // Backend interface provides the common API services (that are provided by // both full and light clients) with access to necessary functions. type Backend interface { // General Ethereum API - Downloader() *downloader.Downloader + Downloader() Downloader ProtocolVersion() int SuggestPrice(ctx context.Context) (*big.Int, error) ChainDb() ethdb.Database diff --git a/les/api_backend.go b/les/api_backend.go index 3c0637462..148b29c0b 100644 --- a/les/api_backend.go +++ b/les/api_backend.go @@ -29,10 +29,10 @@ import ( "github.com/dexon-foundation/dexon/core/state" "github.com/dexon-foundation/dexon/core/types" "github.com/dexon-foundation/dexon/core/vm" - "github.com/dexon-foundation/dexon/eth/downloader" "github.com/dexon-foundation/dexon/eth/gasprice" "github.com/dexon-foundation/dexon/ethdb" "github.com/dexon-foundation/dexon/event" + "github.com/dexon-foundation/dexon/internal/ethapi" "github.com/dexon-foundation/dexon/light" "github.com/dexon-foundation/dexon/params" "github.com/dexon-foundation/dexon/rpc" @@ -163,7 +163,7 @@ func (b *LesApiBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEven return b.eth.blockchain.SubscribeRemovedLogsEvent(ch) } -func (b *LesApiBackend) Downloader() *downloader.Downloader { +func (b *LesApiBackend) Downloader() ethapi.Downloader { return b.eth.Downloader() } diff --git a/les/backend.go b/les/backend.go index 651f26ba6..b56222bba 100644 --- a/les/backend.go +++ b/les/backend.go @@ -215,12 +215,12 @@ func (s *LightEthereum) ResetWithGenesisBlock(gb *types.Block) { s.blockchain.ResetWithGenesisBlock(gb) } -func (s *LightEthereum) BlockChain() *light.LightChain { return s.blockchain } -func (s *LightEthereum) TxPool() *light.TxPool { return s.txPool } -func (s *LightEthereum) Engine() consensus.Engine { return s.engine } -func (s *LightEthereum) LesVersion() int { return int(ClientProtocolVersions[0]) } -func (s *LightEthereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader } -func (s *LightEthereum) EventMux() *event.TypeMux { return s.eventMux } +func (s *LightEthereum) BlockChain() *light.LightChain { return s.blockchain } +func (s *LightEthereum) TxPool() *light.TxPool { return s.txPool } +func (s *LightEthereum) Engine() consensus.Engine { return s.engine } +func (s *LightEthereum) LesVersion() int { return int(ClientProtocolVersions[0]) } +func (s *LightEthereum) Downloader() ethapi.Downloader { return s.protocolManager.downloader } +func (s *LightEthereum) EventMux() *event.TypeMux { return s.eventMux } // Protocols implements node.Service, returning all the currently configured // network protocols to start. |