Skip to content

Commit 2639033

Browse files
committed
Merge pull request #1243 from karalabe/instrument-downloader-sync
eth, eth/downloader: separate concerns, clean up test suite
2 parents 6f5c615 + aa250e2 commit 2639033

File tree

9 files changed

+646
-468
lines changed

9 files changed

+646
-468
lines changed

eth/backend.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ type Ethereum struct {
193193
whisper *whisper.Whisper
194194
pow *ethash.Ethash
195195
protocolManager *ProtocolManager
196-
downloader *downloader.Downloader
197196
SolcPath string
198197
solc *compiler.Solidity
199198

@@ -290,14 +289,13 @@ func New(config *Config) (*Ethereum, error) {
290289
if err != nil {
291290
return nil, err
292291
}
293-
eth.downloader = downloader.New(eth.EventMux(), eth.chainManager.HasBlock, eth.chainManager.GetBlock)
294292
eth.txPool = core.NewTxPool(eth.EventMux(), eth.chainManager.State, eth.chainManager.GasLimit)
295293
eth.blockProcessor = core.NewBlockProcessor(stateDb, extraDb, eth.pow, eth.chainManager, eth.EventMux())
296294
eth.chainManager.SetProcessor(eth.blockProcessor)
295+
eth.protocolManager = NewProtocolManager(config.ProtocolVersion, config.NetworkId, eth.eventMux, eth.txPool, eth.chainManager)
296+
297297
eth.miner = miner.New(eth, eth.EventMux(), eth.pow)
298298
eth.miner.SetGasPrice(config.GasPrice)
299-
300-
eth.protocolManager = NewProtocolManager(config.ProtocolVersion, config.NetworkId, eth.eventMux, eth.txPool, eth.chainManager, eth.downloader)
301299
if config.Shh {
302300
eth.whisper = whisper.New()
303301
eth.shhVersionId = int(eth.whisper.Version())
@@ -447,7 +445,7 @@ func (s *Ethereum) ClientVersion() string { return s.clientVersio
447445
func (s *Ethereum) EthVersion() int { return s.ethVersionId }
448446
func (s *Ethereum) NetVersion() int { return s.netVersionId }
449447
func (s *Ethereum) ShhVersion() int { return s.shhVersionId }
450-
func (s *Ethereum) Downloader() *downloader.Downloader { return s.downloader }
448+
func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader }
451449

452450
// Start the ethereum
453451
func (s *Ethereum) Start() error {

0 commit comments

Comments
 (0)