Skip to content

Commit

Permalink
fix consensus light client status shows empty peer IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Oct 19, 2023
1 parent f63c447 commit b2744c3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions .changelog/5408.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix showing empty peer IDs in the Consensus light client status output
2 changes: 2 additions & 0 deletions go/consensus/cometbft/light/p2p/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ func (lp *lightClientProvider) Initialized() <-chan struct{} {
func (lp *lightClientProvider) PeerID() string {
peer := lp.getPeer()
if peer == nil {
// This happens if a provider is not yet initialized, or
// (unlikely) if a peer was just dropped and no new peer is available.
return ""
}
return peer.String()
Expand Down
4 changes: 3 additions & 1 deletion go/consensus/cometbft/light/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ func (c *client) GetStatus() (*consensus.LightClientStatus, error) {
}

for _, p := range c.providers {
status.PeerIDs = append(status.PeerIDs, p.PeerID())
if id := p.PeerID(); id != "" {
status.PeerIDs = append(status.PeerIDs, id)
}
}

return status, nil
Expand Down

0 comments on commit b2744c3

Please sign in to comment.