@@ -25,6 +25,7 @@ import (
25
25
"regexp"
26
26
"runtime"
27
27
"strconv"
28
+ "strings"
28
29
"time"
29
30
30
31
"github.com/ethereum/go-ethereum/common"
@@ -115,7 +116,11 @@ func (s *Service) loop() {
115
116
// Loop reporting until termination
116
117
for {
117
118
// Establish a websocket connection to the server and authenticate the node
118
- conn , err := websocket .Dial (fmt .Sprintf ("wss://%s/api" , s .host ), "" , "http://localhost/" )
119
+ url := fmt .Sprintf ("%s/api" , s .host )
120
+ if ! strings .Contains (url , "://" ) {
121
+ url = "wss://" + url
122
+ }
123
+ conn , err := websocket .Dial (url , "" , "http://localhost/" )
119
124
if err != nil {
120
125
glog .V (logger .Warn ).Infof ("Stats server unreachable: %v" , err )
121
126
time .Sleep (10 * time .Second )
@@ -297,6 +302,7 @@ func (s *Service) reportLatency(in *json.Decoder, out *json.Encoder) error {
297
302
type blockStats struct {
298
303
Number * big.Int `json:"number"`
299
304
Hash common.Hash `json:"hash"`
305
+ Timestamp * big.Int `json:"timestamp"`
300
306
Miner common.Address `json:"miner"`
301
307
GasUsed * big.Int `json:"gasUsed"`
302
308
GasLimit * big.Int `json:"gasLimit"`
@@ -362,6 +368,7 @@ func (s *Service) reportBlock(out *json.Encoder, block *types.Block) error {
362
368
"block" : & blockStats {
363
369
Number : head .Number ,
364
370
Hash : head .Hash (),
371
+ Timestamp : head .Time ,
365
372
Miner : head .Coinbase ,
366
373
GasUsed : new (big.Int ).Set (head .GasUsed ),
367
374
GasLimit : new (big.Int ).Set (head .GasLimit ),
0 commit comments