diff --git a/erigon-lib/downloader/downloader.go b/erigon-lib/downloader/downloader.go index 84648574583..6c8adb14b0e 100644 --- a/erigon-lib/downloader/downloader.go +++ b/erigon-lib/downloader/downloader.go @@ -109,6 +109,7 @@ type downloadProgress struct { } type AggStats struct { + Requested int MetadataReady, FilesTotal int32 LastMetadataUpdate *time.Time PeersUnique int32 @@ -1827,7 +1828,7 @@ func (d *Downloader) ReCalcStats(interval time.Duration) { prevStats, stats := d.stats, d.stats - stats.Completed = true + stats.Completed = len(torrents) == stats.Requested stats.BytesDownload = uint64(connStats.BytesReadUsefulIntendedData.Int64()) stats.BytesUpload = uint64(connStats.BytesWrittenData.Int64()) @@ -1927,11 +1928,8 @@ func (d *Downloader) ReCalcStats(interval time.Duration) { } // more detailed statistic: download rate of each peer (for each file) - if !torrentComplete && progress != 0 { - if _, ok := downloading[torrentName]; ok { - downloading[torrentName] = progress - } - + if _, ok := downloading[torrentName]; ok { + downloading[torrentName] = progress d.logger.Log(d.verbosity, "[snapshots] progress", "file", torrentName, "progress", fmt.Sprintf("%.2f%%", progress), "peers", len(peersOfThisFile), "webseeds", len(weebseedPeersOfThisFile)) d.logger.Log(d.verbosity, "[snapshots] webseed peers", webseedRates...) d.logger.Log(d.verbosity, "[snapshots] bittorrent peers", rates...) diff --git a/erigon-lib/downloader/downloader_grpc_server.go b/erigon-lib/downloader/downloader_grpc_server.go index 4e0aa0edd34..6923c2db923 100644 --- a/erigon-lib/downloader/downloader_grpc_server.go +++ b/erigon-lib/downloader/downloader_grpc_server.go @@ -58,6 +58,10 @@ func (s *GrpcServer) Add(ctx context.Context, request *proto_downloader.AddReque logEvery := time.NewTicker(20 * time.Second) defer logEvery.Stop() + s.d.lock.Lock() + s.d.stats.Requested += len(request.Items) + s.d.lock.Unlock() + for i, it := range request.Items { if it.Path == "" { return nil, fmt.Errorf("field 'path' is required")