@@ -40,6 +40,8 @@ import (
4040 "github.com/ethereum/go-ethereum/logger/glog"
4141 "github.com/ethereum/go-ethereum/metrics"
4242 "github.com/ethereum/go-ethereum/node"
43+ "github.com/ethereum/go-ethereum/params"
44+ "github.com/ethereum/go-ethereum/rlp"
4345 "gopkg.in/urfave/cli.v1"
4446)
4547
@@ -173,6 +175,7 @@ participating.
173175 utils .VMEnableJitFlag ,
174176 utils .NetworkIdFlag ,
175177 utils .RPCCORSDomainFlag ,
178+ utils .EthStatsURLFlag ,
176179 utils .MetricsEnabledFlag ,
177180 utils .FakePoWFlag ,
178181 utils .SolcPathFlag ,
@@ -254,31 +257,49 @@ func initGenesis(ctx *cli.Context) error {
254257}
255258
256259func makeFullNode (ctx * cli.Context ) * node.Node {
260+ // Create the default extradata and construct the base node
261+ var clientInfo = struct {
262+ Version uint
263+ Name string
264+ GoVersion string
265+ Os string
266+ }{uint (params .VersionMajor << 16 | params .VersionMinor << 8 | params .VersionPatch ), clientIdentifier , runtime .Version (), runtime .GOOS }
267+ extra , err := rlp .EncodeToBytes (clientInfo )
268+ if err != nil {
269+ glog .V (logger .Warn ).Infoln ("error setting canonical miner information:" , err )
270+ }
271+ if uint64 (len (extra )) > params .MaximumExtraDataSize .Uint64 () {
272+ glog .V (logger .Warn ).Infoln ("error setting canonical miner information: extra exceeds" , params .MaximumExtraDataSize )
273+ glog .V (logger .Debug ).Infof ("extra: %x\n " , extra )
274+ extra = nil
275+ }
257276 stack := utils .MakeNode (ctx , clientIdentifier , gitCommit )
258- utils .RegisterEthService (ctx , stack , utils . MakeDefaultExtraData ( clientIdentifier ) )
277+ utils .RegisterEthService (ctx , stack , extra )
259278
260279 // Whisper must be explicitly enabled, but is auto-enabled in --dev mode.
261280 shhEnabled := ctx .GlobalBool (utils .WhisperEnabledFlag .Name )
262281 shhAutoEnabled := ! ctx .GlobalIsSet (utils .WhisperEnabledFlag .Name ) && ctx .GlobalIsSet (utils .DevModeFlag .Name )
263282 if shhEnabled || shhAutoEnabled {
264283 utils .RegisterShhService (stack )
265284 }
266-
285+ // Add the Ethereum Stats daemon if requested
286+ if url := ctx .GlobalString (utils .EthStatsURLFlag .Name ); url != "" {
287+ utils .RegisterEthStatsService (stack , url )
288+ }
267289 // Add the release oracle service so it boots along with node.
268290 if err := stack .Register (func (ctx * node.ServiceContext ) (node.Service , error ) {
269291 config := release.Config {
270292 Oracle : relOracle ,
271- Major : uint32 (utils .VersionMajor ),
272- Minor : uint32 (utils .VersionMinor ),
273- Patch : uint32 (utils .VersionPatch ),
293+ Major : uint32 (params .VersionMajor ),
294+ Minor : uint32 (params .VersionMinor ),
295+ Patch : uint32 (params .VersionPatch ),
274296 }
275297 commit , _ := hex .DecodeString (gitCommit )
276298 copy (config .Commit [:], commit )
277299 return release .NewReleaseService (ctx , config )
278300 }); err != nil {
279301 utils .Fatalf ("Failed to register the Geth release oracle service: %v" , err )
280302 }
281-
282303 return stack
283304}
284305
@@ -342,7 +363,7 @@ func makedag(ctx *cli.Context) error {
342363
343364func version (ctx * cli.Context ) error {
344365 fmt .Println (strings .Title (clientIdentifier ))
345- fmt .Println ("Version:" , utils .Version )
366+ fmt .Println ("Version:" , params .Version )
346367 if gitCommit != "" {
347368 fmt .Println ("Git Commit:" , gitCommit )
348369 }
0 commit comments