7 "github.com/anacrolix/torrent"
8 "github.com/dustin/go-humanize"
11 func overallStatus(c *torrent.Client) {
12 tick := time.Tick(time.Second)
13 var prev torrent.ConnStats
21 stats := c.ConnStats()
23 for _, t := range c.Torrents() {
30 prev := TorrentStats[t.InfoHash()].stats
31 TorrentStats[t.InfoHash()] = TorrentStat{
33 rxSpeed: cur.BytesReadData.Int64() - prev.BytesReadData.Int64(),
34 txSpeed: cur.BytesWrittenData.Int64() - prev.BytesWrittenData.Int64(),
36 TorrentStatsM.Unlock()
37 peers += tStats.ActivePeers
40 "%s / %s | %d | %s%d%s / %s%d%s",
41 humanize.IBytes(uint64(stats.BytesRead.Int64())),
42 humanize.IBytes(uint64(stats.BytesWritten.Int64())),
44 Green, (stats.BytesRead.Int64()-prev.BytesRead.Int64())/1024, Reset,
45 Magenta, (stats.BytesWritten.Int64()-prev.BytesWritten.Int64())/1024, Reset,