diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-04-28 17:00:11 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-05-02 21:20:21 +0800 |
commit | 586eddfd09558bfd71f23c2e50c270d2ca665d49 (patch) | |
tree | 4015e542e0397c606d1f14ef23d15463881be554 /cmd | |
parent | d46da273c6731512b4114393856a96be06505797 (diff) | |
download | dexon-586eddfd09558bfd71f23c2e50c270d2ca665d49.tar.gz dexon-586eddfd09558bfd71f23c2e50c270d2ca665d49.tar.zst dexon-586eddfd09558bfd71f23c2e50c270d2ca665d49.zip |
release, all: integrate the release service into geth
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/geth/main.go | 59 | ||||
-rw-r--r-- | cmd/utils/flags.go | 14 |
2 files changed, 43 insertions, 30 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index ffeb7c1e5..a023497a7 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -18,6 +18,7 @@ package main import ( + "encoding/hex" "fmt" "io/ioutil" "os" @@ -41,31 +42,48 @@ import ( "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/release" "github.com/ethereum/go-ethereum/rlp" ) const ( - ClientIdentifier = "Geth" - Version = "1.5.0-unstable" - VersionMajor = 1 - VersionMinor = 5 - VersionPatch = 0 + clientIdentifier = "Geth" // Client identifier to advertise over the network + versionMajor = 1 // Major version component of the current release + versionMinor = 5 // Minor version component of the current release + versionPatch = 0 // Patch version component of the current release + versionMeta = "unstable" // Version metadata to append to the version string + + versionOracle = "0x48a117313039b73ab02fb9f73e04a66defe123ec" // Ethereum address of the Geth release oracle ) var ( - gitCommit string // set via linker flagg - nodeNameVersion string - app *cli.App + gitCommit string // Git SHA1 commit hash of the release (set via linker flags) + verString string // Combined textual representation of all the version components + relConfig release.Config // Structured version information and release oracle config + app *cli.App ) func init() { - if gitCommit == "" { - nodeNameVersion = Version - } else { - nodeNameVersion = Version + "-" + gitCommit[:8] + // Construct the textual version string from the individual components + verString = fmt.Sprintf("%d.%d.%d", versionMajor, versionMinor, versionPatch) + if versionMeta != "" { + verString += "-" + versionMeta + } + if gitCommit != "" { + verString += "-" + gitCommit[:8] } + // Construct the version release oracle configuration + relConfig.Oracle = common.HexToAddress(versionOracle) - app = utils.NewApp(Version, "the go-ethereum command line interface") + relConfig.Major = uint32(versionMajor) + relConfig.Minor = uint32(versionMinor) + relConfig.Patch = uint32(versionPatch) + + commit, _ := hex.DecodeString(gitCommit) + copy(relConfig.Commit[:], commit) + + // Initialize the CLI app and start Geth + app = utils.NewApp(verString, "the go-ethereum command line interface") app.Action = geth app.HideVersion = true // we have a command to print the version app.Commands = []cli.Command{ @@ -257,7 +275,7 @@ func makeDefaultExtra() []byte { Name string GoVersion string Os string - }{uint(VersionMajor<<16 | VersionMinor<<8 | VersionPatch), ClientIdentifier, runtime.Version(), runtime.GOOS} + }{uint(versionMajor<<16 | versionMinor<<8 | versionPatch), clientIdentifier, runtime.Version(), runtime.GOOS} extra, err := rlp.EncodeToBytes(clientInfo) if err != nil { glog.V(logger.Warn).Infoln("error setting canonical miner information:", err) @@ -275,7 +293,7 @@ func makeDefaultExtra() []byte { // It creates a default node based on the command line arguments and runs it in // blocking mode, waiting for it to be shut down. func geth(ctx *cli.Context) { - node := utils.MakeSystemNode(ClientIdentifier, nodeNameVersion, makeDefaultExtra(), ctx) + node := utils.MakeSystemNode(clientIdentifier, verString, relConfig, makeDefaultExtra(), ctx) startNode(ctx, node) node.Wait() } @@ -339,7 +357,7 @@ func initGenesis(ctx *cli.Context) { // same time. func console(ctx *cli.Context) { // Create and start the node based on the CLI flags - node := utils.MakeSystemNode(ClientIdentifier, nodeNameVersion, makeDefaultExtra(), ctx) + node := utils.MakeSystemNode(clientIdentifier, verString, relConfig, makeDefaultExtra(), ctx) startNode(ctx, node) // Attach to the newly started node, and either execute script or become interactive @@ -372,7 +390,7 @@ func console(ctx *cli.Context) { // of the JavaScript files specified as command arguments. func execScripts(ctx *cli.Context) { // Create and start the node based on the CLI flags - node := utils.MakeSystemNode(ClientIdentifier, nodeNameVersion, makeDefaultExtra(), ctx) + node := utils.MakeSystemNode(clientIdentifier, verString, relConfig, makeDefaultExtra(), ctx) startNode(ctx, node) defer node.Stop() @@ -488,11 +506,8 @@ func gpubench(ctx *cli.Context) { } func version(c *cli.Context) { - fmt.Println(ClientIdentifier) - fmt.Println("Version:", Version) - if gitCommit != "" { - fmt.Println("Git Commit:", gitCommit) - } + fmt.Println(clientIdentifier) + fmt.Println("Version:", version) fmt.Println("Protocol Versions:", eth.ProtocolVersions) fmt.Println("Network Id:", c.GlobalInt(utils.NetworkIdFlag.Name)) fmt.Println("Go Version:", runtime.Version()) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 86e9e9b0d..43dbc37f7 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -34,7 +34,6 @@ import ( "github.com/ethereum/ethash" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/versions" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/crypto" @@ -49,6 +48,7 @@ import ( "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/pow" + "github.com/ethereum/go-ethereum/release" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/whisper" ) @@ -642,7 +642,7 @@ func MakePasswordList(ctx *cli.Context) []string { // MakeSystemNode sets up a local node, configures the services to launch and // assembles the P2P protocol stack. -func MakeSystemNode(name, version string, extra []byte, ctx *cli.Context) *node.Node { +func MakeSystemNode(name, version string, relconf release.Config, extra []byte, ctx *cli.Context) *node.Node { // Avoid conflicting network flags networks, netFlags := 0, []cli.BoolFlag{DevModeFlag, TestNetFlag, OlympicFlag} for _, flag := range netFlags { @@ -773,12 +773,10 @@ func MakeSystemNode(name, version string, extra []byte, ctx *cli.Context) *node. Fatalf("Failed to register the Whisper service: %v", err) } } - - err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { - return versions.NewVersionCheck(ctx) - }) - if err != nil { - Fatalf("Failed to register the Version Check service: %v", err) + if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { + return release.NewReleaseService(ctx, relconf) + }); err != nil { + Fatalf("Failed to register the Geth release oracle service: %v", err) } return stack } |