aboutsummaryrefslogtreecommitdiffstats
path: root/ethstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-12-12 02:16:30 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-12-12 02:16:30 +0800
commit13614f4e1ce842cb4dffd5e9b27db433b980e65d (patch)
tree1be4e4188be179d03578d53f514750afb5489b37 /ethstats
parent4f9ccdd70f69dd0a879329d57ec21588f29f182c (diff)
downloadgo-tangerine-13614f4e1ce842cb4dffd5e9b27db433b980e65d.tar
go-tangerine-13614f4e1ce842cb4dffd5e9b27db433b980e65d.tar.gz
go-tangerine-13614f4e1ce842cb4dffd5e9b27db433b980e65d.tar.bz2
go-tangerine-13614f4e1ce842cb4dffd5e9b27db433b980e65d.tar.lz
go-tangerine-13614f4e1ce842cb4dffd5e9b27db433b980e65d.tar.xz
go-tangerine-13614f4e1ce842cb4dffd5e9b27db433b980e65d.tar.zst
go-tangerine-13614f4e1ce842cb4dffd5e9b27db433b980e65d.zip
ethstats: fix timestamps and add custom proto support
Diffstat (limited to 'ethstats')
-rw-r--r--ethstats/ethstats.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go
index a5fa84468..19f9cfba5 100644
--- a/ethstats/ethstats.go
+++ b/ethstats/ethstats.go
@@ -25,6 +25,7 @@ import (
"regexp"
"runtime"
"strconv"
+ "strings"
"time"
"github.com/ethereum/go-ethereum/common"
@@ -115,7 +116,11 @@ func (s *Service) loop() {
// Loop reporting until termination
for {
// Establish a websocket connection to the server and authenticate the node
- conn, err := websocket.Dial(fmt.Sprintf("wss://%s/api", s.host), "", "http://localhost/")
+ url := fmt.Sprintf("%s/api", s.host)
+ if !strings.Contains(url, "://") {
+ url = "wss://" + url
+ }
+ conn, err := websocket.Dial(url, "", "http://localhost/")
if err != nil {
glog.V(logger.Warn).Infof("Stats server unreachable: %v", err)
time.Sleep(10 * time.Second)
@@ -297,6 +302,7 @@ func (s *Service) reportLatency(in *json.Decoder, out *json.Encoder) error {
type blockStats struct {
Number *big.Int `json:"number"`
Hash common.Hash `json:"hash"`
+ Timestamp *big.Int `json:"timestamp"`
Miner common.Address `json:"miner"`
GasUsed *big.Int `json:"gasUsed"`
GasLimit *big.Int `json:"gasLimit"`
@@ -362,6 +368,7 @@ func (s *Service) reportBlock(out *json.Encoder, block *types.Block) error {
"block": &blockStats{
Number: head.Number,
Hash: head.Hash(),
+ Timestamp: head.Time,
Miner: head.Coinbase,
GasUsed: new(big.Int).Set(head.GasUsed),
GasLimit: new(big.Int).Set(head.GasLimit),