From db0cb193ac1953e57fd5234880e7f96095c818bc Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 29 Nov 2022 16:11:48 +0300 Subject: [PATCH] Short ratio for fifos/top-seed --- cmd/btrtrc/fifos.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/btrtrc/fifos.go b/cmd/btrtrc/fifos.go index 508f6c09..0167b734 100644 --- a/cmd/btrtrc/fifos.go +++ b/cmd/btrtrc/fifos.go @@ -235,6 +235,7 @@ type topTorrent struct { infoHash metainfo.Hash name string tx int64 + ratio float64 } func fifoTopSeed(c *torrent.Client) { @@ -253,18 +254,21 @@ func fifoTopSeed(c *torrent.Client) { continue } stats := t.Stats() - ts = append(ts, &topTorrent{ + top := topTorrent{ infoHash: t.InfoHash(), name: t.Name(), tx: stats.BytesWrittenData.Int64() + TxStats[t.InfoHash()], - }) + } + top.ratio = float64(top.tx) / float64(t.Length()) + ts = append(ts, &top) } sort.Sort(ByTxTraffic(ts)) for _, t := range ts { fmt.Fprintf(fd, - "%s%s%s %s%40s%s %s\n", + "%s%s%s %s%40s%s %s%4.1f%s %s\n", Blue, t.infoHash.HexString(), Reset, Green, shortenName(t.name), Reset, + Magenta, t.ratio, Reset, humanize.IBytes(uint64(t.tx)), ) } -- 2.44.0