Skip to content

Commit

Permalink
fix ipfs swarm peering crash in offline mode
Browse files Browse the repository at this point in the history
Fixes: #8699
  • Loading branch information
aya committed Sep 9, 2022
1 parent b8412ef commit 1f67e84
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/commands/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ var swarmPeeringAddCmd = &cmds.Command{
if err != nil {
return err
}
if node.PeerHost == nil {
return ErrNotOnline
}

for _, addrinfo := range addInfos {
node.Peering.AddPeer(addrinfo)
Expand Down Expand Up @@ -153,6 +156,10 @@ var swarmPeeringLsCmd = &cmds.Command{
if err != nil {
return err
}
if node.PeerHost == nil {
return ErrNotOnline
}

peers := node.Peering.ListPeers()
return cmds.EmitOnce(res, addrInfos{Peers: peers})
},
Expand Down Expand Up @@ -189,6 +196,9 @@ var swarmPeeringRmCmd = &cmds.Command{
if err != nil {
return err
}
if node.PeerHost == nil {
return ErrNotOnline
}

for _, arg := range req.Arguments {
id, err := peer.Decode(arg)
Expand Down

0 comments on commit 1f67e84

Please sign in to comment.