aboutsummaryrefslogtreecommitdiffstats
path: root/ethstats/ethstats.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-01-07 01:30:44 +0800
committerGitHub <noreply@github.com>2017-01-07 01:30:44 +0800
commitac93a6ff6cd1200ab0fb67a5bd0c02cb70646632 (patch)
tree2b06aa1b360f1488264058d04e399e84b898f0d8 /ethstats/ethstats.go
parent444fc892b0a860218dab3e421d92c33408b9eb6d (diff)
parent13e3b2f433c48fe81423c1a13e9a5194ece61b01 (diff)
downloadgo-tangerine-ac93a6ff6cd1200ab0fb67a5bd0c02cb70646632.tar
go-tangerine-ac93a6ff6cd1200ab0fb67a5bd0c02cb70646632.tar.gz
go-tangerine-ac93a6ff6cd1200ab0fb67a5bd0c02cb70646632.tar.bz2
go-tangerine-ac93a6ff6cd1200ab0fb67a5bd0c02cb70646632.tar.lz
go-tangerine-ac93a6ff6cd1200ab0fb67a5bd0c02cb70646632.tar.xz
go-tangerine-ac93a6ff6cd1200ab0fb67a5bd0c02cb70646632.tar.zst
go-tangerine-ac93a6ff6cd1200ab0fb67a5bd0c02cb70646632.zip
Merge pull request #3525 from fjl/all-gosimple-cleanup
all: clean up lint issues, remove more dead code
Diffstat (limited to 'ethstats/ethstats.go')
-rw-r--r--ethstats/ethstats.go43
1 files changed, 13 insertions, 30 deletions
diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go
index 716beef69..8692a43bd 100644
--- a/ethstats/ethstats.go
+++ b/ethstats/ethstats.go
@@ -326,7 +326,7 @@ func (s *Service) login(in *json.Decoder, out *json.Encoder) error {
Secret: s.pass,
}
login := map[string][]interface{}{
- "emit": []interface{}{"hello", auth},
+ "emit": {"hello", auth},
}
if err := out.Encode(login); err != nil {
return err
@@ -365,7 +365,7 @@ func (s *Service) reportLatency(out *json.Encoder) error {
start := time.Now()
ping := map[string][]interface{}{
- "emit": []interface{}{"node-ping", map[string]string{
+ "emit": {"node-ping", map[string]string{
"id": s.node,
"clientTime": start.String(),
}},
@@ -383,15 +383,12 @@ func (s *Service) reportLatency(out *json.Encoder) error {
}
// Send back the measured latency
latency := map[string][]interface{}{
- "emit": []interface{}{"latency", map[string]string{
+ "emit": {"latency", map[string]string{
"id": s.node,
"latency": strconv.Itoa(int((time.Since(start) / time.Duration(2)).Nanoseconds() / 1000000)),
}},
}
- if err := out.Encode(latency); err != nil {
- return err
- }
- return nil
+ return out.Encode(latency)
}
// blockStats is the information to report about individual blocks.
@@ -438,12 +435,9 @@ func (s *Service) reportBlock(out *json.Encoder, block *types.Block) error {
"block": s.assembleBlockStats(block),
}
report := map[string][]interface{}{
- "emit": []interface{}{"block", stats},
- }
- if err := out.Encode(report); err != nil {
- return err
+ "emit": {"block", stats},
}
- return nil
+ return out.Encode(report)
}
// assembleBlockStats retrieves any required metadata to report a single block
@@ -497,9 +491,7 @@ func (s *Service) reportHistory(out *json.Encoder, list []uint64) error {
indexes := make([]uint64, 0, historyUpdateRange)
if len(list) > 0 {
// Specific indexes requested, send them back in particular
- for _, idx := range list {
- indexes = append(indexes, idx)
- }
+ indexes = append(indexes, list...)
} else {
// No indexes requested, send back the top ones
var head *types.Header
@@ -531,12 +523,9 @@ func (s *Service) reportHistory(out *json.Encoder, list []uint64) error {
"history": history,
}
report := map[string][]interface{}{
- "emit": []interface{}{"history", stats},
- }
- if err := out.Encode(report); err != nil {
- return err
+ "emit": {"history", stats},
}
- return nil
+ return out.Encode(report)
}
// pendStats is the information to report about pending transactions.
@@ -562,12 +551,9 @@ func (s *Service) reportPending(out *json.Encoder) error {
},
}
report := map[string][]interface{}{
- "emit": []interface{}{"pending", stats},
- }
- if err := out.Encode(report); err != nil {
- return err
+ "emit": {"pending", stats},
}
- return nil
+ return out.Encode(report)
}
// blockStats is the information to report about the local node.
@@ -616,10 +602,7 @@ func (s *Service) reportStats(out *json.Encoder) error {
},
}
report := map[string][]interface{}{
- "emit": []interface{}{"stats", stats},
- }
- if err := out.Encode(report); err != nil {
- return err
+ "emit": {"stats", stats},
}
- return nil
+ return out.Encode(report)
}