aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2019-02-05 18:49:59 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-02-07 20:36:25 +0800
commitd6225ab846d1abeeb9ba9e9aad84bc566ddf52f2 (patch)
tree6105a12328eba306896de5421b6d91ff775a0d56 /common
parent85b3b1c8d60db82af9138a0649f6e6dce6b49cad (diff)
downloadgo-tangerine-d6225ab846d1abeeb9ba9e9aad84bc566ddf52f2.tar
go-tangerine-d6225ab846d1abeeb9ba9e9aad84bc566ddf52f2.tar.gz
go-tangerine-d6225ab846d1abeeb9ba9e9aad84bc566ddf52f2.tar.bz2
go-tangerine-d6225ab846d1abeeb9ba9e9aad84bc566ddf52f2.tar.lz
go-tangerine-d6225ab846d1abeeb9ba9e9aad84bc566ddf52f2.tar.xz
go-tangerine-d6225ab846d1abeeb9ba9e9aad84bc566ddf52f2.tar.zst
go-tangerine-d6225ab846d1abeeb9ba9e9aad84bc566ddf52f2.zip
cmd/utils, eth: relinquish GC cache to read cache in archive mode
Diffstat (limited to 'common')
-rw-r--r--common/size.go16
-rw-r--r--common/size_test.go4
2 files changed, 10 insertions, 10 deletions
diff --git a/common/size.go b/common/size.go
index bd0fc85c7..6381499a4 100644
--- a/common/size.go
+++ b/common/size.go
@@ -26,10 +26,10 @@ type StorageSize float64
// String implements the stringer interface.
func (s StorageSize) String() string {
- if s > 1000000 {
- return fmt.Sprintf("%.2f mB", s/1000000)
- } else if s > 1000 {
- return fmt.Sprintf("%.2f kB", s/1000)
+ if s > 1048576 {
+ return fmt.Sprintf("%.2f MiB", s/1048576)
+ } else if s > 1024 {
+ return fmt.Sprintf("%.2f KiB", s/1024)
} else {
return fmt.Sprintf("%.2f B", s)
}
@@ -38,10 +38,10 @@ func (s StorageSize) String() string {
// TerminalString implements log.TerminalStringer, formatting a string for console
// output during logging.
func (s StorageSize) TerminalString() string {
- if s > 1000000 {
- return fmt.Sprintf("%.2fmB", s/1000000)
- } else if s > 1000 {
- return fmt.Sprintf("%.2fkB", s/1000)
+ if s > 1048576 {
+ return fmt.Sprintf("%.2fMiB", s/1048576)
+ } else if s > 1024 {
+ return fmt.Sprintf("%.2fKiB", s/1024)
} else {
return fmt.Sprintf("%.2fB", s)
}
diff --git a/common/size_test.go b/common/size_test.go
index f5b6c725e..0938d483c 100644
--- a/common/size_test.go
+++ b/common/size_test.go
@@ -25,8 +25,8 @@ func TestStorageSizeString(t *testing.T) {
size StorageSize
str string
}{
- {2381273, "2.38 mB"},
- {2192, "2.19 kB"},
+ {2381273, "2.27 MiB"},
+ {2192, "2.14 KiB"},
{12, "12.00 B"},
}