]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Short ratio for fifos/top-seed
authorSergey Matveev <stargrave@stargrave.org>
Tue, 29 Nov 2022 13:11:48 +0000 (16:11 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 13 Jan 2023 08:32:42 +0000 (11:32 +0300)
cmd/btrtrc/fifos.go

index 508f6c097df54708120a39073ec056af6c551eaa..0167b7342f1ab25adb52df5472f3d9979a96e66e 100644 (file)
@@ -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)),
                        )
                }