From 832035636b696a794547c498f5060e36cc85891b Mon Sep 17 00:00:00 2001 From: Lucas Hendren Date: Mon, 15 Oct 2018 01:23:34 -0400 Subject: [PATCH] cmd/geth, eth/, les: switched to downloader event --- cmd/geth/main.go | 14 +++++++++----- eth/config.go | 2 +- eth/downloader/downloader.go | 3 --- les/fetcher.go | 1 - 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 01afee1f94..561e163af3 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -34,6 +34,7 @@ import ( "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/console" "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/internal/debug" "github.com/ethereum/go-ethereum/les" @@ -340,18 +341,21 @@ func startNode(ctx *cli.Context, stack *node.Node) { if err := stack.Service(&lightEthereum); err != nil { utils.Fatalf("LightEthereum service not running: %v", err) } - <-lightEthereum.Downloader().SyncedCh - log.Info("Synchronisation completed, exitting", "countdown", exitWhenSynced) + var mux = stack.EventMux() + var sub = mux.Subscribe(downloader.DoneEvent{}) + <-sub.Chan() + log.Info("Synchronisation completed, exitting", "countdown", downloader.DoneEvent{}) time.Sleep(exitWhenSynced) stack.Stop() - } else { var ethereum *eth.Ethereum if err := stack.Service(ðereum); err != nil { utils.Fatalf("Ethereum service not running: %v", err) } - <-ethereum.Downloader().SyncedCh - log.Info("Synchronisation completed, exitting", "countdown", exitWhenSynced) + var mux = stack.EventMux() + var sub = mux.Subscribe(downloader.DoneEvent{}) + <-sub.Chan() + log.Info("Synchronisation completed, exitting", "countdown", downloader.DoneEvent{}) time.Sleep(exitWhenSynced) stack.Stop() } diff --git a/eth/config.go b/eth/config.go index 2f6f5ca7ad..b78043bb65 100644 --- a/eth/config.go +++ b/eth/config.go @@ -124,7 +124,7 @@ type Config struct { // specify time to exit after syncing ExitWhenSynced time.Duration - + // Type of the EWASM interpreter ("" for detault) EWASMInterpreter string // Type of the EVM interpreter ("" for default) diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index bca8cef381..17daaade08 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -128,7 +128,6 @@ type Downloader struct { bodyWakeCh chan bool // [eth/62] Channel to signal the block body fetcher of new tasks receiptWakeCh chan bool // [eth/63] Channel to signal the receipt fetcher of new tasks headerProcCh chan []*types.Header // [eth/62] Channel to feed the header processor new tasks - SyncedCh chan bool // for stateFetcher stateSyncStart chan *stateSync @@ -227,7 +226,6 @@ func New(mode SyncMode, stateDb ethdb.Database, mux *event.TypeMux, chain BlockC syncStatsState: stateSyncStats{ processed: rawdb.ReadFastTrieProgress(stateDb), }, - SyncedCh: make(chan bool, 1), trackStateReq: make(chan *stateReq), } go dl.qosTuner() @@ -320,7 +318,6 @@ func (d *Downloader) Synchronise(id string, head common.Hash, td *big.Int, mode switch err { case nil: select { - case d.SyncedCh <- true: default: } case errBusy: diff --git a/les/fetcher.go b/les/fetcher.go index 099934f3a0..f3b3503555 100644 --- a/les/fetcher.go +++ b/les/fetcher.go @@ -448,7 +448,6 @@ func (f *lightFetcher) nextRequest() (*distReq, uint64) { p.Log().Debug("Synchronisation started") f.pm.synchronise(p) f.syncDone <- p - f.SyncedCh <- true }() return nil },