[ver] add nodeconfig set/get version

Signed-off-by: Leo Chen <leo@harmony.one>
pull/1150/head
Leo Chen 6 years ago
parent f2604e0c8a
commit a45be75e1a
  1. 7
      cmd/harmony/main.go
  2. 12
      internal/configs/node/config.go

@ -55,8 +55,8 @@ func InitLDBDatabase(ip string, port string, freshDB bool, isBeacon bool) (*ethd
return ethdb.NewLDBDatabase(dbFileName, 0, 0) return ethdb.NewLDBDatabase(dbFileName, 0, 0)
} }
func printVersion(me string) { func printVersion() {
fmt.Fprintf(os.Stderr, "Harmony (C) 2018. %v, version %v-%v (%v %v)\n", path.Base(me), version, commit, builtBy, builtAt) fmt.Fprintln(os.Stderr, nodeconfig.GetVersion())
os.Exit(0) os.Exit(0)
} }
@ -432,8 +432,9 @@ func main() {
flag.Var(&utils.BootNodes, "bootnodes", "a list of bootnode multiaddress (delimited by ,)") flag.Var(&utils.BootNodes, "bootnodes", "a list of bootnode multiaddress (delimited by ,)")
flag.Parse() flag.Parse()
nodeconfig.SetVersion(fmt.Sprintf("Harmony (C) 2018. %v, version %v-%v (%v %v)", path.Base(os.Args[0]), version, commit, builtBy, builtAt))
if *versionFlag { if *versionFlag {
printVersion(os.Args[0]) printVersion()
} }
// If FN node running, they should either specify blsPrivateKey or the file with passphrase // If FN node running, they should either specify blsPrivateKey or the file with passphrase

@ -74,6 +74,8 @@ const (
MaxShards = 32 // maximum number of shards. It is also the maxium number of configs. MaxShards = 32 // maximum number of shards. It is also the maxium number of configs.
) )
var version string
// ConfigType is the structure of all node related configuration variables // ConfigType is the structure of all node related configuration variables
type ConfigType struct { type ConfigType struct {
// The three groupID design, please refer to https://github.com/harmony-one/harmony/blob/master/node/node.md#libp2p-integration // The three groupID design, please refer to https://github.com/harmony-one/harmony/blob/master/node/node.md#libp2p-integration
@ -230,3 +232,13 @@ func (conf *ConfigType) SetNetworkType(networkType NetworkType) {
func (conf *ConfigType) GetNetworkType() NetworkType { func (conf *ConfigType) GetNetworkType() NetworkType {
return conf.networkType return conf.networkType
} }
// SetVersion set the version of the node binary
func SetVersion(ver string) {
version = ver
}
// GetVersion return the version of the node binary
func GetVersion() string {
return version
}

Loading…
Cancel
Save