mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
node/api: fixed rate formatter
This commit is contained in:
parent
f9401ae011
commit
6eed84c7ea
1 changed files with 2 additions and 2 deletions
|
|
@ -312,10 +312,10 @@ func NewPublicDebugAPI(node *Node) *PublicDebugAPI {
|
||||||
// Metrics retrieves all the known system metric collected by the node.
|
// Metrics retrieves all the known system metric collected by the node.
|
||||||
func (api *PublicDebugAPI) Metrics(raw bool) (map[string]interface{}, error) {
|
func (api *PublicDebugAPI) Metrics(raw bool) (map[string]interface{}, error) {
|
||||||
// Create a rate formatter
|
// 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 {
|
round := func(value float64, prec int) string {
|
||||||
unit := 0
|
unit := 0
|
||||||
for value >= 1000 {
|
for value >= 1000 && unit < 9 {
|
||||||
unit, value, prec = unit+1, value/1000, 2
|
unit, value, prec = unit+1, value/1000, 2
|
||||||
}
|
}
|
||||||
return fmt.Sprintf(fmt.Sprintf("%%.%df%s", prec, units[unit]), value)
|
return fmt.Sprintf(fmt.Sprintf("%%.%df%s", prec, units[unit]), value)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue