Skip to content

Commit

Permalink
fix peer peerids
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Nov 22, 2024
1 parent 89bfe97 commit 3d9483b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion handlers/clients_cl.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,17 @@ func buildCLClientsPageData() (*models.ClientsCLPageData, time.Duration) {
Type: "internal",
}
if id != nil {
if node.ENR == "" {
node.ENR = id.Enr
} else if node.ENR != "" {
// Need to compare `seq` field from ENRs and only store highest
nodeENR := parseEnrRecord(node.ENR)
idENR := parseEnrRecord(id.Enr)
if nodeENR != nil && idENR != nil && idENR.Seq() > nodeENR.Seq() {
node.ENR = id.Enr // idENR has higher sequence number, so override.
}
}

node.ENR = id.Enr
}
pageData.Nodes[peerId] = node
Expand All @@ -272,7 +283,7 @@ func buildCLClientsPageData() (*models.ClientsCLPageData, time.Duration) {
addPeerNode(peer)

peerNode := &models.ClientCLPageDataNodePeers{
PeerID: peerId,
PeerID: peer.PeerID,
State: peer.State,
Direction: peer.Direction,
LastSeenP2PAddress: peer.LastSeenP2PAddress,
Expand Down
2 changes: 1 addition & 1 deletion templates/clients/clients_cl.html
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ <h5 class="modal-title" id="peerDasWarningsModal">👀 PeerDAS: Some problems we
<p>Some other node reported a higher sequence number than this one.
<code data-bind="text: 'seq=' + $root.getEnrValue(enr_kv, 'seq')"></code> vs <code data-bind="text: 'seq=' + $root.getEnrValue($node.enr_kv, 'seq')"></code>
</p>
<p>ENR: <code data-bind="text: enr"></code></p>
<p>ENR: <code data-bind="text: $node.enr"></code></p>
{{ html "<!-- /ko -->" }}
</div>
{{ html "<!-- /ko -->" }}
Expand Down

0 comments on commit 3d9483b

Please sign in to comment.