mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 06:35:07 +03:00
Expose download/upload rate per peer
This commit is contained in:
parent
c22a746a1d
commit
fa39806aa4
5 changed files with 61 additions and 12 deletions
|
@ -356,13 +356,15 @@ type DataUnit uint64
|
|||
|
||||
func (d DataUnit) String() string {
|
||||
switch {
|
||||
case d > 1024*1024*1024*1024:
|
||||
return fmt.Sprintf("%2.ftb", float64(d)/1024/1024/1024/1024)
|
||||
case d > 1024*1024*1024:
|
||||
return fmt.Sprintf("%2.fgb", float64(d)/1024/1024/1024)
|
||||
case d > 1024*1024:
|
||||
return fmt.Sprintf("%2.fmb", float64(d)/1024/1024)
|
||||
case d >= 1024*1024*1024*1024:
|
||||
return fmt.Sprintf("%2.1fTB", float64(d)/1024/1024/1024/1024)
|
||||
case d >= 1024*1024*1024:
|
||||
return fmt.Sprintf("%2.1fGB", float64(d)/1024/1024/1024)
|
||||
case d >= 1024*1024:
|
||||
return fmt.Sprintf("%2.1fMB", float64(d)/1024/1024)
|
||||
case d >= 100:
|
||||
return fmt.Sprintf("%2.1fKB", float64(d)/1024)
|
||||
default:
|
||||
return fmt.Sprintf("%2.fkb", float64(d)/1024)
|
||||
return fmt.Sprintf("%dB", d)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue