formatBytes formats bytes into human-readable format
(bytes int64)
| 365 | |
| 366 | // formatBytes formats bytes into human-readable format |
| 367 | func formatBytes(bytes int64) string { |
| 368 | const unit = 1024 |
| 369 | if bytes < unit { |
| 370 | return fmt.Sprintf("%d B", bytes) |
| 371 | } |
| 372 | |
| 373 | div, exp := int64(unit), 0 |
| 374 | for n := bytes / unit; n >= unit; n /= unit { |
| 375 | div *= unit |
| 376 | exp++ |
| 377 | } |
| 378 | |
| 379 | return fmt.Sprintf("%.1f %cB", float64(bytes)/float64(div), "KMGTPE"[exp]) |
| 380 | } |
| 381 | |
| 382 | // CLI flags structure |
| 383 | type ValidatorFlags struct { |
no outgoing calls