mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
added grabbing info about downloaded metadata (#8972)
This commit is contained in:
parent
06e77d1705
commit
ac1e42b68d
@ -53,6 +53,7 @@ func (d *DiagnosticClient) runSnapshotListener() {
|
||||
d.snapshotDownload.Alloc = info.Alloc
|
||||
d.snapshotDownload.Sys = info.Sys
|
||||
d.snapshotDownload.DownloadFinished = info.DownloadFinished
|
||||
d.snapshotDownload.TorrentMetadataReady = info.TorrentMetadataReady
|
||||
|
||||
if info.DownloadFinished {
|
||||
return
|
||||
|
@ -30,18 +30,19 @@ type PeerStatistics struct {
|
||||
}
|
||||
|
||||
type SnapshotDownloadStatistics struct {
|
||||
Downloaded uint64 `json:"downloaded"`
|
||||
Total uint64 `json:"total"`
|
||||
TotalTime float64 `json:"totalTime"`
|
||||
DownloadRate uint64 `json:"downloadRate"`
|
||||
UploadRate uint64 `json:"uploadRate"`
|
||||
Peers int32 `json:"peers"`
|
||||
Files int32 `json:"files"`
|
||||
Connections uint64 `json:"connections"`
|
||||
Alloc uint64 `json:"alloc"`
|
||||
Sys uint64 `json:"sys"`
|
||||
DownloadFinished bool `json:"downloadFinished"`
|
||||
Segments map[string]SegmentDownloadStatistics `json:"segments"`
|
||||
Downloaded uint64 `json:"downloaded"`
|
||||
Total uint64 `json:"total"`
|
||||
TotalTime float64 `json:"totalTime"`
|
||||
DownloadRate uint64 `json:"downloadRate"`
|
||||
UploadRate uint64 `json:"uploadRate"`
|
||||
Peers int32 `json:"peers"`
|
||||
Files int32 `json:"files"`
|
||||
Connections uint64 `json:"connections"`
|
||||
Alloc uint64 `json:"alloc"`
|
||||
Sys uint64 `json:"sys"`
|
||||
DownloadFinished bool `json:"downloadFinished"`
|
||||
Segments map[string]SegmentDownloadStatistics `json:"segments"`
|
||||
TorrentMetadataReady int32 `json:"torrentMetadataReady"`
|
||||
}
|
||||
|
||||
type SegmentDownloadStatistics struct {
|
||||
|
@ -160,10 +160,26 @@ Loop:
|
||||
log.Info(fmt.Sprintf("[%s] download finished", logPrefix), "time", time.Since(downloadStartTime).String())
|
||||
break Loop
|
||||
} else {
|
||||
diagnostics.Send(diagnostics.SnapshotDownloadStatistics{
|
||||
Downloaded: stats.BytesCompleted,
|
||||
Total: stats.BytesTotal,
|
||||
TotalTime: time.Since(downloadStartTime).Round(time.Second).Seconds(),
|
||||
DownloadRate: stats.DownloadRate,
|
||||
UploadRate: stats.UploadRate,
|
||||
Peers: stats.PeersUnique,
|
||||
Files: stats.FilesTotal,
|
||||
Connections: stats.ConnectionsTotal,
|
||||
Alloc: m.Alloc,
|
||||
Sys: m.Sys,
|
||||
DownloadFinished: stats.Completed,
|
||||
TorrentMetadataReady: stats.MetadataReady,
|
||||
})
|
||||
|
||||
if stats.MetadataReady < stats.FilesTotal {
|
||||
log.Info(fmt.Sprintf("[%s] Waiting for torrents metadata: %d/%d", logPrefix, stats.MetadataReady, stats.FilesTotal))
|
||||
continue
|
||||
}
|
||||
|
||||
dbg.ReadMemStats(&m)
|
||||
downloadTimeLeft := calculateTime(stats.BytesTotal-stats.BytesCompleted, stats.DownloadRate)
|
||||
suffix := "downloading"
|
||||
@ -171,20 +187,6 @@ Loop:
|
||||
suffix += " (or verifying)"
|
||||
}
|
||||
|
||||
diagnostics.Send(diagnostics.SnapshotDownloadStatistics{
|
||||
Downloaded: stats.BytesCompleted,
|
||||
Total: stats.BytesTotal,
|
||||
TotalTime: time.Since(downloadStartTime).Round(time.Second).Seconds(),
|
||||
DownloadRate: stats.DownloadRate,
|
||||
UploadRate: stats.UploadRate,
|
||||
Peers: stats.PeersUnique,
|
||||
Files: stats.FilesTotal,
|
||||
Connections: stats.ConnectionsTotal,
|
||||
Alloc: m.Alloc,
|
||||
Sys: m.Sys,
|
||||
DownloadFinished: stats.Completed,
|
||||
})
|
||||
|
||||
log.Info(fmt.Sprintf("[%s] %s", logPrefix, suffix),
|
||||
"progress", fmt.Sprintf("%.2f%% %s/%s", stats.Progress, common.ByteCount(stats.BytesCompleted), common.ByteCount(stats.BytesTotal)),
|
||||
"time-left", downloadTimeLeft,
|
||||
|
Loading…
Reference in New Issue
Block a user