From 2a57d54ef9adba354770b896faecbbf2f40fa668 Mon Sep 17 00:00:00 2001
From: Angelo Capossele <angelocapossele@gmail.com>
Date: Mon, 22 Jun 2020 13:18:27 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20Make=20shown=20nodeIDs=20consist?=
 =?UTF-8?q?ent=20(#515)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 plugins/analysis/dashboard/fpc_livefeed.go      |  3 +--
 plugins/analysis/dashboard/fpc_livefeed_test.go |  3 +--
 plugins/metrics/global_metrics.go               | 10 ++++++++--
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/plugins/analysis/dashboard/fpc_livefeed.go b/plugins/analysis/dashboard/fpc_livefeed.go
index 5d981ac4..1056cae6 100644
--- a/plugins/analysis/dashboard/fpc_livefeed.go
+++ b/plugins/analysis/dashboard/fpc_livefeed.go
@@ -14,7 +14,6 @@ import (
 	"github.com/iotaledger/hive.go/daemon"
 	"github.com/iotaledger/hive.go/events"
 	"github.com/iotaledger/hive.go/workerpool"
-	"github.com/mr-tron/base58/base58"
 )
 
 const (
@@ -98,7 +97,7 @@ func runFPCLiveFeed() {
 func createFPCUpdate(hb *packet.FPCHeartbeat) *FPCUpdate {
 	// prepare the update
 	conflicts := make(conflictSet)
-	nodeID := base58.Encode(hb.OwnID)
+	nodeID := shortNodeIDString(hb.OwnID)
 	for ID, context := range hb.RoundStats.ActiveVoteContexts {
 		newVoteContext := voteContext{
 			NodeID:   nodeID,
diff --git a/plugins/analysis/dashboard/fpc_livefeed_test.go b/plugins/analysis/dashboard/fpc_livefeed_test.go
index 9c2a4f8f..a5c4a8ea 100644
--- a/plugins/analysis/dashboard/fpc_livefeed_test.go
+++ b/plugins/analysis/dashboard/fpc_livefeed_test.go
@@ -7,14 +7,13 @@ import (
 
 	"github.com/iotaledger/goshimmer/packages/vote"
 	"github.com/iotaledger/goshimmer/plugins/analysis/packet"
-	"github.com/mr-tron/base58/base58"
 	"github.com/stretchr/testify/require"
 )
 
 // TestCreateFPCUpdate checks that given a FPC heartbeat, the returned FPCUpdate is ok.
 func TestCreateFPCUpdate(t *testing.T) {
 	ownID := sha256.Sum256([]byte{'A'})
-	base58OwnID := base58.Encode(ownID[:])
+	base58OwnID := shortNodeIDString(ownID[:])
 
 	// create a FPCHeartbeat
 	hbTest := &packet.FPCHeartbeat{
diff --git a/plugins/metrics/global_metrics.go b/plugins/metrics/global_metrics.go
index c6906653..4eee1bf1 100644
--- a/plugins/metrics/global_metrics.go
+++ b/plugins/metrics/global_metrics.go
@@ -6,7 +6,7 @@ import (
 	analysisdashboard "github.com/iotaledger/goshimmer/plugins/analysis/dashboard"
 	"github.com/iotaledger/goshimmer/plugins/analysis/packet"
 	"github.com/iotaledger/hive.go/events"
-	"github.com/mr-tron/base58/base58"
+	"github.com/iotaledger/hive.go/identity"
 	"go.uber.org/atomic"
 )
 
@@ -32,7 +32,7 @@ var (
 var onMetricHeartbeatReceived = events.NewClosure(func(hb *packet.MetricHeartbeat) {
 	nodessMetricsMutex.Lock()
 	defer nodessMetricsMutex.Unlock()
-	nodesMetrics[base58.Encode(hb.OwnID)] = NodeInfo{
+	nodesMetrics[shortNodeIDString(hb.OwnID)] = NodeInfo{
 		OS:          hb.OS,
 		Arch:        hb.Arch,
 		NumCPU:      hb.NumCPU,
@@ -64,3 +64,9 @@ func calculateNetworkDiameter() {
 func NetworkDiameter() int32 {
 	return networkDiameter.Load()
 }
+
+func shortNodeIDString(b []byte) string {
+	var id identity.ID
+	copy(id[:], b)
+	return id.String()
+}
-- 
GitLab