diff --git a/cmd/geth/main.go b/cmd/geth/main.go index cdc8e31118..63767dc59d 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -346,16 +346,17 @@ func startNode(ctx *cli.Context, stack *node.Node) { } } var mux = stack.EventMux() - var sub = mux.Subscribe(downloader.BlockEvent{}) + var sub = mux.Subscribe(downloader.DoneEvent{}) for { select { case headers := <-sub.Chan(): if headers == nil { return } - log.Info("Synchronisation completed, checking", "check", headers) - time.Sleep(exitWhenSynced) - stack.Stop() + if 600 >= time.Now().Unix()-headers.Time.Unix() { + time.Sleep(exitWhenSynced) + stack.Stop() + } default: } } diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 32b6d879cd..8dd7aeb02d 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -414,7 +414,8 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I if err != nil { d.mux.Post(FailedEvent{err}) } else { - d.mux.Post(DoneEvent{}) + latest := d.blockchain.CurrentHeader() + d.mux.Post(DoneEvent{latest}) } }() if p.version < 62 { @@ -1562,9 +1563,6 @@ func (d *Downloader) processFastSyncContent(latest *types.Header) error { if err := d.importBlockResults(afterP); err != nil { return err } - if 600 > time.Now().Unix()-latest.Time.Int64() { - d.mux.Post(BlockEvent{}) - } } } diff --git a/eth/downloader/events.go b/eth/downloader/events.go index a70d21f50f..b6329b8015 100644 --- a/eth/downloader/events.go +++ b/eth/downloader/events.go @@ -16,7 +16,10 @@ package downloader -type DoneEvent struct{} -type BlockEvent struct{} +import ( + "github.com/ethereum/go-ethereum/core/types" +) + +type DoneEvent struct{ *types.Header } type StartEvent struct{} type FailedEvent struct{ Err error }