Skip to content

Commit

Permalink
Merge pull request #5408 from oasisprotocol/ptrus/fix/empty-peer-id
Browse files Browse the repository at this point in the history
fix consensus light client status shows empty peer IDs
  • Loading branch information
ptrus authored Oct 19, 2023
2 parents 0d68f8a + 993d58e commit 1b654de
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
// (less likely) 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 1b654de

Please sign in to comment.