eth/downloader: better ux

This commit is contained in:
Gary Rong 2024-01-22 12:17:30 +08:00
parent aa21c1f2f4
commit 9f13d29432

View file

@ -68,7 +68,7 @@ func (api *DownloaderAPI) eventLoop() {
var (
sub = api.mux.Subscribe(StartEvent{})
syncSubscriptions = make(map[chan interface{}]struct{})
checkInterval = time.Second * 30
checkInterval = time.Second * 60
checkTimer = time.NewTimer(checkInterval)
// status flags
@ -102,15 +102,6 @@ func (api *DownloaderAPI) eventLoop() {
}
switch event.Data.(type) {
case StartEvent:
prog := getProgress()
notification := &SyncingResult{
Syncing: true,
Status: prog,
}
// broadcast
for c := range syncSubscriptions {
c <- notification
}
started = true
}
case <-checkTimer.C:
@ -120,6 +111,13 @@ func (api *DownloaderAPI) eventLoop() {
}
prog := getProgress()
if !prog.Done() {
notification := &SyncingResult{
Syncing: true,
Status: prog,
}
for c := range syncSubscriptions {
c <- notification
}
checkTimer.Reset(checkInterval)
continue
}