Skip to content

Commit

Permalink
chore: address review
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Oct 13, 2020
1 parent 79d2852 commit 5ae4f29
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/dialer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ const {
MAX_PER_PEER_DIALS
} = require('../constants')

const dns4Code = 54
const dns6Code = 55

class Dialer {
/**
* @class
Expand All @@ -45,9 +42,12 @@ class Dialer {
this.concurrency = concurrency
this.timeout = timeout
this.perPeerLimit = perPeerLimit
this.resolvers = resolvers
this.tokens = [...new Array(concurrency)].map((_, index) => index)
this._pendingDials = new Map()

for (const [key, value] of Object.entries(resolvers)) {
multiaddr.resolvers.set(key, value)
}
}

/**
Expand Down Expand Up @@ -211,10 +211,11 @@ class Dialer {
*/
async _resolve (ma) {
// TODO: recursive logic should live in multiaddr once dns4/dns6 support is in place
const resolvableProto = ma.protos().find((p) => p.resolvable)
// Now only supporting resolve for dnsaddr
const resolvableProto = ma.protoNames().includes('dnsaddr')

// Multiaddr is not resolvable (including exception for dns4/dns6)? End recursion!
if (!resolvableProto || resolvableProto.code === dns4Code || resolvableProto === dns6Code) {
if (!resolvableProto) {
return [ma]
}

Expand All @@ -238,10 +239,6 @@ class Dialer {
* @returns {Promise<Array<Multiaddr>>}
*/
_resolveRecord (ma) {
for (const [key, value] of Object.entries(this.resolvers)) {
ma.resolvers.set(key, value)
}

return ma.resolve()
}
}
Expand Down

0 comments on commit 5ae4f29

Please sign in to comment.