Skip to content

Commit

Permalink
chore: small refactor to make thing clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
2color committed Aug 1, 2024
1 parent da263e6 commit 4a761ff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ func (d *daemon) runCheck(query url.Values) (*output, error) {
return nil, err
}

// User has only passed a PeerID without any maddrs
onlyPeerID := len(ai.Addrs) == 0

c, err := cid.Decode(cidStr)
if err != nil {
return nil, err
Expand All @@ -138,9 +141,10 @@ func (d *daemon) runCheck(query url.Values) (*output, error) {
addrMap, peerAddrDHTErr := peerAddrsInDHT(ctx, d.dht, d.dhtMessenger, ai.ID)
out.PeerFoundInDHT = addrMap

// If peerID given, but no addresses check the DHT
if len(ai.Addrs) == 0 {
// If peerID given,but no addresses check the DHT
if onlyPeerID {
if peerAddrDHTErr != nil {
// PeerID is not resolvable via the DHT
connectionFailed = true
out.ConnectionError = peerAddrDHTErr.Error()
}
Expand Down

0 comments on commit 4a761ff

Please sign in to comment.