mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 13:07:17 +00:00
shorter common.ByteCount for shorter logs #433
This commit is contained in:
parent
14f53eefaf
commit
42355b17ee
@ -21,14 +21,14 @@ import "fmt"
|
||||
func ByteCount(b uint64) string {
|
||||
const unit = 1024
|
||||
if b < unit {
|
||||
return fmt.Sprintf("%d B", b)
|
||||
return fmt.Sprintf("%db", b)
|
||||
}
|
||||
div, exp := uint64(unit), 0
|
||||
for n := b / unit; n >= unit; n /= unit {
|
||||
div *= unit
|
||||
exp++
|
||||
}
|
||||
return fmt.Sprintf("%.1f %ciB",
|
||||
return fmt.Sprintf("%.1f%cb",
|
||||
float64(b)/float64(div), "KMGTPE"[exp])
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user