From 6eed84c7ea0cc66deed4cbc56b77dc017f9e6090 Mon Sep 17 00:00:00 2001 From: hackyminer Date: Tue, 29 Jan 2019 13:20:34 +0900 Subject: [PATCH] node/api: fixed rate formatter --- node/api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/api.go b/node/api.go index 6e36e505d1..88febdf1e4 100644 --- a/node/api.go +++ b/node/api.go @@ -312,10 +312,10 @@ func NewPublicDebugAPI(node *Node) *PublicDebugAPI { // Metrics retrieves all the known system metric collected by the node. func (api *PublicDebugAPI) Metrics(raw bool) (map[string]interface{}, error) { // Create a rate formatter - units := []string{"", "K", "M", "G", "T", "E", "P"} + units := []string{"", "K", "M", "G", "T", "P", "E", "Z", "Y"} round := func(value float64, prec int) string { unit := 0 - for value >= 1000 { + for value >= 1000 && unit < 9 { unit, value, prec = unit+1, value/1000, 2 } return fmt.Sprintf(fmt.Sprintf("%%.%df%s", prec, units[unit]), value)