diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index 8d1b8b0fe9ce765431b6d52e8b6cd71547639095..af7b3b6e9eb50873f86591e57b71c545c4eb0016 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -88,20 +88,26 @@ func reportHeartbeat(dispatchers *EventDispatchers) { nodeID = local.GetInstance().ID().Bytes() } - // Get outboundIds (chosen neighbors) - outgoingNeighbors := autopeering.Selection.GetOutgoingNeighbors() - outboundIds := make([][]byte, len(outgoingNeighbors)) - for i, neighbor := range outgoingNeighbors { - // Doesn't copy the ID, take care not to modify underlying bytearray! - outboundIds[i] = neighbor.ID().Bytes() - } + var outboundIds [][]byte + var inboundIds [][]byte - // Get inboundIds (accepted neighbors) - incomingNeighbors := autopeering.Selection.GetIncomingNeighbors() - inboundIds := make([][]byte, len(incomingNeighbors)) - for i, neighbor := range incomingNeighbors { - // Doesn't copy the ID, take care not to modify underlying bytearray! - inboundIds[i] = neighbor.ID().Bytes() + // When gossip (and autopeering selection) is enabled, we have neighbors to report + if autopeering.Selection != nil { + // Get outboundIds (chosen neighbors) + outgoingNeighbors := autopeering.Selection.GetOutgoingNeighbors() + outboundIds = make([][]byte, len(outgoingNeighbors)) + for i, neighbor := range outgoingNeighbors { + // Doesn't copy the ID, take care not to modify underlying bytearray! + outboundIds[i] = neighbor.ID().Bytes() + } + + // Get inboundIds (accepted neighbors) + incomingNeighbors := autopeering.Selection.GetIncomingNeighbors() + inboundIds = make([][]byte, len(incomingNeighbors)) + for i, neighbor := range incomingNeighbors { + // Doesn't copy the ID, take care not to modify underlying bytearray! + inboundIds[i] = neighbor.ID().Bytes() + } } packet := &heartbeat.Packet{OwnID: nodeID, OutboundIDs: outboundIds, InboundIDs: inboundIds}