mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth/downloader: better ux
This commit is contained in:
parent
aa21c1f2f4
commit
9f13d29432
1 changed files with 8 additions and 10 deletions
|
|
@ -68,7 +68,7 @@ func (api *DownloaderAPI) eventLoop() {
|
||||||
var (
|
var (
|
||||||
sub = api.mux.Subscribe(StartEvent{})
|
sub = api.mux.Subscribe(StartEvent{})
|
||||||
syncSubscriptions = make(map[chan interface{}]struct{})
|
syncSubscriptions = make(map[chan interface{}]struct{})
|
||||||
checkInterval = time.Second * 30
|
checkInterval = time.Second * 60
|
||||||
checkTimer = time.NewTimer(checkInterval)
|
checkTimer = time.NewTimer(checkInterval)
|
||||||
|
|
||||||
// status flags
|
// status flags
|
||||||
|
|
@ -102,15 +102,6 @@ func (api *DownloaderAPI) eventLoop() {
|
||||||
}
|
}
|
||||||
switch event.Data.(type) {
|
switch event.Data.(type) {
|
||||||
case StartEvent:
|
case StartEvent:
|
||||||
prog := getProgress()
|
|
||||||
notification := &SyncingResult{
|
|
||||||
Syncing: true,
|
|
||||||
Status: prog,
|
|
||||||
}
|
|
||||||
// broadcast
|
|
||||||
for c := range syncSubscriptions {
|
|
||||||
c <- notification
|
|
||||||
}
|
|
||||||
started = true
|
started = true
|
||||||
}
|
}
|
||||||
case <-checkTimer.C:
|
case <-checkTimer.C:
|
||||||
|
|
@ -120,6 +111,13 @@ func (api *DownloaderAPI) eventLoop() {
|
||||||
}
|
}
|
||||||
prog := getProgress()
|
prog := getProgress()
|
||||||
if !prog.Done() {
|
if !prog.Done() {
|
||||||
|
notification := &SyncingResult{
|
||||||
|
Syncing: true,
|
||||||
|
Status: prog,
|
||||||
|
}
|
||||||
|
for c := range syncSubscriptions {
|
||||||
|
c <- notification
|
||||||
|
}
|
||||||
checkTimer.Reset(checkInterval)
|
checkTimer.Reset(checkInterval)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue