Skip to content

Commit

Permalink
fix displaying disconnected clients
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Nov 22, 2024
1 parent 0bb25a2 commit 830bb97
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
23 changes: 15 additions & 8 deletions handlers/clients_cl.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,37 @@ func buildCLPeerMapData() *models.ClientCLPageDataPeerMap {

for _, client := range services.GlobalBeaconService.GetConsensusClients() {
id := client.GetNodeIdentity()

var peerId string
if id == nil {
continue
peerId = fmt.Sprintf("unknown-%d", client.GetIndex())
} else {
peerId = id.PeerID
}
peerID := id.PeerID
if _, ok := nodes[peerID]; !ok {

if _, ok := nodes[peerId]; !ok {
node := models.ClientCLPageDataPeerMapNode{
ID: peerID,
ID: peerId,
Label: client.GetName(),
Group: "internal",
}
nodes[peerID] = &node
nodes[peerId] = &node
peerMap.ClientPageDataMapNode = append(peerMap.ClientPageDataMapNode, &node)
}
}

for _, client := range services.GlobalBeaconService.GetConsensusClients() {
id := client.GetNodeIdentity()

var peerId string
if id == nil {
continue
peerId = fmt.Sprintf("unknown-%d", client.GetIndex())
} else {
peerId = id.PeerID
}
peerId := id.PeerID

peers := client.GetNodePeers()
for _, peer := range peers {
peerId := peerId
// Check if the PeerId is already in the nodes map, if not add it as an "external" node
if _, ok := nodes[peer.PeerID]; !ok {
node := models.ClientCLPageDataPeerMapNode{
Expand Down
7 changes: 3 additions & 4 deletions handlers/clients_el.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func buildELPeerMapData() *models.ClientELPageDataPeerMap {

for _, client := range services.GlobalBeaconService.GetExecutionClients() {
nodeInfo := client.GetNodeInfo()
peerID := "unknown"
peerID := fmt.Sprintf("unknown-%v", client.GetIndex())
var en *enode.Node
var err error
if nodeInfo != nil && nodeInfo.Enode != "" {
Expand Down Expand Up @@ -104,10 +104,9 @@ func buildELPeerMapData() *models.ClientELPageDataPeerMap {
}
}
peers := client.GetNodePeers()
for _, peer := range peers {
nodeID := nodeID
for idx, peer := range peers {
en, err := enode.ParseV4(peer.Enode)
peerID := "unknown"
peerID := fmt.Sprintf("unknown-peer-%v-%v", client.GetIndex(), idx)
if err != nil {
logrus.WithFields(logrus.Fields{"client": client.GetName(), "enode": peer.Enode}).Error("failed to parse peer enode")
} else {
Expand Down

0 comments on commit 830bb97

Please sign in to comment.