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 4d71ae3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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 uninitialized, 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 4d71ae3

Please sign in to comment.