diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-10-19 18:59:02 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-11-21 21:09:28 +0800 |
commit | 8c78449a9ef8f2a77cc1ff94f9a0a3178af21408 (patch) | |
tree | 61902b11284d1455ca7c109a512b93048d53ad4f /cmd/puppeth/module_node.go | |
parent | 005665867d50a4b38e269b6b84156db2f75469a3 (diff) | |
download | dexon-8c78449a9ef8f2a77cc1ff94f9a0a3178af21408.tar dexon-8c78449a9ef8f2a77cc1ff94f9a0a3178af21408.tar.gz dexon-8c78449a9ef8f2a77cc1ff94f9a0a3178af21408.tar.bz2 dexon-8c78449a9ef8f2a77cc1ff94f9a0a3178af21408.tar.lz dexon-8c78449a9ef8f2a77cc1ff94f9a0a3178af21408.tar.xz dexon-8c78449a9ef8f2a77cc1ff94f9a0a3178af21408.tar.zst dexon-8c78449a9ef8f2a77cc1ff94f9a0a3178af21408.zip |
cmd/puppeth: reorganize stats reports to make it readable
Diffstat (limited to 'cmd/puppeth/module_node.go')
-rw-r--r-- | cmd/puppeth/module_node.go | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/cmd/puppeth/module_node.go b/cmd/puppeth/module_node.go index 375e3e646..ad50cd80a 100644 --- a/cmd/puppeth/module_node.go +++ b/cmd/puppeth/module_node.go @@ -18,6 +18,7 @@ package main import ( "bytes" + "encoding/json" "fmt" "math/rand" "path/filepath" @@ -25,6 +26,7 @@ import ( "strings" "text/template" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" ) @@ -164,14 +166,37 @@ type nodeInfos struct { gasPrice float64 } -// String implements the stringer interface. -func (info *nodeInfos) String() string { - discv5 := "" +// Report converts the typed struct into a plain string->string map, cotnaining +// most - but not all - fields for reporting to the user. +func (info *nodeInfos) Report() map[string]string { + report := map[string]string{ + "Data directory": info.datadir, + "Listener port (full nodes)": strconv.Itoa(info.portFull), + "Peer count (all total)": strconv.Itoa(info.peersTotal), + "Peer count (light nodes)": strconv.Itoa(info.peersLight), + "Ethstats username": info.ethstats, + } if info.peersLight > 0 { - discv5 = fmt.Sprintf(", portv5=%d", info.portLight) + report["Listener port (light nodes)"] = strconv.Itoa(info.portLight) + } + if info.gasTarget > 0 { + report["Gas limit (baseline target)"] = fmt.Sprintf("%0.3f MGas", info.gasTarget) + report["Gas price (minimum accepted)"] = fmt.Sprintf("%0.3f GWei", info.gasPrice) + } + if info.etherbase != "" { + report["Miner account"] = info.etherbase + } + if info.keyJSON != "" { + var key struct { + Address string `json:"address"` + } + if err := json.Unmarshal([]byte(info.keyJSON), &key); err == nil { + report["Signer account"] = common.HexToAddress(key.Address).Hex() + } else { + log.Error("Failed to retrieve signer address", "err", err) + } } - return fmt.Sprintf("port=%d%s, datadir=%s, peers=%d, lights=%d, ethstats=%s, gastarget=%0.3f MGas, gasprice=%0.3f GWei", - info.portFull, discv5, info.datadir, info.peersTotal, info.peersLight, info.ethstats, info.gasTarget, info.gasPrice) + return report } // checkNode does a health-check against an boot or seal node server to verify |