-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dvovk/sync file level #8931
dvovk/sync file level #8931
Changes from all commits
69bbe69
c610cd7
c061717
170ce49
c0b450d
04b1f0d
9dd85ab
e1997e1
3b9a677
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ import ( | |
"github.com/ledgerwatch/erigon-lib/common" | ||
"github.com/ledgerwatch/erigon-lib/common/datadir" | ||
"github.com/ledgerwatch/erigon-lib/common/dbg" | ||
"github.com/ledgerwatch/erigon-lib/diagnostics" | ||
"github.com/ledgerwatch/erigon-lib/downloader/downloadercfg" | ||
"github.com/ledgerwatch/erigon-lib/downloader/snaptype" | ||
"github.com/ledgerwatch/erigon-lib/kv" | ||
|
@@ -117,6 +118,7 @@ func New(ctx context.Context, cfg *downloadercfg.Cfg, dirs datadir.Dirs, logger | |
if err := d.addTorrentFilesFromDisk(false); err != nil { | ||
return nil, err | ||
} | ||
|
||
// CornerCase: no peers -> no anoncments to trackers -> no magnetlink resolution (but magnetlink has filename) | ||
// means we can start adding weebseeds without waiting for `<-t.GotInfo()` | ||
d.wg.Add(1) | ||
|
@@ -348,32 +350,65 @@ func (d *Downloader) ReCalcStats(interval time.Duration) { | |
} | ||
|
||
d.logger.Log(d.verbosity, "[snapshots] progress", "file", t.Name(), "progress", fmt.Sprintf("%.2f%%", progress), "peers", len(peersOfThisFile), "webseeds", len(weebseedPeersOfThisFile)) | ||
if d.verbosity < log.LvlInfo { | ||
break //of switch | ||
} | ||
|
||
// more detailed statistic: download rate of each peer (for each file) | ||
webseedRates := make([]interface{}, 0, len(weebseedPeersOfThisFile)*2) | ||
for _, peer := range weebseedPeersOfThisFile { | ||
urlS := strings.Trim(strings.TrimPrefix(peer.String(), "webseed peer for "), "\"") | ||
if urlObj, err := url.Parse(urlS); err == nil { | ||
if shortUrl, err := url.JoinPath(urlObj.Host, urlObj.Path); err == nil { | ||
webseedRates = append(webseedRates, shortUrl, fmt.Sprintf("%s/s", common.ByteCount(uint64(peer.DownloadRate())))) | ||
isDiagEnabled := diagnostics.TypeOf(diagnostics.TorrentFile{}).Enabled() | ||
if d.verbosity < log.LvlInfo || isDiagEnabled { | ||
|
||
// more detailed statistic: download rate of each peer (for each file) | ||
websRates := uint64(0) | ||
webseedRates := make([]interface{}, 0, len(weebseedPeersOfThisFile)*2) | ||
for _, peer := range weebseedPeersOfThisFile { | ||
urlS := strings.Trim(strings.TrimPrefix(peer.String(), "webseed peer for "), "\"") | ||
if urlObj, err := url.Parse(urlS); err == nil { | ||
if shortUrl, err := url.JoinPath(urlObj.Host, urlObj.Path); err == nil { | ||
dr := uint64(peer.DownloadRate()) | ||
webseedRates = append(webseedRates, shortUrl, fmt.Sprintf("%s/s", common.ByteCount(dr))) | ||
websRates += dr | ||
} | ||
|
||
d.logger.Log(d.verbosity, "[snapshots] progress", "name", t.Name(), "progress", fmt.Sprintf("%.2f%%", progress), "webseeds", len(t.Metainfo().UrlList), "peers", len(peersOfThisFile)) | ||
} | ||
} | ||
|
||
lenght := uint64(len(weebseedPeersOfThisFile)) | ||
if lenght > 0 { | ||
websRates = websRates / lenght | ||
} | ||
|
||
d.logger.Info(fmt.Sprintf("[snapshots] webseed peers file=%s", t.Name()), webseedRates...) | ||
rates := make([]interface{}, 0, len(peersOfThisFile)*2) | ||
seedsRates := uint64(0) | ||
for _, peer := range peersOfThisFile { | ||
dr := uint64(peer.DownloadRate()) | ||
rates = append(rates, peer.PeerClientName.Load(), fmt.Sprintf("%s/s", common.ByteCount(dr))) | ||
seedsRates += dr | ||
} | ||
d.logger.Info(fmt.Sprintf("[snapshots] bittorrent peers file=%s", t.Name()), rates...) | ||
|
||
lenght = uint64(len(peersOfThisFile)) | ||
if lenght > 0 { | ||
seedsRates = seedsRates / uint64(len(peersOfThisFile)) | ||
} | ||
|
||
if isDiagEnabled { | ||
diagnostics.Send(diagnostics.TorrentFile{ | ||
Name: t.Name(), | ||
TotalBytes: uint64(t.Length()), | ||
DownloadedBytes: uint64(t.BytesCompleted()), | ||
SeedsCount: len(t.Metainfo().UrlList), | ||
PeersCount: len(peersOfThisFile), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is small confusion happened: Dictionary:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed names |
||
WebseedsRate: websRates, | ||
SeedsRate: seedsRates, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I advise rename “seedsRate” to “peersRate”. Just because “Seed” word is not used anywhere in erigon: logs, p2p peers, etc… |
||
}) | ||
} | ||
} | ||
d.logger.Info(fmt.Sprintf("[snapshots] webseed peers file=%s", t.Name()), webseedRates...) | ||
rates := make([]interface{}, 0, len(peersOfThisFile)*2) | ||
for _, peer := range peersOfThisFile { | ||
rates = append(rates, peer.PeerClientName.Load(), fmt.Sprintf("%s/s", common.ByteCount(uint64(peer.DownloadRate())))) | ||
} | ||
d.logger.Info(fmt.Sprintf("[snapshots] bittorrent peers file=%s", t.Name()), rates...) | ||
|
||
default: | ||
noMetadata = append(noMetadata, t.Name()) | ||
} | ||
|
||
stats.Completed = stats.Completed && t.Complete.Bool() | ||
} | ||
|
||
if len(noMetadata) > 0 { | ||
amount := len(noMetadata) | ||
if len(noMetadata) > 5 { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then need reneame count field also