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

Fix #372 Analysis client plugin panic without gossip (#384)

parent f9a8cf20
No related branches found
No related tags found
No related merge requests found
......@@ -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}
......
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