|
1 | 1 | import { CodeError } from '@libp2p/interface'
|
2 | 2 | import { ipPortToMultiaddr as toMultiaddr } from '@libp2p/utils/ip-port-to-multiaddr'
|
3 |
| -// @ts-expect-error no types |
4 |
| -import toIterable from 'stream-to-it' |
| 3 | +import { duplex } from 'stream-to-it' |
5 | 4 | import { CLOSE_TIMEOUT, SOCKET_TIMEOUT } from './constants.js'
|
6 | 5 | import { multiaddrToNetConfig } from './utils.js'
|
7 | 6 | import type { ComponentLogger, MultiaddrConnection, CounterGroup } from '@libp2p/interface'
|
@@ -55,7 +54,7 @@ export const toMultiaddrConnection = (socket: Socket, options: ToConnectionOptio
|
55 | 54 |
|
56 | 55 | const lOpts = multiaddrToNetConfig(remoteAddr)
|
57 | 56 | const lOptsStr = lOpts.path ?? `${lOpts.host ?? ''}:${lOpts.port ?? ''}`
|
58 |
| - const { sink, source } = toIterable.duplex(socket) |
| 57 | + const { sink, source } = duplex(socket) |
59 | 58 |
|
60 | 59 | // by default there is no timeout
|
61 | 60 | // https://nodejs.org/dist/latest-v16.x/docs/api/net.html#socketsettimeouttimeout-callback
|
@@ -109,7 +108,7 @@ export const toMultiaddrConnection = (socket: Socket, options: ToConnectionOptio
|
109 | 108 | // If aborted we can safely ignore
|
110 | 109 | if (err.type !== 'aborted') {
|
111 | 110 | // If the source errored the socket will already have been destroyed by
|
112 |
| - // toIterable.duplex(). If the socket errored it will already be |
| 111 | + // duplex(). If the socket errored it will already be |
113 | 112 | // destroyed. There's nothing to do here except log the error & return.
|
114 | 113 | log.error('%s error in sink', lOptsStr, err)
|
115 | 114 | }
|
|
0 commit comments