Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: update libp2p interfaces #1252

Merged
merged 2 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ import { TCP } from '@libp2p/tcp'
import { Mplex } from '@libp2p/mplex'
import { Noise } from '@chainsafe/libp2p-noise'
import { GossipSub } from 'libp2p-gossipsub'
import { SignaturePolicy } from '@libp2p/interfaces/pubsub'
import { SignaturePolicy } from '@libp2p/interface-pubsub'

const node = await createLibp2p({
transports: [
Expand Down
2 changes: 1 addition & 1 deletion doc/migrations/v0.36-v.037.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ libp2p.pubsub.off('my-topic', handler)
**After**

```js
import type { Message } from '@libp2p/interfaces/pubsub'
import type { Message } from '@libp2p/interface-pubsub'

const handler = (event: CustomEvent<Message>) => {
const message = event.detail
Expand Down
12 changes: 6 additions & 6 deletions examples/delegated-routing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"@chainsafe/libp2p-noise": "^6.2.0",
"ipfs-core": "^0.14.1",
"libp2p": "../../",
"@libp2p/delegated-content-routing": "^1.0.1",
"@libp2p/delegated-peer-routing": "^1.0.1",
"@libp2p/kad-dht": "^1.0.9",
"@libp2p/mplex": "^1.0.4",
"@libp2p/webrtc-star": "^1.0.8",
"@libp2p/websockets": "^1.0.7",
"@libp2p/delegated-content-routing": "^2.0.1",
"@libp2p/delegated-peer-routing": "^2.0.1",
"@libp2p/kad-dht": "^2.0.0",
"@libp2p/mplex": "^2.0.0",
"@libp2p/webrtc-star": "^2.0.0",
"@libp2p/websockets": "^2.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0"
Expand Down
8 changes: 4 additions & 4 deletions examples/libp2p-in-the-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"license": "ISC",
"dependencies": {
"@chainsafe/libp2p-noise": "^6.2.0",
"@libp2p/bootstrap": "^1.0.4",
"@libp2p/mplex": "^1.0.4",
"@libp2p/webrtc-star": "^1.0.8",
"@libp2p/websockets": "^1.0.7",
"@libp2p/bootstrap": "^2.0.0",
"@libp2p/mplex": "^2.0.0",
"@libp2p/webrtc-star": "^2.0.0",
"@libp2p/websockets": "^2.0.0",
"libp2p": "../../"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
},
"license": "MIT",
"dependencies": {
"@libp2p/pubsub-peer-discovery": "^5.0.2",
"@libp2p/floodsub": "^1.0.6",
"@libp2p/pubsub-peer-discovery": "^6.0.0",
"@libp2p/floodsub": "^2.0.0",
"@nodeutils/defaults-deep": "^1.1.0",
"execa": "^2.1.0",
"fs-extra": "^8.1.0",
Expand Down
6 changes: 3 additions & 3 deletions examples/webrtc-direct/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
},
"license": "ISC",
"dependencies": {
"@libp2p/webrtc-direct": "^1.0.1",
"@libp2p/webrtc-direct": "^2.0.0",
"@chainsafe/libp2p-noise": "^6.2.0",
"@libp2p/bootstrap": "^1.0.4",
"@libp2p/mplex": "^1.0.4",
"@libp2p/bootstrap": "^2.0.0",
"@libp2p/mplex": "^2.0.0",
"libp2p": "../../",
"wrtc": "^0.4.7"
},
Expand Down
74 changes: 48 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,19 @@
],
"exports": {
".": {
"types": "./src/index.d.ts",
"import": "./dist/src/index.js"
},
"./insecure": {
"types": "./dist/src/insecure/index.d.ts",
"import": "./dist/src/insecure/index.js"
},
"./pnet": {
"types": "./dist/src/pnet/index.d.ts",
"import": "./dist/src/pnet/index.js"
},
"./transport-manager": {
"types": "./dist/src/transport-manager.d.ts",
"import": "./dist/src/transport-manager.js"
}
},
Expand Down Expand Up @@ -93,18 +97,34 @@
},
"dependencies": {
"@achingbrain/nat-port-mapper": "^1.0.3",
"@libp2p/connection": "^2.0.2",
"@libp2p/crypto": "^0.22.11",
"@libp2p/interfaces": "^2.0.2",
"@libp2p/logger": "^1.1.4",
"@libp2p/multistream-select": "^1.0.4",
"@libp2p/components": "^1.0.0",
"@libp2p/connection": "^3.0.0",
"@libp2p/crypto": "^1.0.0",
"@libp2p/interface-address-manager": "^1.0.1",
"@libp2p/interface-connection": "^1.0.1",
"@libp2p/interface-connection-encrypter": "^1.0.2",
"@libp2p/interface-content-routing": "^1.0.1",
"@libp2p/interface-dht": "^1.0.0",
"@libp2p/interface-metrics": "^1.0.2",
"@libp2p/interface-peer-discovery": "^1.0.0",
"@libp2p/interface-peer-id": "^1.0.2",
"@libp2p/interface-peer-info": "^1.0.1",
"@libp2p/interface-peer-routing": "^1.0.0",
"@libp2p/interface-peer-store": "^1.0.0",
"@libp2p/interface-pubsub": "^1.0.1",
"@libp2p/interface-registrar": "^1.0.0",
"@libp2p/interface-stream-muxer": "^1.0.1",
"@libp2p/interface-transport": "^1.0.0",
"@libp2p/interfaces": "^3.0.2",
"@libp2p/logger": "^2.0.0",
"@libp2p/multistream-select": "^2.0.0",
"@libp2p/peer-collections": "^1.0.2",
"@libp2p/peer-id": "^1.1.10",
"@libp2p/peer-id-factory": "^1.0.9",
"@libp2p/peer-record": "^1.0.8",
"@libp2p/peer-store": "^1.0.10",
"@libp2p/peer-record": "^2.0.0",
"@libp2p/peer-store": "^2.0.0",
"@libp2p/tracked-map": "^1.0.5",
"@libp2p/utils": "^1.0.10",
"@libp2p/utils": "^2.0.0",
"@multiformats/mafmt": "^11.0.2",
"@multiformats/multiaddr": "^10.1.8",
"abortable-iterator": "^4.0.2",
Expand All @@ -119,7 +139,7 @@
"it-filter": "^1.0.3",
"it-first": "^1.0.6",
"it-foreach": "^0.1.1",
"it-handshake": "^3.0.1",
"it-handshake": "^4.0.0",
"it-length-prefixed": "^7.0.1",
"it-map": "^1.0.6",
"it-merge": "^1.0.3",
Expand All @@ -146,22 +166,24 @@
},
"devDependencies": {
"@chainsafe/libp2p-noise": "^6.2.0",
"@libp2p/bootstrap": "^1.0.4",
"@libp2p/daemon-client": "^1.0.2",
"@libp2p/daemon-server": "^1.0.2",
"@libp2p/delegated-content-routing": "^1.0.5",
"@libp2p/delegated-peer-routing": "^1.0.5",
"@libp2p/floodsub": "^1.0.6",
"@libp2p/interface-compliance-tests": "^2.0.3",
"@libp2p/interop": "^1.0.3",
"@libp2p/kad-dht": "^1.0.9",
"@libp2p/mdns": "^1.0.5",
"@libp2p/mplex": "^1.1.0",
"@libp2p/pubsub": "^1.2.18",
"@libp2p/tcp": "^1.0.9",
"@libp2p/topology": "^1.1.7",
"@libp2p/webrtc-star": "^1.0.8",
"@libp2p/websockets": "^1.0.7",
"@libp2p/bootstrap": "^2.0.0",
"@libp2p/daemon-client": "^2.0.0",
"@libp2p/daemon-server": "^2.0.0",
"@libp2p/delegated-content-routing": "^2.0.0",
"@libp2p/delegated-peer-routing": "^2.0.0",
"@libp2p/floodsub": "^2.0.0",
"@libp2p/interface-compliance-tests": "^3.0.1",
"@libp2p/interface-connection-encrypter-compliance-tests": "^1.0.0",
"@libp2p/interface-mocks": "^1.0.1",
"@libp2p/interop": "^2.0.0",
"@libp2p/kad-dht": "^2.0.0",
"@libp2p/mdns": "^2.0.0",
"@libp2p/mplex": "^2.0.0",
"@libp2p/pubsub": "^2.0.0",
"@libp2p/tcp": "^2.0.0",
"@libp2p/topology": "^2.0.0",
"@libp2p/webrtc-star": "^2.0.0",
"@libp2p/websockets": "^2.0.0",
"@types/node-forge": "^1.0.0",
"@types/p-fifo": "^1.0.0",
"@types/varint": "^6.0.0",
Expand All @@ -173,7 +195,7 @@
"go-libp2p": "^0.0.6",
"into-stream": "^7.0.0",
"ipfs-http-client": "^57.0.1",
"it-pushable": "^2.0.1",
"it-pushable": "^3.0.0",
"it-to-buffer": "^2.0.2",
"nock": "^13.0.3",
"npm-run-all": "^4.1.5",
Expand Down
4 changes: 2 additions & 2 deletions src/address-manager/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { AddressManagerEvents } from '@libp2p/interfaces/address-manager'
import type { AddressManagerEvents } from '@libp2p/interface-address-manager'
import { CustomEvent, EventEmitter } from '@libp2p/interfaces/events'
import { Multiaddr } from '@multiformats/multiaddr'
import { peerIdFromString } from '@libp2p/peer-id'
import type { Components } from '@libp2p/interfaces/components'
import type { Components } from '@libp2p/components'

export interface AddressManagerInit {
announceFilter?: AddressFilter
Expand Down
8 changes: 4 additions & 4 deletions src/circuit/auto-relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
HOP_METADATA_VALUE,
RELAY_RENDEZVOUS_NS
} from './constants.js'
import type { PeerId } from '@libp2p/interfaces/peer-id'
import type { AddressSorter, PeerProtocolsChangeData } from '@libp2p/interfaces/peer-store'
import type { Connection } from '@libp2p/interfaces/connection'
import type { Components } from '@libp2p/interfaces/components'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { AddressSorter, PeerProtocolsChangeData } from '@libp2p/interface-peer-store'
import type { Connection } from '@libp2p/interface-connection'
import type { Components } from '@libp2p/components'
import sort from 'it-sort'
import all from 'it-all'
import { pipe } from 'it-pipe'
Expand Down
4 changes: 2 additions & 2 deletions src/circuit/circuit/hop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { pipe } from 'it-pipe'
import { codes as Errors } from '../../errors.js'
import { stop } from './stop.js'
import { RELAY_CODEC } from '../multicodec.js'
import type { Connection } from '@libp2p/interfaces/connection'
import type { Connection } from '@libp2p/interface-connection'
import { peerIdFromBytes } from '@libp2p/peer-id'
import type { Duplex } from 'it-stream-types'
import type { Circuit } from '../transport.js'
import type { ConnectionManager } from '@libp2p/interfaces/connection-manager'
import type { ConnectionManager } from '@libp2p/interface-connection-manager'

const log = logger('libp2p:circuit:hop')

Expand Down
2 changes: 1 addition & 1 deletion src/circuit/circuit/stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CircuitRelay as CircuitPB } from '../pb/index.js'
import { RELAY_CODEC } from '../multicodec.js'
import { StreamHandler } from './stream-handler.js'
import { validateAddrs } from './utils.js'
import type { Connection } from '@libp2p/interfaces/connection'
import type { Connection } from '@libp2p/interface-connection'
import type { Duplex } from 'it-stream-types'

const log = logger('libp2p:circuit:stop')
Expand Down
2 changes: 1 addition & 1 deletion src/circuit/circuit/stream-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { logger } from '@libp2p/logger'
import * as lp from 'it-length-prefixed'
import { Handshake, handshake } from 'it-handshake'
import { CircuitRelay } from '../pb/index.js'
import type { Stream } from '@libp2p/interfaces/connection'
import type { Stream } from '@libp2p/interface-connection'
import type { Source } from 'it-stream-types'

const log = logger('libp2p:circuit:stream-handler')
Expand Down
4 changes: 2 additions & 2 deletions src/circuit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { namespaceToCid } from './utils.js'
import {
RELAY_RENDEZVOUS_NS
} from './constants.js'
import type { AddressSorter } from '@libp2p/interfaces/peer-store'
import type { AddressSorter } from '@libp2p/interface-peer-store'
import type { Startable } from '@libp2p/interfaces/startable'
import type { Components } from '@libp2p/interfaces/components'
import type { Components } from '@libp2p/components'

const log = logger('libp2p:relay')

Expand Down
6 changes: 3 additions & 3 deletions src/circuit/listener.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CustomEvent, EventEmitter } from '@libp2p/interfaces/events'
import type { ConnectionManager } from '@libp2p/interfaces/connection-manager'
import type { PeerStore } from '@libp2p/interfaces/peer-store'
import type { Listener } from '@libp2p/interfaces/transport'
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
import type { PeerStore } from '@libp2p/interface-peer-store'
import type { Listener } from '@libp2p/interface-transport'
import { peerIdFromString } from '@libp2p/peer-id'
import { Multiaddr } from '@multiformats/multiaddr'

Expand Down
10 changes: 5 additions & 5 deletions src/circuit/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import { createListener } from './listener.js'
import { handleCanHop, handleHop, hop } from './circuit/hop.js'
import { handleStop } from './circuit/stop.js'
import { StreamHandler } from './circuit/stream-handler.js'
import { symbol } from '@libp2p/interfaces/transport'
import { symbol } from '@libp2p/interface-transport'
import { peerIdFromString } from '@libp2p/peer-id'
import { Components, Initializable } from '@libp2p/interfaces/components'
import { Components, Initializable } from '@libp2p/components'
import type { AbortOptions } from '@libp2p/interfaces'
import type { IncomingStreamData } from '@libp2p/interfaces/registrar'
import type { Listener, Transport, CreateListenerOptions, ConnectionHandler } from '@libp2p/interfaces/transport'
import type { Connection } from '@libp2p/interfaces/connection'
import type { IncomingStreamData } from '@libp2p/interface-registrar'
import type { Listener, Transport, CreateListenerOptions, ConnectionHandler } from '@libp2p/interface-transport'
import type { Connection } from '@libp2p/interface-connection'

const log = logger('libp2p:circuit')

Expand Down
2 changes: 1 addition & 1 deletion src/connection-manager/auto-dialler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { pipe } from 'it-pipe'
import filter from 'it-filter'
import sort from 'it-sort'
import type { Startable } from '@libp2p/interfaces/startable'
import type { Components } from '@libp2p/interfaces/components'
import type { Components } from '@libp2p/components'

const log = logger('libp2p:connection-manager:auto-dialler')

Expand Down
4 changes: 2 additions & 2 deletions src/connection-manager/dialer/auto-dialer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PeerInfo } from '@libp2p/interfaces/peer-info'
import type { PeerInfo } from '@libp2p/interface-peer-info'
import { logger } from '@libp2p/logger'
import type { Components } from '@libp2p/interfaces/components'
import type { Components } from '@libp2p/components'
import { TimeoutController } from 'timeout-abort-controller'

const log = logger('libp2p:dialer:auto-dialer')
Expand Down
2 changes: 1 addition & 1 deletion src/connection-manager/dialer/dial-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { setMaxListeners } from 'events'
import { codes } from '../../errors.js'
import { logger } from '@libp2p/logger'
import type { Multiaddr } from '@multiformats/multiaddr'
import type { Connection } from '@libp2p/interfaces/connection'
import type { Connection } from '@libp2p/interface-connection'
import type { AbortOptions } from '@libp2p/interfaces'
import type { Dialer } from './index.js'

Expand Down
10 changes: 5 additions & 5 deletions src/connection-manager/dialer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ import {
MAX_PER_PEER_DIALS,
MAX_ADDRS_TO_DIAL
} from '../../constants.js'
import type { Connection } from '@libp2p/interfaces/connection'
import type { Connection } from '@libp2p/interface-connection'
import type { AbortOptions } from '@libp2p/interfaces'
import type { Startable } from '@libp2p/interfaces/startable'
import type { PeerId } from '@libp2p/interfaces/peer-id'
import type { PeerId } from '@libp2p/interface-peer-id'
import { getPeer } from '../../get-peer.js'
import sort from 'it-sort'
import { Components, Initializable } from '@libp2p/interfaces/components'
import { Components, Initializable } from '@libp2p/components'
import map from 'it-map'
import type { AddressSorter } from '@libp2p/interfaces/peer-store'
import type { ComponentMetricsTracker } from '@libp2p/interfaces/metrics'
import type { AddressSorter } from '@libp2p/interface-peer-store'
import type { ComponentMetricsTracker } from '@libp2p/interface-metrics'

const log = logger('libp2p:dialer')

Expand Down
12 changes: 6 additions & 6 deletions src/connection-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { CustomEvent, EventEmitter } from '@libp2p/interfaces/events'
import type { Startable } from '@libp2p/interfaces/startable'
import { trackedMap } from '@libp2p/tracked-map'
import { codes } from '../errors.js'
import { isPeerId, PeerId } from '@libp2p/interfaces/peer-id'
import { isPeerId, PeerId } from '@libp2p/interface-peer-id'
import { setMaxListeners } from 'events'
import type { Connection } from '@libp2p/interfaces/connection'
import type { ConnectionManager } from '@libp2p/interfaces/connection-manager'
import { Components, Initializable } from '@libp2p/interfaces/components'
import * as STATUS from '@libp2p/interfaces/connection/status'
import type { Connection } from '@libp2p/interface-connection'
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
import { Components, Initializable } from '@libp2p/components'
import * as STATUS from '@libp2p/interface-connection/status'
import { Dialer } from './dialer/index.js'
import type { AddressSorter } from '@libp2p/interfaces/peer-store'
import type { AddressSorter } from '@libp2p/interface-peer-store'
import type { Resolver } from '@multiformats/multiaddr'

const log = logger('libp2p:connection-manager')
Expand Down
4 changes: 2 additions & 2 deletions src/content-routing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
import drain from 'it-drain'
import merge from 'it-merge'
import { pipe } from 'it-pipe'
import type { ContentRouting } from '@libp2p/interfaces/content-routing'
import type { ContentRouting } from '@libp2p/interface-content-routing'
import type { AbortOptions } from '@libp2p/interfaces'
import type { Startable } from '@libp2p/interfaces/startable'
import type { CID } from 'multiformats/cid'
import type { Components } from '@libp2p/interfaces/components'
import type { Components } from '@libp2p/components'

export interface CompoundContentRoutingInit {
routers: ContentRouting[]
Expand Down
4 changes: 2 additions & 2 deletions src/content-routing/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import errCode from 'err-code'
import filter from 'it-filter'
import map from 'it-map'
import type { Source } from 'it-stream-types'
import type { PeerInfo } from '@libp2p/interfaces/peer-info'
import type { PeerStore } from '@libp2p/interfaces/peer-store'
import type { PeerInfo } from '@libp2p/interface-peer-info'
import type { PeerStore } from '@libp2p/interface-peer-store'

/**
* Store the multiaddrs from every peer in the passed peer store
Expand Down
Loading