Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.

Commit 7371423

Browse files
committed
chore: address review
1 parent f510e8f commit 7371423

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"aegir": "^32.1.0",
4848
"it-pair": "^1.0.0",
4949
"it-pipe": "^1.1.0",
50-
"libp2p-interfaces": "^0.8.4",
50+
"libp2p-interfaces": "libp2p/js-libp2p-interfaces#chore/update-types",
5151
"streaming-iterables": "^5.0.3",
5252
"util": "^0.12.3"
5353
},

src/ip-port-to-multiaddr.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict'
22

3+
const debug = require('debug')
4+
const log = Object.assign(debug('libp2p:ip-port-to-multiaddr'), {
5+
error: debug('libp2p:ip-port-to-multiaddr:err')
6+
})
37
const multiaddr = require('multiaddr')
48
const errCode = require('err-code')
59
const { Address4, Address6 } = require('ip-address')
@@ -33,7 +37,7 @@ function ipPortToMultiaddr (ip, port) {
3337
// Test valid IPv4
3438
new Address4(ip) // eslint-disable-line no-new
3539
return multiaddr(`/ip4/${ip}/tcp/${port}`)
36-
} catch (_) {}
40+
} catch {}
3741

3842
try {
3943
// Test valid IPv6
@@ -42,7 +46,9 @@ function ipPortToMultiaddr (ip, port) {
4246
? multiaddr(`/ip4/${ip6.to4().correctForm()}/tcp/${port}`)
4347
: multiaddr(`/ip6/${ip}/tcp/${port}`)
4448
} catch (err) {
45-
throw errCode(new Error(`invalid ip:port for creating a multiaddr: ${ip}:${port}`), errors.ERR_INVALID_IP)
49+
const errMsg = `invalid ip:port for creating a multiaddr: ${ip}:${port}`
50+
log.error(errMsg)
51+
throw errCode(new Error(errMsg), errors.ERR_INVALID_IP)
4652
}
4753
}
4854

src/stream-to-ma-conn.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const abortable = require('abortable-iterator')
3+
const { source: abortable } = require('abortable-iterator')
44
const debug = require('debug')
55
const log = debug('libp2p:stream:converter')
66

@@ -25,6 +25,7 @@ const log = debug('libp2p:stream:converter')
2525
* @param {Multiaddr} streamProperties.localAddr
2626
* @param {object} [options]
2727
* @param {AbortSignal} [options.signal]
28+
* @returns {MultiaddrConnection}
2829
*/
2930
function streamToMaConnection ({ stream, remoteAddr, localAddr }, options = {}) {
3031
const { sink, source } = stream
@@ -51,7 +52,6 @@ function streamToMaConnection ({ stream, remoteAddr, localAddr }, options = {})
5152
}
5253
close()
5354
},
54-
// @ts-ignore abortable has no type definitions
5555
source: options.signal ? abortable(source, options.signal) : source,
5656
conn: stream,
5757
localAddr,

0 commit comments

Comments
 (0)