Skip to content
Snippets Groups Projects
Unverified Commit 9dbb3139 authored by Levente Pap's avatar Levente Pap Committed by GitHub
Browse files

:bug: Fix decoding node IDs in analysis server (#503)

parent 57fb70b7
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
analysisserver "github.com/iotaledger/goshimmer/plugins/analysis/server" analysisserver "github.com/iotaledger/goshimmer/plugins/analysis/server"
"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/mr-tron/base58" "github.com/iotaledger/hive.go/identity"
) )
// the period in which we scan and delete old data. // the period in which we scan and delete old data.
...@@ -29,22 +29,22 @@ func configureEventsRecording() { ...@@ -29,22 +29,22 @@ func configureEventsRecording() {
analysisserver.Events.Heartbeat.Attach(events.NewClosure(func(hb *packet.Heartbeat) { analysisserver.Events.Heartbeat.Attach(events.NewClosure(func(hb *packet.Heartbeat) {
var out strings.Builder var out strings.Builder
for _, value := range hb.OutboundIDs { for _, value := range hb.OutboundIDs {
out.WriteString(base58.Encode(value)) out.WriteString(shortNodeIDString(value))
} }
var in strings.Builder var in strings.Builder
for _, value := range hb.InboundIDs { for _, value := range hb.InboundIDs {
in.WriteString(base58.Encode(value)) in.WriteString(shortNodeIDString(value))
} }
log.Debugw( log.Debugw(
"Heartbeat", "Heartbeat",
"nodeId", base58.Encode(hb.OwnID), "nodeId", shortNodeIDString(hb.OwnID),
"outboundIds", out.String(), "outboundIds", out.String(),
"inboundIds", in.String(), "inboundIds", in.String(),
) )
lock.Lock() lock.Lock()
defer lock.Unlock() defer lock.Unlock()
nodeIDString := base58.Encode(hb.OwnID) nodeIDString := shortNodeIDString(hb.OwnID)
timestamp := time.Now() timestamp := time.Now()
// when node is new, add to graph // when node is new, add to graph
...@@ -56,7 +56,7 @@ func configureEventsRecording() { ...@@ -56,7 +56,7 @@ func configureEventsRecording() {
// outgoing neighbor links update // outgoing neighbor links update
for _, outgoingNeighbor := range hb.OutboundIDs { for _, outgoingNeighbor := range hb.OutboundIDs {
outgoingNeighborString := base58.Encode(outgoingNeighbor) outgoingNeighborString := shortNodeIDString(outgoingNeighbor)
// do we already know about this neighbor? // do we already know about this neighbor?
// if no, add it and set it online // if no, add it and set it online
if _, isAlready := nodes[outgoingNeighborString]; !isAlready { if _, isAlready := nodes[outgoingNeighborString]; !isAlready {
...@@ -82,7 +82,7 @@ func configureEventsRecording() { ...@@ -82,7 +82,7 @@ func configureEventsRecording() {
// incoming neighbor links update // incoming neighbor links update
for _, incomingNeighbor := range hb.InboundIDs { for _, incomingNeighbor := range hb.InboundIDs {
incomingNeighborString := base58.Encode(incomingNeighbor) incomingNeighborString := shortNodeIDString(incomingNeighbor)
// do we already know about this neighbor? // do we already know about this neighbor?
// if no, add it and set it online // if no, add it and set it online
if _, isAlready := nodes[incomingNeighborString]; !isAlready { if _, isAlready := nodes[incomingNeighborString]; !isAlready {
...@@ -206,3 +206,9 @@ type EventHandlers struct { ...@@ -206,3 +206,9 @@ type EventHandlers struct {
// EventHandlersConsumer defines the consumer function of an *EventHandlers. // EventHandlersConsumer defines the consumer function of an *EventHandlers.
type EventHandlersConsumer = func(handler *EventHandlers) type EventHandlersConsumer = func(handler *EventHandlers)
func shortNodeIDString(b []byte) string {
var id identity.ID
copy(id[:], b)
return id.String()
}
...@@ -162,7 +162,7 @@ func NewHeartbeatMessage(hb *Heartbeat) ([]byte, error) { ...@@ -162,7 +162,7 @@ func NewHeartbeatMessage(hb *Heartbeat) ([]byte, error) {
return nil, err return nil, err
} }
// write serialized packet bytes into the buffer // write serialized packet bytes into the buffer
if err := binary.Write(buf, binary.LittleEndian, packet); err != nil { if err := binary.Write(buf, binary.BigEndian, packet); err != nil {
return nil, err return nil, err
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment