libp2p 0.45.9 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -77
- package/dist/index.min.js +27 -27
- package/dist/src/address-manager/index.d.ts +5 -5
- package/dist/src/address-manager/index.d.ts.map +1 -1
- package/dist/src/address-manager/utils.d.ts.map +1 -1
- package/dist/src/address-manager/utils.js.map +1 -1
- package/dist/src/autonat/index.d.ts +26 -6
- package/dist/src/autonat/index.d.ts.map +1 -1
- package/dist/src/autonat/index.js +23 -3
- package/dist/src/autonat/index.js.map +1 -1
- package/dist/src/circuit-relay/index.d.ts +36 -1
- package/dist/src/circuit-relay/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/index.js +35 -0
- package/dist/src/circuit-relay/index.js.map +1 -1
- package/dist/src/circuit-relay/server/advert-service.d.ts +3 -3
- package/dist/src/circuit-relay/server/advert-service.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/advert-service.js +1 -1
- package/dist/src/circuit-relay/server/advert-service.js.map +1 -1
- package/dist/src/circuit-relay/server/index.d.ts +8 -8
- package/dist/src/circuit-relay/server/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/index.js +30 -28
- package/dist/src/circuit-relay/server/index.js.map +1 -1
- package/dist/src/circuit-relay/server/reservation-store.d.ts +3 -3
- package/dist/src/circuit-relay/server/reservation-store.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/reservation-voucher.d.ts +2 -2
- package/dist/src/circuit-relay/transport/discovery.d.ts +8 -8
- package/dist/src/circuit-relay/transport/discovery.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/discovery.js +3 -4
- package/dist/src/circuit-relay/transport/discovery.js.map +1 -1
- package/dist/src/circuit-relay/transport/index.d.ts +21 -10
- package/dist/src/circuit-relay/transport/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/index.js +52 -25
- package/dist/src/circuit-relay/transport/index.js.map +1 -1
- package/dist/src/circuit-relay/transport/listener.d.ts +2 -2
- package/dist/src/circuit-relay/transport/listener.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/listener.js +4 -3
- package/dist/src/circuit-relay/transport/listener.js.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.d.ts +13 -7
- package/dist/src/circuit-relay/transport/reservation-store.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.js +24 -10
- package/dist/src/circuit-relay/transport/reservation-store.js.map +1 -1
- package/dist/src/circuit-relay/utils.d.ts +1 -1
- package/dist/src/components.d.ts +15 -14
- package/dist/src/components.d.ts.map +1 -1
- package/dist/src/components.js +2 -2
- package/dist/src/components.js.map +1 -1
- package/dist/src/config/connection-gater.browser.d.ts +1 -1
- package/dist/src/config/connection-gater.d.ts +1 -1
- package/dist/src/config.d.ts +1 -2
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +2 -2
- package/dist/src/config.js.map +1 -1
- package/dist/src/connection/index.d.ts +22 -13
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection/index.js +54 -30
- package/dist/src/connection/index.js.map +1 -1
- package/dist/src/connection-manager/auto-dial.d.ts +5 -5
- package/dist/src/connection-manager/auto-dial.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dial.js +3 -1
- package/dist/src/connection-manager/auto-dial.js.map +1 -1
- package/dist/src/connection-manager/connection-pruner.d.ts +4 -4
- package/dist/src/connection-manager/connection-pruner.d.ts.map +1 -1
- package/dist/src/connection-manager/connection-pruner.js +2 -2
- package/dist/src/connection-manager/connection-pruner.js.map +1 -1
- package/dist/src/connection-manager/constants.d.ts.map +1 -1
- package/dist/src/connection-manager/constants.js.map +1 -1
- package/dist/src/connection-manager/dial-queue.d.ts +11 -17
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +6 -6
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts +11 -12
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +17 -11
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/content-routing/index.d.ts +5 -5
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +1 -1
- package/dist/src/content-routing/index.js.map +1 -1
- package/dist/src/content-routing/utils.d.ts +2 -2
- package/dist/src/content-routing/utils.js +1 -1
- package/dist/src/content-routing/utils.js.map +1 -1
- package/dist/src/fetch/constants.d.ts.map +1 -1
- package/dist/src/fetch/constants.js.map +1 -1
- package/dist/src/fetch/index.d.ts +5 -5
- package/dist/src/fetch/index.d.ts.map +1 -1
- package/dist/src/fetch/index.js +5 -5
- package/dist/src/fetch/index.js.map +1 -1
- package/dist/src/get-peer.d.ts +1 -1
- package/dist/src/get-peer.js +2 -2
- package/dist/src/get-peer.js.map +1 -1
- package/dist/src/identify/consts.d.ts.map +1 -1
- package/dist/src/identify/consts.js.map +1 -1
- package/dist/src/identify/identify.d.ts +8 -7
- package/dist/src/identify/identify.d.ts.map +1 -1
- package/dist/src/identify/identify.js +66 -72
- package/dist/src/identify/identify.js.map +1 -1
- package/dist/src/identify/index.d.ts +28 -9
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/identify/index.js.map +1 -1
- package/dist/src/index.d.ts +11 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/insecure/index.d.ts +1 -1
- package/dist/src/insecure/index.js +1 -1
- package/dist/src/insecure/index.js.map +1 -1
- package/dist/src/libp2p.d.ts +13 -13
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +13 -8
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/peer-routing.d.ts +5 -5
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +1 -1
- package/dist/src/peer-routing.js.map +1 -1
- package/dist/src/ping/constants.d.ts.map +1 -1
- package/dist/src/ping/constants.js.map +1 -1
- package/dist/src/ping/index.d.ts +5 -4
- package/dist/src/ping/index.d.ts.map +1 -1
- package/dist/src/ping/index.js +32 -21
- package/dist/src/ping/index.js.map +1 -1
- package/dist/src/pnet/index.d.ts +1 -1
- package/dist/src/pnet/index.js +1 -1
- package/dist/src/pnet/index.js.map +1 -1
- package/dist/src/registrar.d.ts +7 -6
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +7 -11
- package/dist/src/registrar.js.map +1 -1
- package/dist/src/transport-manager.d.ts +9 -9
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +7 -4
- package/dist/src/transport-manager.js.map +1 -1
- package/dist/src/upgrader.d.ts +13 -12
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +37 -26
- package/dist/src/upgrader.js.map +1 -1
- package/dist/src/upnp-nat/index.d.ts +4 -4
- package/dist/src/upnp-nat/index.d.ts.map +1 -1
- package/dist/src/upnp-nat/index.js +1 -1
- package/dist/src/upnp-nat/index.js.map +1 -1
- package/dist/src/utils/peer-job-queue.d.ts +1 -1
- package/dist/src/utils/peer-job-queue.js +1 -1
- package/dist/src/utils/peer-job-queue.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +52 -85
- package/src/address-manager/README.md +1 -1
- package/src/address-manager/index.ts +5 -5
- package/src/address-manager/utils.ts +0 -1
- package/src/autonat/index.ts +33 -12
- package/src/circuit-relay/index.ts +37 -1
- package/src/circuit-relay/server/advert-service.ts +3 -3
- package/src/circuit-relay/server/index.ts +41 -38
- package/src/circuit-relay/server/reservation-store.ts +3 -3
- package/src/circuit-relay/server/reservation-voucher.ts +2 -2
- package/src/circuit-relay/transport/discovery.ts +10 -11
- package/src/circuit-relay/transport/index.ts +76 -38
- package/src/circuit-relay/transport/listener.ts +9 -7
- package/src/circuit-relay/transport/reservation-store.ts +41 -18
- package/src/circuit-relay/utils.ts +1 -1
- package/src/components.ts +16 -15
- package/src/config/connection-gater.browser.ts +1 -1
- package/src/config/connection-gater.ts +1 -1
- package/src/config.ts +3 -4
- package/src/connection/index.ts +82 -40
- package/src/connection-manager/auto-dial.ts +8 -6
- package/src/connection-manager/connection-pruner.ts +6 -6
- package/src/connection-manager/constants.ts +0 -1
- package/src/connection-manager/dial-queue.ts +20 -27
- package/src/connection-manager/index.ts +27 -22
- package/src/content-routing/index.ts +6 -6
- package/src/content-routing/utils.ts +3 -3
- package/src/fetch/constants.ts +0 -1
- package/src/fetch/index.ts +11 -11
- package/src/get-peer.ts +3 -3
- package/src/identify/consts.ts +0 -1
- package/src/identify/identify.ts +85 -92
- package/src/identify/index.ts +32 -8
- package/src/index.ts +11 -12
- package/src/insecure/index.ts +3 -3
- package/src/libp2p.ts +24 -18
- package/src/peer-routing.ts +6 -6
- package/src/ping/constants.ts +0 -1
- package/src/ping/index.ts +45 -27
- package/src/pnet/index.ts +2 -2
- package/src/registrar.ts +14 -17
- package/src/transport-manager.ts +16 -12
- package/src/upgrader.ts +52 -39
- package/src/upnp-nat/index.ts +5 -5
- package/src/utils/peer-job-queue.ts +2 -2
- package/src/version.ts +1 -1
- package/dist/src/pubsub/dummy-pubsub.d.ts +0 -18
- package/dist/src/pubsub/dummy-pubsub.d.ts.map +0 -1
- package/dist/src/pubsub/dummy-pubsub.js +0 -38
- package/dist/src/pubsub/dummy-pubsub.js.map +0 -1
- package/src/pubsub/dummy-pubsub.ts +0 -53
package/src/insecure/index.ts
CHANGED
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import { UnexpectedPeerError, InvalidCryptoExchangeError } from '@libp2p/interface
|
|
25
|
+
import { UnexpectedPeerError, InvalidCryptoExchangeError } from '@libp2p/interface/errors'
|
|
26
26
|
import { logger } from '@libp2p/logger'
|
|
27
27
|
import { peerIdFromBytes, peerIdFromKeys } from '@libp2p/peer-id'
|
|
28
28
|
import { handshake } from 'it-handshake'
|
|
29
29
|
import * as lp from 'it-length-prefixed'
|
|
30
30
|
import map from 'it-map'
|
|
31
31
|
import { Exchange, KeyType } from './pb/proto.js'
|
|
32
|
-
import type { ConnectionEncrypter, SecuredConnection } from '@libp2p/interface
|
|
33
|
-
import type { PeerId } from '@libp2p/interface
|
|
32
|
+
import type { ConnectionEncrypter, SecuredConnection } from '@libp2p/interface/connection-encrypter'
|
|
33
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
34
34
|
import type { Duplex, Source } from 'it-stream-types'
|
|
35
35
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
36
36
|
|
package/src/libp2p.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { setMaxListeners } from 'events'
|
|
2
2
|
import { unmarshalPublicKey } from '@libp2p/crypto/keys'
|
|
3
|
-
import { type ContentRouting, contentRouting } from '@libp2p/interface
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { type ContentRouting, contentRouting } from '@libp2p/interface/content-routing'
|
|
4
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
5
|
+
import { EventEmitter, CustomEvent } from '@libp2p/interface/events'
|
|
6
|
+
import { peerDiscovery } from '@libp2p/interface/peer-discovery'
|
|
7
|
+
import { type PeerRouting, peerRouting } from '@libp2p/interface/peer-routing'
|
|
8
8
|
import { DefaultKeyChain } from '@libp2p/keychain'
|
|
9
9
|
import { logger } from '@libp2p/logger'
|
|
10
10
|
import { PeerSet } from '@libp2p/peer-collections'
|
|
@@ -29,15 +29,15 @@ import { DefaultTransportManager } from './transport-manager.js'
|
|
|
29
29
|
import { DefaultUpgrader } from './upgrader.js'
|
|
30
30
|
import type { Components } from './components.js'
|
|
31
31
|
import type { Libp2p, Libp2pInit, Libp2pOptions } from './index.js'
|
|
32
|
-
import type {
|
|
33
|
-
import type {
|
|
34
|
-
import type {
|
|
35
|
-
import type { Metrics } from '@libp2p/interface
|
|
36
|
-
import type { PeerId } from '@libp2p/interface
|
|
37
|
-
import type { PeerInfo } from '@libp2p/interface
|
|
38
|
-
import type { PeerStore } from '@libp2p/interface
|
|
39
|
-
import type {
|
|
40
|
-
import type {
|
|
32
|
+
import type { Libp2pEvents, PendingDial, ServiceMap, AbortOptions } from '@libp2p/interface'
|
|
33
|
+
import type { Connection, NewStreamOptions, Stream } from '@libp2p/interface/connection'
|
|
34
|
+
import type { KeyChain } from '@libp2p/interface/keychain'
|
|
35
|
+
import type { Metrics } from '@libp2p/interface/metrics'
|
|
36
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
37
|
+
import type { PeerInfo } from '@libp2p/interface/peer-info'
|
|
38
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
39
|
+
import type { Topology } from '@libp2p/interface/topology'
|
|
40
|
+
import type { StreamHandler, StreamHandlerOptions } from '@libp2p/interface-internal/registrar'
|
|
41
41
|
import type { Datastore } from 'interface-datastore'
|
|
42
42
|
|
|
43
43
|
const log = logger('libp2p')
|
|
@@ -99,7 +99,13 @@ export class Libp2pNode<T extends ServiceMap = Record<string, unknown>> extends
|
|
|
99
99
|
components.events.addEventListener('peer:update', evt => {
|
|
100
100
|
// if there was no peer previously in the peer store this is a new peer
|
|
101
101
|
if (evt.detail.previous == null) {
|
|
102
|
-
|
|
102
|
+
const peerInfo: PeerInfo = {
|
|
103
|
+
id: evt.detail.peer.id,
|
|
104
|
+
multiaddrs: evt.detail.peer.addresses.map(a => a.multiaddr),
|
|
105
|
+
protocols: evt.detail.peer.protocols
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
this.safeDispatchEvent('peer:discovery', { detail: peerInfo })
|
|
103
109
|
}
|
|
104
110
|
})
|
|
105
111
|
|
|
@@ -283,7 +289,7 @@ export class Libp2pNode<T extends ServiceMap = Record<string, unknown>> extends
|
|
|
283
289
|
return this.components.connectionManager.openConnection(peer, options)
|
|
284
290
|
}
|
|
285
291
|
|
|
286
|
-
async dialProtocol (peer: PeerId | Multiaddr | Multiaddr[], protocols: string | string[], options:
|
|
292
|
+
async dialProtocol (peer: PeerId | Multiaddr | Multiaddr[], protocols: string | string[], options: NewStreamOptions = {}): Promise<Stream> {
|
|
287
293
|
if (protocols == null) {
|
|
288
294
|
throw new CodeError('no protocols were provided to open a stream', codes.ERR_INVALID_PROTOCOLS_FOR_STREAM)
|
|
289
295
|
}
|
|
@@ -307,12 +313,12 @@ export class Libp2pNode<T extends ServiceMap = Record<string, unknown>> extends
|
|
|
307
313
|
return this.components.registrar.getProtocols()
|
|
308
314
|
}
|
|
309
315
|
|
|
310
|
-
async hangUp (peer: PeerId | Multiaddr): Promise<void> {
|
|
316
|
+
async hangUp (peer: PeerId | Multiaddr, options: AbortOptions = {}): Promise<void> {
|
|
311
317
|
if (isMultiaddr(peer)) {
|
|
312
318
|
peer = peerIdFromString(peer.getPeerId() ?? '')
|
|
313
319
|
}
|
|
314
320
|
|
|
315
|
-
await this.components.connectionManager.closeConnections(peer)
|
|
321
|
+
await this.components.connectionManager.closeConnections(peer, options)
|
|
316
322
|
}
|
|
317
323
|
|
|
318
324
|
/**
|
package/src/peer-routing.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/
|
|
1
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
2
2
|
import { logger } from '@libp2p/logger'
|
|
3
3
|
import filter from 'it-filter'
|
|
4
4
|
import first from 'it-first'
|
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
requirePeers
|
|
11
11
|
} from './content-routing/utils.js'
|
|
12
12
|
import { codes, messages } from './errors.js'
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
17
|
-
import type {
|
|
13
|
+
import type { AbortOptions } from '@libp2p/interface'
|
|
14
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
15
|
+
import type { PeerInfo } from '@libp2p/interface/peer-info'
|
|
16
|
+
import type { PeerRouting } from '@libp2p/interface/peer-routing'
|
|
17
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
18
18
|
|
|
19
19
|
const log = logger('libp2p:peer-routing')
|
|
20
20
|
|
package/src/ping/constants.ts
CHANGED
package/src/ping/index.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { setMaxListeners } from 'events'
|
|
2
1
|
import { randomBytes } from '@libp2p/crypto'
|
|
3
|
-
import { CodeError } from '@libp2p/
|
|
2
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
4
3
|
import { logger } from '@libp2p/logger'
|
|
5
4
|
import { abortableDuplex } from 'abortable-iterator'
|
|
6
|
-
import { anySignal } from 'any-signal'
|
|
7
5
|
import first from 'it-first'
|
|
8
6
|
import { pipe } from 'it-pipe'
|
|
9
7
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
10
8
|
import { codes } from '../errors.js'
|
|
11
9
|
import { PROTOCOL_PREFIX, PROTOCOL_NAME, PING_LENGTH, PROTOCOL_VERSION, TIMEOUT, MAX_INBOUND_STREAMS, MAX_OUTBOUND_STREAMS } from './constants.js'
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
14
|
-
import type { PeerId } from '@libp2p/interface
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
17
|
-
import type {
|
|
10
|
+
import type { AbortOptions } from '@libp2p/interface'
|
|
11
|
+
import type { Stream } from '@libp2p/interface/connection'
|
|
12
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
13
|
+
import type { Startable } from '@libp2p/interface/startable'
|
|
14
|
+
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
15
|
+
import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal/registrar'
|
|
18
16
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
19
17
|
|
|
20
18
|
const log = logger('libp2p:ping')
|
|
@@ -27,6 +25,7 @@ export interface PingServiceInit {
|
|
|
27
25
|
protocolPrefix?: string
|
|
28
26
|
maxInboundStreams?: number
|
|
29
27
|
maxOutboundStreams?: number
|
|
28
|
+
runOnTransientConnection?: boolean
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
31
|
* How long we should wait for a ping response
|
|
@@ -46,6 +45,7 @@ class DefaultPingService implements Startable, PingService {
|
|
|
46
45
|
private readonly timeout: number
|
|
47
46
|
private readonly maxInboundStreams: number
|
|
48
47
|
private readonly maxOutboundStreams: number
|
|
48
|
+
private readonly runOnTransientConnection: boolean
|
|
49
49
|
|
|
50
50
|
constructor (components: PingServiceComponents, init: PingServiceInit) {
|
|
51
51
|
this.components = components
|
|
@@ -54,12 +54,14 @@ class DefaultPingService implements Startable, PingService {
|
|
|
54
54
|
this.timeout = init.timeout ?? TIMEOUT
|
|
55
55
|
this.maxInboundStreams = init.maxInboundStreams ?? MAX_INBOUND_STREAMS
|
|
56
56
|
this.maxOutboundStreams = init.maxOutboundStreams ?? MAX_OUTBOUND_STREAMS
|
|
57
|
+
this.runOnTransientConnection = init.runOnTransientConnection ?? true
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
async start (): Promise<void> {
|
|
60
61
|
await this.components.registrar.handle(this.protocol, this.handleMessage, {
|
|
61
62
|
maxInboundStreams: this.maxInboundStreams,
|
|
62
|
-
maxOutboundStreams: this.maxOutboundStreams
|
|
63
|
+
maxOutboundStreams: this.maxOutboundStreams,
|
|
64
|
+
runOnTransientConnection: this.runOnTransientConnection
|
|
63
65
|
})
|
|
64
66
|
this.started = true
|
|
65
67
|
}
|
|
@@ -77,11 +79,19 @@ class DefaultPingService implements Startable, PingService {
|
|
|
77
79
|
* A handler to register with Libp2p to process ping messages
|
|
78
80
|
*/
|
|
79
81
|
handleMessage (data: IncomingStreamData): void {
|
|
82
|
+
log('incoming ping from %p', data.connection.remotePeer)
|
|
83
|
+
|
|
80
84
|
const { stream } = data
|
|
85
|
+
const start = Date.now()
|
|
81
86
|
|
|
82
87
|
void pipe(stream, stream)
|
|
83
88
|
.catch(err => {
|
|
84
|
-
log.error(err)
|
|
89
|
+
log.error('incoming ping from %p failed with error', data.connection.remotePeer, err)
|
|
90
|
+
})
|
|
91
|
+
.finally(() => {
|
|
92
|
+
const ms = Date.now() - start
|
|
93
|
+
|
|
94
|
+
log('incoming ping from %p complete in %dms', data.connection.remotePeer, ms)
|
|
85
95
|
})
|
|
86
96
|
}
|
|
87
97
|
|
|
@@ -92,45 +102,53 @@ class DefaultPingService implements Startable, PingService {
|
|
|
92
102
|
* @returns {Promise<number>}
|
|
93
103
|
*/
|
|
94
104
|
async ping (peer: PeerId | Multiaddr | Multiaddr[], options: AbortOptions = {}): Promise<number> {
|
|
95
|
-
log('
|
|
105
|
+
log('pinging %p', peer)
|
|
96
106
|
|
|
97
107
|
const start = Date.now()
|
|
98
108
|
const data = randomBytes(PING_LENGTH)
|
|
99
109
|
const connection = await this.components.connectionManager.openConnection(peer, options)
|
|
100
110
|
let stream: Stream | undefined
|
|
101
111
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
try {
|
|
105
|
-
// fails on node < 15.4
|
|
106
|
-
setMaxListeners?.(Infinity, signal)
|
|
107
|
-
} catch {}
|
|
112
|
+
options.signal = options.signal ?? AbortSignal.timeout(this.timeout)
|
|
108
113
|
|
|
109
114
|
try {
|
|
110
|
-
stream = await connection.newStream(
|
|
111
|
-
|
|
115
|
+
stream = await connection.newStream(this.protocol, {
|
|
116
|
+
...options,
|
|
117
|
+
runOnTransientConnection: this.runOnTransientConnection
|
|
112
118
|
})
|
|
113
119
|
|
|
114
120
|
// make stream abortable
|
|
115
|
-
const source = abortableDuplex(stream, signal)
|
|
121
|
+
const source = abortableDuplex(stream, options.signal)
|
|
116
122
|
|
|
117
123
|
const result = await pipe(
|
|
118
124
|
[data],
|
|
119
125
|
source,
|
|
120
126
|
async (source) => first(source)
|
|
121
127
|
)
|
|
122
|
-
const end = Date.now()
|
|
123
128
|
|
|
124
|
-
|
|
125
|
-
|
|
129
|
+
const ms = Date.now() - start
|
|
130
|
+
|
|
131
|
+
if (result == null) {
|
|
132
|
+
throw new CodeError(`Did not receive a ping ack after ${ms}ms`, codes.ERR_WRONG_PING_ACK)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (!uint8ArrayEquals(data, result.subarray())) {
|
|
136
|
+
throw new CodeError(`Received wrong ping ack after ${ms}ms`, codes.ERR_WRONG_PING_ACK)
|
|
126
137
|
}
|
|
127
138
|
|
|
128
|
-
|
|
139
|
+
log('ping %p complete in %dms', connection.remotePeer, ms)
|
|
140
|
+
|
|
141
|
+
return ms
|
|
142
|
+
} catch (err: any) {
|
|
143
|
+
log.error('error while pinging %p', connection.remotePeer, err)
|
|
144
|
+
|
|
145
|
+
stream?.abort(err)
|
|
146
|
+
|
|
147
|
+
throw err
|
|
129
148
|
} finally {
|
|
130
149
|
if (stream != null) {
|
|
131
|
-
stream.close()
|
|
150
|
+
await stream.close()
|
|
132
151
|
}
|
|
133
|
-
signal.clear()
|
|
134
152
|
}
|
|
135
153
|
}
|
|
136
154
|
}
|
package/src/pnet/index.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { randomBytes } from '@libp2p/crypto'
|
|
26
|
-
import { CodeError } from '@libp2p/
|
|
26
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
27
27
|
import { logger } from '@libp2p/logger'
|
|
28
28
|
import { handshake } from 'it-handshake'
|
|
29
29
|
import map from 'it-map'
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
} from './crypto.js'
|
|
38
38
|
import * as Errors from './errors.js'
|
|
39
39
|
import { NONCE_LENGTH } from './key-generator.js'
|
|
40
|
-
import type { ConnectionProtector, MultiaddrConnection } from '@libp2p/interface
|
|
40
|
+
import type { ConnectionProtector, MultiaddrConnection } from '@libp2p/interface/connection'
|
|
41
41
|
|
|
42
42
|
const log = logger('libp2p:pnet')
|
|
43
43
|
|
package/src/registrar.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CodeError } from '@libp2p/interfaces/errors'
|
|
1
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
3
2
|
import { logger } from '@libp2p/logger'
|
|
4
3
|
import merge from 'merge-options'
|
|
5
4
|
import { codes } from './errors.js'
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type { PeerId } from '@libp2p/interface
|
|
9
|
-
import type { PeerStore } from '@libp2p/interface
|
|
10
|
-
import type {
|
|
5
|
+
import type { Libp2pEvents, PeerUpdate } from '@libp2p/interface'
|
|
6
|
+
import type { EventEmitter } from '@libp2p/interface/events'
|
|
7
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
8
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
9
|
+
import type { Topology } from '@libp2p/interface/topology'
|
|
10
|
+
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
11
|
+
import type { StreamHandlerOptions, StreamHandlerRecord, Registrar, StreamHandler } from '@libp2p/interface-internal/registrar'
|
|
11
12
|
|
|
12
13
|
const log = logger('libp2p:registrar')
|
|
13
14
|
|
|
@@ -116,9 +117,8 @@ export class DefaultRegistrar implements Registrar {
|
|
|
116
117
|
* Register handlers for a set of multicodecs given
|
|
117
118
|
*/
|
|
118
119
|
async register (protocol: string, topology: Topology): Promise<string> {
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
throw new CodeError('topology must be an instance of interfaces/topology', codes.ERR_INVALID_PARAMETERS)
|
|
120
|
+
if (topology == null) {
|
|
121
|
+
throw new CodeError('invalid topology', codes.ERR_INVALID_PARAMETERS)
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
// Create topology
|
|
@@ -133,9 +133,6 @@ export class DefaultRegistrar implements Registrar {
|
|
|
133
133
|
|
|
134
134
|
topologies.set(id, topology)
|
|
135
135
|
|
|
136
|
-
// Set registrar
|
|
137
|
-
await topology.setRegistrar(this)
|
|
138
|
-
|
|
139
136
|
return id
|
|
140
137
|
}
|
|
141
138
|
|
|
@@ -171,7 +168,7 @@ export class DefaultRegistrar implements Registrar {
|
|
|
171
168
|
}
|
|
172
169
|
|
|
173
170
|
for (const topology of topologies.values()) {
|
|
174
|
-
topology.onDisconnect(remotePeer)
|
|
171
|
+
topology.onDisconnect?.(remotePeer)
|
|
175
172
|
}
|
|
176
173
|
}
|
|
177
174
|
})
|
|
@@ -211,7 +208,7 @@ export class DefaultRegistrar implements Registrar {
|
|
|
211
208
|
}
|
|
212
209
|
|
|
213
210
|
for (const topology of topologies.values()) {
|
|
214
|
-
topology.onConnect(remotePeer, connection)
|
|
211
|
+
topology.onConnect?.(remotePeer, connection)
|
|
215
212
|
}
|
|
216
213
|
}
|
|
217
214
|
})
|
|
@@ -242,7 +239,7 @@ export class DefaultRegistrar implements Registrar {
|
|
|
242
239
|
}
|
|
243
240
|
|
|
244
241
|
for (const topology of topologies.values()) {
|
|
245
|
-
topology.onDisconnect(peer.id)
|
|
242
|
+
topology.onDisconnect?.(peer.id)
|
|
246
243
|
}
|
|
247
244
|
}
|
|
248
245
|
|
|
@@ -260,7 +257,7 @@ export class DefaultRegistrar implements Registrar {
|
|
|
260
257
|
if (connection == null) {
|
|
261
258
|
continue
|
|
262
259
|
}
|
|
263
|
-
topology.onConnect(peer.id, connection)
|
|
260
|
+
topology.onConnect?.(peer.id, connection)
|
|
264
261
|
}
|
|
265
262
|
}
|
|
266
263
|
}
|
package/src/transport-manager.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
2
|
+
import { trackedMap } from '@libp2p/interface/metrics/tracked-map'
|
|
3
|
+
import { FaultTolerance } from '@libp2p/interface/transport'
|
|
3
4
|
import { logger } from '@libp2p/logger'
|
|
4
|
-
import { trackedMap } from '@libp2p/tracked-map'
|
|
5
5
|
import { codes } from './errors.js'
|
|
6
|
-
import type {
|
|
7
|
-
import type { Connection } from '@libp2p/interface
|
|
8
|
-
import type {
|
|
9
|
-
import type { Metrics } from '@libp2p/interface
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
6
|
+
import type { Libp2pEvents, AbortOptions } from '@libp2p/interface'
|
|
7
|
+
import type { Connection } from '@libp2p/interface/connection'
|
|
8
|
+
import type { EventEmitter } from '@libp2p/interface/events'
|
|
9
|
+
import type { Metrics } from '@libp2p/interface/metrics'
|
|
10
|
+
import type { Startable } from '@libp2p/interface/startable'
|
|
11
|
+
import type { Listener, Transport, Upgrader } from '@libp2p/interface/transport'
|
|
12
|
+
import type { AddressManager } from '@libp2p/interface-internal/address-manager'
|
|
13
|
+
import type { TransportManager } from '@libp2p/interface-internal/transport-manager'
|
|
14
14
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
15
15
|
|
|
16
16
|
const log = logger('libp2p:transports')
|
|
@@ -177,6 +177,10 @@ export class DefaultTransportManager implements TransportManager, Startable {
|
|
|
177
177
|
* Starts listeners for each listen Multiaddr
|
|
178
178
|
*/
|
|
179
179
|
async listen (addrs: Multiaddr[]): Promise<void> {
|
|
180
|
+
if (!this.isStarted()) {
|
|
181
|
+
throw new CodeError('Not started', codes.ERR_NODE_NOT_STARTED)
|
|
182
|
+
}
|
|
183
|
+
|
|
180
184
|
if (addrs == null || addrs.length === 0) {
|
|
181
185
|
log('no addresses were provided for listening, this node is dial only')
|
|
182
186
|
return
|
|
@@ -190,7 +194,7 @@ export class DefaultTransportManager implements TransportManager, Startable {
|
|
|
190
194
|
|
|
191
195
|
// For each supported multiaddr, create a listener
|
|
192
196
|
for (const addr of supportedAddrs) {
|
|
193
|
-
log('creating listener for %s on %
|
|
197
|
+
log('creating listener for %s on %a', key, addr)
|
|
194
198
|
const listener = transport.createListener({
|
|
195
199
|
upgrader: this.components.upgrader
|
|
196
200
|
})
|
package/src/upgrader.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setMaxListeners } from 'events'
|
|
2
|
-
import { CodeError } from '@libp2p/
|
|
2
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
3
3
|
import { logger } from '@libp2p/logger'
|
|
4
4
|
import * as mss from '@libp2p/multistream-select'
|
|
5
5
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
@@ -9,19 +9,18 @@ import { createConnection } from './connection/index.js'
|
|
|
9
9
|
import { INBOUND_UPGRADE_TIMEOUT } from './connection-manager/constants.js'
|
|
10
10
|
import { codes } from './errors.js'
|
|
11
11
|
import { DEFAULT_MAX_INBOUND_STREAMS, DEFAULT_MAX_OUTBOUND_STREAMS } from './registrar.js'
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
17
|
-
import type { Metrics } from '@libp2p/interface
|
|
18
|
-
import type { PeerId } from '@libp2p/interface
|
|
19
|
-
import type { PeerStore } from '@libp2p/interface
|
|
20
|
-
import type {
|
|
21
|
-
import type {
|
|
22
|
-
import type {
|
|
23
|
-
import type {
|
|
24
|
-
import type { EventEmitter } from '@libp2p/interfaces/events'
|
|
12
|
+
import type { Libp2pEvents, AbortOptions } from '@libp2p/interface'
|
|
13
|
+
import type { MultiaddrConnection, Connection, Stream, ConnectionProtector, NewStreamOptions } from '@libp2p/interface/connection'
|
|
14
|
+
import type { ConnectionEncrypter, SecuredConnection } from '@libp2p/interface/connection-encrypter'
|
|
15
|
+
import type { ConnectionGater } from '@libp2p/interface/connection-gater'
|
|
16
|
+
import type { EventEmitter } from '@libp2p/interface/events'
|
|
17
|
+
import type { Metrics } from '@libp2p/interface/metrics'
|
|
18
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
19
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
20
|
+
import type { StreamMuxer, StreamMuxerFactory } from '@libp2p/interface/stream-muxer'
|
|
21
|
+
import type { Upgrader, UpgraderOptions } from '@libp2p/interface/transport'
|
|
22
|
+
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
23
|
+
import type { Registrar } from '@libp2p/interface-internal/registrar'
|
|
25
24
|
import type { Duplex, Source } from 'it-stream-types'
|
|
26
25
|
|
|
27
26
|
const log = logger('libp2p:upgrader')
|
|
@@ -33,6 +32,7 @@ interface CreateConnectionOptions {
|
|
|
33
32
|
upgradedConn: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>
|
|
34
33
|
remotePeer: PeerId
|
|
35
34
|
muxerFactory?: StreamMuxerFactory
|
|
35
|
+
transient?: boolean
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
interface OnStreamOptions {
|
|
@@ -90,7 +90,7 @@ function countStreams (protocol: string, direction: 'inbound' | 'outbound', conn
|
|
|
90
90
|
let streamCount = 0
|
|
91
91
|
|
|
92
92
|
connection.streams.forEach(stream => {
|
|
93
|
-
if (stream.
|
|
93
|
+
if (stream.direction === direction && stream.protocol === protocol) {
|
|
94
94
|
streamCount++
|
|
95
95
|
}
|
|
96
96
|
})
|
|
@@ -252,7 +252,8 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
252
252
|
maConn,
|
|
253
253
|
upgradedConn,
|
|
254
254
|
muxerFactory,
|
|
255
|
-
remotePeer
|
|
255
|
+
remotePeer,
|
|
256
|
+
transient: opts?.transient
|
|
256
257
|
})
|
|
257
258
|
} finally {
|
|
258
259
|
this.components.connectionManager.afterUpgradeInbound()
|
|
@@ -349,7 +350,8 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
349
350
|
maConn,
|
|
350
351
|
upgradedConn,
|
|
351
352
|
muxerFactory,
|
|
352
|
-
remotePeer
|
|
353
|
+
remotePeer,
|
|
354
|
+
transient: opts?.transient
|
|
353
355
|
})
|
|
354
356
|
}
|
|
355
357
|
|
|
@@ -363,7 +365,8 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
363
365
|
maConn,
|
|
364
366
|
upgradedConn,
|
|
365
367
|
remotePeer,
|
|
366
|
-
muxerFactory
|
|
368
|
+
muxerFactory,
|
|
369
|
+
transient
|
|
367
370
|
} = opts
|
|
368
371
|
|
|
369
372
|
let muxer: StreamMuxer | undefined
|
|
@@ -404,7 +407,7 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
404
407
|
// the souce/sink
|
|
405
408
|
muxedStream.source = stream.source
|
|
406
409
|
muxedStream.sink = stream.sink
|
|
407
|
-
muxedStream.
|
|
410
|
+
muxedStream.protocol = protocol
|
|
408
411
|
|
|
409
412
|
// If a protocol stream has been successfully negotiated and is to be passed to the application,
|
|
410
413
|
// the peerstore should ensure that the peer is registered with that protocol
|
|
@@ -417,11 +420,11 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
417
420
|
|
|
418
421
|
this._onStream({ connection, stream: muxedStream, protocol })
|
|
419
422
|
})
|
|
420
|
-
.catch(err => {
|
|
423
|
+
.catch(async err => {
|
|
421
424
|
log.error(err)
|
|
422
425
|
|
|
423
|
-
if (muxedStream.
|
|
424
|
-
muxedStream.close()
|
|
426
|
+
if (muxedStream.timeline.close == null) {
|
|
427
|
+
await muxedStream.close()
|
|
425
428
|
}
|
|
426
429
|
})
|
|
427
430
|
},
|
|
@@ -473,7 +476,7 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
473
476
|
// the souce/sink
|
|
474
477
|
muxedStream.source = stream.source
|
|
475
478
|
muxedStream.sink = stream.sink
|
|
476
|
-
muxedStream.
|
|
479
|
+
muxedStream.protocol = protocol
|
|
477
480
|
|
|
478
481
|
this.components.metrics?.trackProtocolStream(muxedStream, connection)
|
|
479
482
|
|
|
@@ -481,8 +484,8 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
481
484
|
} catch (err: any) {
|
|
482
485
|
log.error('could not create new stream', err)
|
|
483
486
|
|
|
484
|
-
if (muxedStream.
|
|
485
|
-
muxedStream.
|
|
487
|
+
if (muxedStream.timeline.close == null) {
|
|
488
|
+
muxedStream.abort(err)
|
|
486
489
|
}
|
|
487
490
|
|
|
488
491
|
if (err.code != null) {
|
|
@@ -509,7 +512,7 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
509
512
|
// Wait for close to finish before notifying of the closure
|
|
510
513
|
(async () => {
|
|
511
514
|
try {
|
|
512
|
-
if (connection.
|
|
515
|
+
if (connection.status === 'open') {
|
|
513
516
|
await connection.close()
|
|
514
517
|
}
|
|
515
518
|
} catch (err: any) {
|
|
@@ -537,20 +540,26 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
537
540
|
connection = createConnection({
|
|
538
541
|
remoteAddr: maConn.remoteAddr,
|
|
539
542
|
remotePeer,
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
},
|
|
543
|
+
status: 'open',
|
|
544
|
+
direction,
|
|
545
|
+
timeline: maConn.timeline,
|
|
546
|
+
multiplexer: muxer?.protocol,
|
|
547
|
+
encryption: cryptoProtocol,
|
|
548
|
+
transient,
|
|
547
549
|
newStream: newStream ?? errConnectionNotMultiplexed,
|
|
548
|
-
getStreams: () => { if (muxer != null) { return muxer.streams } else { return
|
|
549
|
-
close: async () => {
|
|
550
|
-
await maConn.close()
|
|
551
|
-
// Ensure remaining streams are closed
|
|
550
|
+
getStreams: () => { if (muxer != null) { return muxer.streams } else { return [] } },
|
|
551
|
+
close: async (options?: AbortOptions) => {
|
|
552
|
+
await maConn.close(options)
|
|
553
|
+
// Ensure remaining streams are closed gracefully
|
|
552
554
|
if (muxer != null) {
|
|
553
|
-
muxer.close()
|
|
555
|
+
await muxer.close(options)
|
|
556
|
+
}
|
|
557
|
+
},
|
|
558
|
+
abort: (err) => {
|
|
559
|
+
maConn.abort(err)
|
|
560
|
+
// Ensure remaining streams are aborted
|
|
561
|
+
if (muxer != null) {
|
|
562
|
+
muxer.abort(err)
|
|
554
563
|
}
|
|
555
564
|
}
|
|
556
565
|
})
|
|
@@ -567,7 +576,11 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
567
576
|
*/
|
|
568
577
|
_onStream (opts: OnStreamOptions): void {
|
|
569
578
|
const { connection, stream, protocol } = opts
|
|
570
|
-
const { handler } = this.components.registrar.getHandler(protocol)
|
|
579
|
+
const { handler, options } = this.components.registrar.getHandler(protocol)
|
|
580
|
+
|
|
581
|
+
if (connection.transient && options.runOnTransientConnection !== true) {
|
|
582
|
+
throw new CodeError('Cannot open protocol stream on transient connection', 'ERR_TRANSIENT_CONNECTION')
|
|
583
|
+
}
|
|
571
584
|
|
|
572
585
|
handler({ connection, stream })
|
|
573
586
|
}
|
package/src/upnp-nat/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { upnpNat, type NatAPI } from '@achingbrain/nat-port-mapper'
|
|
2
|
-
import { CodeError } from '@libp2p/
|
|
2
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
3
3
|
import { logger } from '@libp2p/logger'
|
|
4
4
|
import { isLoopback } from '@libp2p/utils/multiaddr/is-loopback'
|
|
5
5
|
import { fromNodeAddress } from '@multiformats/multiaddr'
|
|
@@ -7,10 +7,10 @@ import isPrivateIp from 'private-ip'
|
|
|
7
7
|
import { isBrowser } from 'wherearewe'
|
|
8
8
|
import { codes } from '../errors.js'
|
|
9
9
|
import * as pkg from '../version.js'
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
10
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
11
|
+
import type { Startable } from '@libp2p/interface/startable'
|
|
12
|
+
import type { AddressManager } from '@libp2p/interface-internal/address-manager'
|
|
13
|
+
import type { TransportManager } from '@libp2p/interface-internal/transport-manager'
|
|
14
14
|
|
|
15
15
|
const log = logger('libp2p:upnp-nat')
|
|
16
16
|
const DEFAULT_TTL = 7200
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
2
|
|
|
3
|
-
import { CodeError } from '@libp2p/
|
|
3
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
4
4
|
import PQueue from 'p-queue'
|
|
5
5
|
import { codes } from '../errors.js'
|
|
6
|
-
import type { PeerId } from '@libp2p/interface
|
|
6
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
7
7
|
import type { QueueAddOptions, Options, Queue } from 'p-queue'
|
|
8
8
|
|
|
9
9
|
// Port of lower_bound from https://en.cppreference.com/w/cpp/algorithm/lower_bound
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '0.
|
|
1
|
+
export const version = '0.46.0'
|
|
2
2
|
export const name = 'libp2p'
|