Skip to content

Commit

Permalink
refactor!: extract circuit relay v2 to separate module (#2222)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: imports from `libp2p/circuit-relay` should be updated to `@libp2p/circuit-relay-v2`
  • Loading branch information
achingbrain committed Nov 15, 2023
1 parent a364d95 commit 24afba3
Show file tree
Hide file tree
Showing 55 changed files with 451 additions and 1,492 deletions.
1 change: 1 addition & 0 deletions .release-please.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"packages/pubsub": {},
"packages/pubsub-floodsub": {},
"packages/stream-multiplexer-mplex": {},
"packages/transport-circuit-relay-v2": {},
"packages/transport-tcp": {},
"packages/transport-webrtc": {},
"packages/transport-websockets": {},
Expand Down
6 changes: 3 additions & 3 deletions doc/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ import { tcp } from '@libp2p/tcp'
import { mplex } from '@libp2p/mplex'
import { yamux } from '@chainsafe/libp2p-yamux'
import { noise } from '@chainsafe/libp2p-noise'
import { circuitRelayTransport, circuitRelayServer } from 'libp2p/circuit-relay'
import { circuitRelayTransport, circuitRelayServer } from '@libp2p/circuit-relay-v2'
import { identify } from '@libp2p/identify'


Expand Down Expand Up @@ -501,7 +501,7 @@ import { tcp } from '@libp2p/tcp'
import { mplex } from '@libp2p/mplex'
import { yamux } from '@chainsafe/libp2p-yamux'
import { noise } from '@chainsafe/libp2p-noise'
import { circuitRelayTransport } from 'libp2p/circuit-relay'
import { circuitRelayTransport } from '@libp2p/circuit-relay-v2'

const node = await createLibp2p({
transports: [
Expand Down Expand Up @@ -529,7 +529,7 @@ import { createLibp2p } from 'libp2p'
import { tcp } from '@libp2p/tcp'
import { mplex } from '@libp2p/mplex'
import { noise } from '@chainsafe/libp2p-noise'
import { circuitRelayTransport } from 'libp2p/circuit-relay'
import { circuitRelayTransport } from '@libp2p/circuit-relay-v2'

const node = await createLibp2p({
transports: [
Expand Down
1 change: 1 addition & 0 deletions interop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"dependencies": {
"@chainsafe/libp2p-noise": "^13.0.0",
"@chainsafe/libp2p-yamux": "^5.0.0",
"@libp2p/circuit-relay-v2": "^0.0.0",
"@libp2p/identify": "^0.0.0",
"@libp2p/mplex": "^9.0.12",
"@libp2p/ping": "^0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion interop/relay.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { circuitRelayServer } from '@libp2p/circuit-relay-v2'
import { identify } from '@libp2p/identify'
import { webSockets } from '@libp2p/websockets'
import * as filters from '@libp2p/websockets/filters'
import { createLibp2p } from 'libp2p'
import { circuitRelayServer } from 'libp2p/circuit-relay'

export async function createRelay () {
const server = await createLibp2p({
Expand Down
2 changes: 1 addition & 1 deletion interop/test/ping.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { } from 'aegir/chai'
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { circuitRelayTransport } from '@libp2p/circuit-relay-v2'
import { type Identify, identify } from '@libp2p/identify'
import { mplex } from '@libp2p/mplex'
import { ping, type PingService } from '@libp2p/ping'
Expand All @@ -14,7 +15,6 @@ import * as filters from '@libp2p/websockets/filters'
import { webTransport } from '@libp2p/webtransport'
import { type Multiaddr, multiaddr } from '@multiformats/multiaddr'
import { createLibp2p, type Libp2p, type Libp2pOptions } from 'libp2p'
import { circuitRelayTransport } from 'libp2p/circuit-relay'

async function redisProxy (commands: any[]): Promise<any> {
const res = await fetch(`http://localhost:${process.env.proxyPort ?? ''}/`, { body: JSON.stringify(commands), method: 'POST' })
Expand Down
3 changes: 3 additions & 0 deletions interop/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
{
"path": "../packages/stream-multiplexer-mplex"
},
{
"path": "../packages/transport-circuit-relay-v2"
},
{
"path": "../packages/transport-tcp"
},
Expand Down
2 changes: 0 additions & 2 deletions packages/connection-encrypter-plaintext/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ Loading this module through a script tag will make it's exports available as `Li
<script src="https://unpkg.com/@libp2p/plaintext/dist/index.min.js"></script>
```

> Implementation of the DCUtR Protocol
# API Docs

- <https://libp2p.github.io/js-libp2p/modules/_libp2p_plaintext.html>
Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p/.aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default {
const { WebSockets } = await import('@multiformats/mafmt')
const { createLibp2p } = await import('./dist/src/index.js')
const { plaintext } = await import('@libp2p/plaintext')
const { circuitRelayServer, circuitRelayTransport } = await import('./dist/src/circuit-relay/index.js')
const { circuitRelayServer, circuitRelayTransport } = await import('@libp2p/circuit-relay-v2')
const { identify } = await import('@libp2p/identify')
const { fetchService } = await import('./dist/src/fetch/index.js')

Expand Down
10 changes: 1 addition & 9 deletions packages/libp2p/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@
"types": "./dist/src/index.d.ts",
"import": "./dist/src/index.js"
},
"./circuit-relay": {
"types": "./dist/src/circuit-relay/index.d.ts",
"import": "./dist/src/circuit-relay/index.js"
},
"./fetch": {
"types": "./dist/src/fetch/index.d.ts",
"import": "./dist/src/fetch/index.js"
Expand Down Expand Up @@ -99,7 +95,6 @@
"@libp2p/peer-collections": "^4.0.8",
"@libp2p/peer-id": "^3.0.6",
"@libp2p/peer-id-factory": "^3.0.8",
"@libp2p/peer-record": "^6.0.9",
"@libp2p/peer-store": "^9.0.9",
"@libp2p/utils": "^4.0.7",
"@multiformats/mafmt": "^12.1.2",
Expand All @@ -116,15 +111,12 @@
"it-length-prefixed": "^9.0.1",
"it-map": "^3.0.3",
"it-merge": "^3.0.0",
"it-pair": "^2.0.6",
"it-pipe": "^3.0.1",
"it-protobuf-stream": "^1.0.0",
"it-stream-types": "^2.0.1",
"merge-options": "^3.0.4",
"multiformats": "^12.0.1",
"p-defer": "^4.0.0",
"p-queue": "^7.3.4",
"p-retry": "^6.0.0",
"private-ip": "^3.0.0",
"protons-runtime": "^5.0.0",
"rate-limiter-flexible": "^3.0.0",
Expand All @@ -136,6 +128,7 @@
"@chainsafe/libp2p-noise": "^13.0.0",
"@chainsafe/libp2p-yamux": "^5.0.0",
"@libp2p/bootstrap": "^9.0.12",
"@libp2p/circuit-relay-v2": "^0.0.0",
"@libp2p/daemon-client": "^7.0.0",
"@libp2p/daemon-server": "^6.0.0",
"@libp2p/floodsub": "^8.0.13",
Expand All @@ -152,7 +145,6 @@
"execa": "^8.0.1",
"go-libp2p": "^1.1.1",
"it-pushable": "^3.2.0",
"it-to-buffer": "^4.0.1",
"npm-run-all": "^4.1.5",
"p-event": "^6.0.0",
"p-times": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p/src/connection-manager/auto-dial.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PeerMap, PeerSet } from '@libp2p/peer-collections'
import { PeerJobQueue } from '@libp2p/utils/peer-job-queue'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { PeerJobQueue } from '../utils/peer-job-queue.js'
import { AUTO_DIAL_CONCURRENCY, AUTO_DIAL_DISCOVERED_PEERS_DEBOUNCE, AUTO_DIAL_INTERVAL, AUTO_DIAL_MAX_QUEUE_LENGTH, AUTO_DIAL_PEER_RETRY_THRESHOLD, AUTO_DIAL_PRIORITY, LAST_DIAL_FAILURE_KEY, MIN_CONNECTIONS } from './constants.js'
import type { Libp2pEvents, Logger, ComponentLogger } from '@libp2p/interface'
import type { TypedEventTarget } from '@libp2p/interface/events'
Expand Down
119 changes: 0 additions & 119 deletions packages/libp2p/test/circuit-relay/discovery.node.ts

This file was deleted.

Loading

0 comments on commit 24afba3

Please sign in to comment.