From 4c8c5e2f7410d850ee6068b46c8b880f733743d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Fri, 25 Nov 2016 17:55:06 +0200 Subject: cmd, ethstats, les, mobile, params: native netstats (#3336) --- mobile/geth.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'mobile') diff --git a/mobile/geth.go b/mobile/geth.go index 738c0c548..7ea4b2f65 100644 --- a/mobile/geth.go +++ b/mobile/geth.go @@ -27,6 +27,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/ethclient" + "github.com/ethereum/go-ethereum/ethstats" "github.com/ethereum/go-ethereum/les" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p/nat" @@ -65,6 +66,12 @@ type NodeConfig struct { // A minimum of 16MB is always reserved. EthereumDatabaseCache int + // EthereumNetStats is a netstats connection string to use to report various + // chain, transaction and node stats to a monitoring server. + // + // It has the form "nodename:secret@host:port" + EthereumNetStats string + // WhisperEnabled specifies whether the node should run the Whisper protocol. WhisperEnabled bool } @@ -106,6 +113,7 @@ func NewNode(datadir string, config *NodeConfig) (*Node, error) { // Create the empty networking stack nodeConf := &node.Config{ Name: clientIdentifier, + Version: params.Version, DataDir: datadir, KeyStoreDir: filepath.Join(datadir, "keystore"), // Mobile should never use internal keystores! NoDiscovery: true, @@ -150,6 +158,17 @@ func NewNode(datadir string, config *NodeConfig) (*Node, error) { }); err != nil { return nil, fmt.Errorf("ethereum init: %v", err) } + // If netstats reporting is requested, do it + if config.EthereumNetStats != "" { + if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { + var lesServ *les.LightEthereum + ctx.Service(&lesServ) + + return ethstats.New(config.EthereumNetStats, nil, lesServ) + }); err != nil { + return nil, fmt.Errorf("netstats init: %v", err) + } + } } // Register the Whisper protocol if requested if config.WhisperEnabled { -- cgit v1.2.3