cmd/geth, cmd/utils: Updated flag and linting issue

This commit is contained in:
Lucas Hendren 2019-01-26 12:44:44 -05:00
parent 0b8fa153c1
commit c8660fa5a1
2 changed files with 14 additions and 15 deletions

View file

@ -339,21 +339,20 @@ func startNode(ctx *cli.Context, stack *node.Node) {
sub := stack.EventMux().Subscribe(downloader.DoneEvent{}) sub := stack.EventMux().Subscribe(downloader.DoneEvent{})
defer sub.Unsubscribe() defer sub.Unsubscribe()
for { for {
select { event := <-sub.Chan()
case event := <-sub.Chan(): if event == nil {
if event == nil { continue
continue
}
done, ok := event.Data.(downloader.DoneEvent)
if !ok {
continue
}
if timestamp := time.Unix(done.Latest.Time.Int64(), 0); time.Since(timestamp) < 10*time.Minute {
log.Info("Synchronisation completed", "latestnum", done.Latest.Number, "latesthash", done.Latest.Hash(),
"age", common.PrettyAge(timestamp))
stack.Stop()
}
} }
done, ok := event.Data.(downloader.DoneEvent)
if !ok {
continue
}
if timestamp := time.Unix(done.Latest.Time.Int64(), 0); time.Since(timestamp) < 10*time.Minute {
log.Info("Synchronisation completed", "latestnum", done.Latest.Number, "latesthash", done.Latest.Hash(),
"age", common.PrettyAge(timestamp))
stack.Stop()
}
} }
}() }()
} }

View file

@ -159,7 +159,7 @@ var (
} }
ExitWhenSyncedFlag = cli.BoolFlag{ ExitWhenSyncedFlag = cli.BoolFlag{
Name: "exitwhensynced", Name: "exitwhensynced",
Usage: "Exists syncing by given time (default 0) after block synchronisation", Usage: "Exists syncing after block synchronisation",
} }
defaultSyncMode = eth.DefaultConfig.SyncMode defaultSyncMode = eth.DefaultConfig.SyncMode
SyncModeFlag = TextMarshalerFlag{ SyncModeFlag = TextMarshalerFlag{