diff --git a/plugins/analysis/client/fpc_heartbeato.go b/plugins/analysis/client/fpc_heartbeato.go index 4d0f72b19921cbabd86dc6fb9da89205114e00cc..50467520866e08fd03d494acf9f535fa654a9de6 100644 --- a/plugins/analysis/client/fpc_heartbeato.go +++ b/plugins/analysis/client/fpc_heartbeato.go @@ -39,7 +39,7 @@ func onRoundExecuted(roundStats *vote.RoundStats) { } hb := &packet.FPCHeartbeat{ - Version: banner.AppVersion, + Version: banner.SimplifiedAppVersion, OwnID: nodeID, RoundStats: rs, } diff --git a/plugins/analysis/client/heartbeat.go b/plugins/analysis/client/heartbeat.go index f5bda8985fb2271789a45086e3bb057b63f49706..c3a8397cc529264ac68d7d322e96b9250dd28d26 100644 --- a/plugins/analysis/client/heartbeat.go +++ b/plugins/analysis/client/heartbeat.go @@ -75,5 +75,5 @@ func createHeartbeat() *packet.Heartbeat { copy(inboundIDs[i], neighbor.ID().Bytes()) } - return &packet.Heartbeat{NetworkID: []byte(banner.AppVersion), OwnID: nodeID, OutboundIDs: outboundIDs, InboundIDs: inboundIDs} + return &packet.Heartbeat{NetworkID: []byte(banner.SimplifiedAppVersion), OwnID: nodeID, OutboundIDs: outboundIDs, InboundIDs: inboundIDs} } diff --git a/plugins/analysis/client/metric_heartbeat.go b/plugins/analysis/client/metric_heartbeat.go index 8586713a76e6bdd3e0d91a1add09d54990375128..47b54d1c556e46cd0b6ddc05b531066426401376 100644 --- a/plugins/analysis/client/metric_heartbeat.go +++ b/plugins/analysis/client/metric_heartbeat.go @@ -35,7 +35,7 @@ func createMetricHeartbeat() *packet.MetricHeartbeat { } return &packet.MetricHeartbeat{ - Version: banner.AppVersion, + Version: banner.SimplifiedAppVersion, OwnID: nodeID, OS: runtime.GOOS, Arch: runtime.GOARCH, diff --git a/plugins/analysis/packet/fpc_heartbeat.go b/plugins/analysis/packet/fpc_heartbeat.go index 3870a860f6c5401dbea3aac176e53c25526260a0..4ab7759dad5f32338c3b7c22cc7cba36f5cda684 100644 --- a/plugins/analysis/packet/fpc_heartbeat.go +++ b/plugins/analysis/packet/fpc_heartbeat.go @@ -62,7 +62,7 @@ func ParseFPCHeartbeat(data []byte) (*FPCHeartbeat, error) { return nil, err } - if hb.Version != banner.AppVersion { + if hb.Version != banner.SimplifiedAppVersion { return nil, ErrInvalidFPCHeartbeatVersion } diff --git a/plugins/analysis/packet/fpc_heartbeat_test.go b/plugins/analysis/packet/fpc_heartbeat_test.go index 2ccc465c29882c538970f15ed4d8cd87f29dd472..50bc7bd7b5970ef8d3087225de47473910f30086 100644 --- a/plugins/analysis/packet/fpc_heartbeat_test.go +++ b/plugins/analysis/packet/fpc_heartbeat_test.go @@ -46,7 +46,7 @@ func TestFPCHeartbeat(t *testing.T) { _, err = ParseFPCHeartbeat(packet) require.Error(t, err) - hb.Version = banner.AppVersion + hb.Version = banner.SimplifiedAppVersion packet, err = hb.Bytes() require.NoError(t, err) diff --git a/plugins/analysis/packet/metric_heartbeat.go b/plugins/analysis/packet/metric_heartbeat.go index ef2a0f326440106d95240b4deaf346145995db35..726a4831125f1e3f3c10b1b88c79b2e23c668b1e 100644 --- a/plugins/analysis/packet/metric_heartbeat.go +++ b/plugins/analysis/packet/metric_heartbeat.go @@ -60,7 +60,7 @@ func ParseMetricHeartbeat(data []byte) (*MetricHeartbeat, error) { return nil, err } - if hb.Version != banner.AppVersion { + if hb.Version != banner.SimplifiedAppVersion { return nil, ErrInvalidMetricHeartbeatVersion } diff --git a/plugins/analysis/packet/metric_heartbeat_test.go b/plugins/analysis/packet/metric_heartbeat_test.go index f3b8cc8262a354320e6351c50f3227d64065bb97..9f5a080d9fe9f3cac6d8313751555716a3557bfc 100644 --- a/plugins/analysis/packet/metric_heartbeat_test.go +++ b/plugins/analysis/packet/metric_heartbeat_test.go @@ -45,7 +45,7 @@ func TestMetricHeartbeat(t *testing.T) { _, err = ParseMetricHeartbeat(packet) require.Error(t, err) - hb.Version = banner.AppVersion + hb.Version = banner.SimplifiedAppVersion packet, err = hb.Bytes() require.NoError(t, err) diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index c6a1a7bd21f2fcd3c2962b123bd8ad0c0d94bbe5..b2a55e3e5c199d0b5b74d28f8e50edf1568508d4 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -148,7 +148,7 @@ func processHeartbeatPacket(data []byte) { } // processHeartbeatPacket parses the serialized data into a FPC Heartbeat packet and triggers its event. -// Note that the processFPCHeartbeatPacket function will return an error if the hb version field is different than banner.AppVersion, +// Note that the processFPCHeartbeatPacket function will return an error if the hb version field is different than banner.SimplifiedAppVersion, // thus the hb will be discarded. func processFPCHeartbeatPacket(data []byte) { hb, err := packet.ParseFPCHeartbeat(data) @@ -162,7 +162,7 @@ func processFPCHeartbeatPacket(data []byte) { } // processMetricHeartbeatPacket parses the serialized data into a Metric Heartbeat packet and triggers its event. -// Note that the ParseMetricHeartbeat function will return an error if the hb version field is different than banner.AppVersion, +// Note that the ParseMetricHeartbeat function will return an error if the hb version field is different than banner.SimplifiedAppVersion, // thus the hb will be discarded. func processMetricHeartbeatPacket(data []byte) { hb, err := packet.ParseMetricHeartbeat(data) diff --git a/plugins/banner/plugin.go b/plugins/banner/plugin.go index 763a01ea4f9c94064162febe60c04df127bd7749..6172958a995f8e345f36984ce7965a5ce5d3fee2 100644 --- a/plugins/banner/plugin.go +++ b/plugins/banner/plugin.go @@ -2,6 +2,7 @@ package banner import ( "fmt" + "strings" "sync" "github.com/iotaledger/hive.go/node" @@ -14,12 +15,14 @@ var ( // plugin is the plugin instance of the banner plugin. plugin *node.Plugin once sync.Once -) -const ( // AppVersion version number AppVersion = "v0.3.0" + // SimplifiedAppVersion is the version number without commit hash + SimplifiedAppVersion string +) +const ( // AppName app code name AppName = "GoShimmer" ) @@ -44,8 +47,23 @@ func configure(ctx *node.Plugin) { `, AppVersion) fmt.Println() + SimplifiedAppVersion = simplifiedVersion(AppVersion) + ctx.Node.Logger.Infof("GoShimmer version %s ...", AppVersion) ctx.Node.Logger.Info("Loading plugins ...") } func run(ctx *node.Plugin) {} + +func simplifiedVersion(version string) string { + // ignore commit hash + ver := version + if strings.Contains(ver, "-") { + ver = strings.Split(ver, "-")[0] + } + // attach a "v" at front + if !strings.Contains(ver, "v") { + ver = "v" + ver + } + return ver +} diff --git a/plugins/metrics/global_metrics.go b/plugins/metrics/global_metrics.go index 80e32fddfa4723b21594fbe88d452cbf7111408d..07f3f2cd96902a31de383bb9d5965129ff16fab0 100644 --- a/plugins/metrics/global_metrics.go +++ b/plugins/metrics/global_metrics.go @@ -58,8 +58,8 @@ func NodesMetrics() map[string]NodeInfo { func calculateNetworkDiameter() { diameter := 0 // TODO: send data for all available networkIDs, not just current - if analysisserver.Networks[banner.AppVersion] != nil { - g := analysisserver.Networks[banner.AppVersion].NetworkGraph() + if analysisserver.Networks[banner.SimplifiedAppVersion] != nil { + g := analysisserver.Networks[banner.SimplifiedAppVersion].NetworkGraph() diameter = g.Diameter() } networkDiameter.Store(int32(diameter)) diff --git a/plugins/prometheus/global_metrics.go b/plugins/prometheus/global_metrics.go index 6767a5cc8268d7615de99e7c9cbaed70a2f6019c..37282493f312794eb835d617c74f3a3b9fd672d8 100644 --- a/plugins/prometheus/global_metrics.go +++ b/plugins/prometheus/global_metrics.go @@ -182,8 +182,8 @@ func collectNodesInfo() { } // TODO: send data for all available networkIDs, not just current - if analysisserver.Networks[banner.AppVersion] != nil { - for nodeID, neighborCount := range analysisserver.Networks[banner.AppVersion].NumOfNeighbors() { + if analysisserver.Networks[banner.SimplifiedAppVersion] != nil { + for nodeID, neighborCount := range analysisserver.Networks[banner.SimplifiedAppVersion].NumOfNeighbors() { nodesNeighborCount.WithLabelValues(nodeID, "in").Set(float64(neighborCount.Inbound)) nodesNeighborCount.WithLabelValues(nodeID, "out").Set(float64(neighborCount.Outbound)) } diff --git a/plugins/remotelog/plugin.go b/plugins/remotelog/plugin.go index a7018f70d305b617cf569ea5e70c5c1700fbd692..80f7bc32229725955989e66bc87892d762d0b40d 100644 --- a/plugins/remotelog/plugin.go +++ b/plugins/remotelog/plugin.go @@ -105,7 +105,7 @@ func run(plugin *node.Plugin) { func sendLogMsg(level logger.Level, name string, msg string) { m := logMessage{ - banner.AppVersion, + banner.SimplifiedAppVersion, myGitHead, myGitBranch, myID,