From 850ba5af6b1e709e4365adf5680c2e17bf4d142a Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Thu, 25 Apr 2024 12:28:07 +0700 Subject: [PATCH] Revert "Added downloader request count (#10036)" This reverts commit 9af72789bd8832f6c0d73609143a2ae855c95e53. --- erigon-lib/downloader/downloader.go | 10 ++++++---- erigon-lib/downloader/downloader_grpc_server.go | 4 ---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/erigon-lib/downloader/downloader.go b/erigon-lib/downloader/downloader.go index 6c8adb14b0e..84648574583 100644 --- a/erigon-lib/downloader/downloader.go +++ b/erigon-lib/downloader/downloader.go @@ -109,7 +109,6 @@ type downloadProgress struct { } type AggStats struct { - Requested int MetadataReady, FilesTotal int32 LastMetadataUpdate *time.Time PeersUnique int32 @@ -1828,7 +1827,7 @@ func (d *Downloader) ReCalcStats(interval time.Duration) { prevStats, stats := d.stats, d.stats - stats.Completed = len(torrents) == stats.Requested + stats.Completed = true stats.BytesDownload = uint64(connStats.BytesReadUsefulIntendedData.Int64()) stats.BytesUpload = uint64(connStats.BytesWrittenData.Int64()) @@ -1928,8 +1927,11 @@ func (d *Downloader) ReCalcStats(interval time.Duration) { } // more detailed statistic: download rate of each peer (for each file) - if _, ok := downloading[torrentName]; ok { - downloading[torrentName] = progress + if !torrentComplete && progress != 0 { + 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 6923c2db923..4e0aa0edd34 100644 --- a/erigon-lib/downloader/downloader_grpc_server.go +++ b/erigon-lib/downloader/downloader_grpc_server.go @@ -58,10 +58,6 @@ 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")