mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
cmd/geth, eth/, les: switched to downloader event
This commit is contained in:
parent
c9daec2cbe
commit
832035636b
4 changed files with 10 additions and 10 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue