Skip to content
Snippets Groups Projects
Unverified Commit d03042f7 authored by jkrvivian's avatar jkrvivian
Browse files

feat: Add commit tag to version

parent a31747e6
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ func onRoundExecuted(roundStats *vote.RoundStats) {
}
hb := &packet.FPCHeartbeat{
Version: banner.AppVersion,
Version: banner.SimplifiedAppVersion,
OwnID: nodeID,
RoundStats: rs,
}
......
......@@ -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}
}
......@@ -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,
......
......@@ -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
}
......
......@@ -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)
......
......@@ -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
}
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
}
......@@ -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))
......
......@@ -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))
}
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment