Skip to content
Snippets Groups Projects
Unverified Commit 2a57d54e authored by Angelo Capossele's avatar Angelo Capossele Committed by GitHub
Browse files

:lipstick: Make shown nodeIDs consistent (#515)

parent f4b7f3f8
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,6 @@ import ( ...@@ -14,7 +14,6 @@ import (
"github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/daemon"
"github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/workerpool" "github.com/iotaledger/hive.go/workerpool"
"github.com/mr-tron/base58/base58"
) )
const ( const (
...@@ -98,7 +97,7 @@ func runFPCLiveFeed() { ...@@ -98,7 +97,7 @@ func runFPCLiveFeed() {
func createFPCUpdate(hb *packet.FPCHeartbeat) *FPCUpdate { func createFPCUpdate(hb *packet.FPCHeartbeat) *FPCUpdate {
// prepare the update // prepare the update
conflicts := make(conflictSet) conflicts := make(conflictSet)
nodeID := base58.Encode(hb.OwnID) nodeID := shortNodeIDString(hb.OwnID)
for ID, context := range hb.RoundStats.ActiveVoteContexts { for ID, context := range hb.RoundStats.ActiveVoteContexts {
newVoteContext := voteContext{ newVoteContext := voteContext{
NodeID: nodeID, NodeID: nodeID,
......
...@@ -7,14 +7,13 @@ import ( ...@@ -7,14 +7,13 @@ import (
"github.com/iotaledger/goshimmer/packages/vote" "github.com/iotaledger/goshimmer/packages/vote"
"github.com/iotaledger/goshimmer/plugins/analysis/packet" "github.com/iotaledger/goshimmer/plugins/analysis/packet"
"github.com/mr-tron/base58/base58"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
// TestCreateFPCUpdate checks that given a FPC heartbeat, the returned FPCUpdate is ok. // TestCreateFPCUpdate checks that given a FPC heartbeat, the returned FPCUpdate is ok.
func TestCreateFPCUpdate(t *testing.T) { func TestCreateFPCUpdate(t *testing.T) {
ownID := sha256.Sum256([]byte{'A'}) ownID := sha256.Sum256([]byte{'A'})
base58OwnID := base58.Encode(ownID[:]) base58OwnID := shortNodeIDString(ownID[:])
// create a FPCHeartbeat // create a FPCHeartbeat
hbTest := &packet.FPCHeartbeat{ hbTest := &packet.FPCHeartbeat{
......
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
analysisdashboard "github.com/iotaledger/goshimmer/plugins/analysis/dashboard" analysisdashboard "github.com/iotaledger/goshimmer/plugins/analysis/dashboard"
"github.com/iotaledger/goshimmer/plugins/analysis/packet" "github.com/iotaledger/goshimmer/plugins/analysis/packet"
"github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/events"
"github.com/mr-tron/base58/base58" "github.com/iotaledger/hive.go/identity"
"go.uber.org/atomic" "go.uber.org/atomic"
) )
...@@ -32,7 +32,7 @@ var ( ...@@ -32,7 +32,7 @@ var (
var onMetricHeartbeatReceived = events.NewClosure(func(hb *packet.MetricHeartbeat) { var onMetricHeartbeatReceived = events.NewClosure(func(hb *packet.MetricHeartbeat) {
nodessMetricsMutex.Lock() nodessMetricsMutex.Lock()
defer nodessMetricsMutex.Unlock() defer nodessMetricsMutex.Unlock()
nodesMetrics[base58.Encode(hb.OwnID)] = NodeInfo{ nodesMetrics[shortNodeIDString(hb.OwnID)] = NodeInfo{
OS: hb.OS, OS: hb.OS,
Arch: hb.Arch, Arch: hb.Arch,
NumCPU: hb.NumCPU, NumCPU: hb.NumCPU,
...@@ -64,3 +64,9 @@ func calculateNetworkDiameter() { ...@@ -64,3 +64,9 @@ func calculateNetworkDiameter() {
func NetworkDiameter() int32 { func NetworkDiameter() int32 {
return networkDiameter.Load() return networkDiameter.Load()
} }
func shortNodeIDString(b []byte) string {
var id identity.ID
copy(id[:], b)
return id.String()
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment