Skip to content

Commit

Permalink
deps: update libp2p deps to v2 (#170)
Browse files Browse the repository at this point in the history
Updates examples to use the new libp2p release
  • Loading branch information
achingbrain authored Sep 18, 2024
1 parent 45f28ff commit 72f62ba
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 26 deletions.
5 changes: 2 additions & 3 deletions 1-dht.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { yamux } from '@chainsafe/libp2p-yamux'
import { bootstrap } from '@libp2p/bootstrap'
import { identify } from '@libp2p/identify'
import { kadDHT, removePublicAddressesMapper } from '@libp2p/kad-dht'
import { mplex } from '@libp2p/mplex'
import { tcp } from '@libp2p/tcp'
import { createLibp2p } from 'libp2p'
import bootstrappers from './bootstrappers.js'
Expand All @@ -15,8 +14,8 @@ const node = await createLibp2p({
listen: ['/ip4/0.0.0.0/tcp/0']
},
transports: [tcp()],
streamMuxers: [yamux(), mplex()],
connectionEncryption: [noise()],
streamMuxers: [yamux()],
connectionEncrypters: [noise()],
peerDiscovery: [
bootstrap({
list: bootstrappers
Expand Down
5 changes: 2 additions & 3 deletions 2-mdns.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { mdns } from '@libp2p/mdns'
import { mplex } from '@libp2p/mplex'
import { tcp } from '@libp2p/tcp'
import { createLibp2p } from 'libp2p'

Expand All @@ -16,9 +15,9 @@ const createNode = async () => {
tcp()
],
streamMuxers: [
yamux(), mplex()
yamux()
],
connectionEncryption: [
connectionEncrypters: [
noise()
],
peerDiscovery: [
Expand Down
9 changes: 4 additions & 5 deletions 3-pubsub.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* eslint-disable no-console */

import { gossipsub } from '@chainsafe/libp2p-gossipsub'
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { bootstrap } from '@libp2p/bootstrap'
import { floodsub } from '@libp2p/floodsub'
import { identify } from '@libp2p/identify'
import { mplex } from '@libp2p/mplex'
import { pubsubPeerDiscovery } from '@libp2p/pubsub-peer-discovery'
import { tcp } from '@libp2p/tcp'
import { createLibp2p } from 'libp2p'
Expand All @@ -16,15 +15,15 @@ const createNode = async (bootstrappers = []) => {
listen: ['/ip4/0.0.0.0/tcp/0']
},
transports: [tcp()],
streamMuxers: [yamux(), mplex()],
connectionEncryption: [noise()],
streamMuxers: [yamux()],
connectionEncrypters: [noise()],
peerDiscovery: [
pubsubPeerDiscovery({
interval: 1000
})
],
services: {
pubsub: floodsub(),
pubsub: gossipsub(),
identify: identify()
}
}
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ Update your libp2p configuration to include MulticastDNS.
import { createLibp2p } from 'libp2p'
import { mdns } from '@libp2p/mdns'
import { tcp } from '@libp2p/tcp'
import { mplex } from '@libp2p/mplex'
import { yamux } from '@chainsafe/libp2p-yamux'
import { noise } from '@chainsafe/libp2p-noise'

Expand All @@ -85,9 +84,9 @@ const createNode = () => {
tcp()
],
streamMuxers: [
yamux(),mplex()
yamux(),
],
connectionEncryption: [
connectionEncrypters: [
noise()
],
peerDiscovery: [
Expand Down
23 changes: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@
"test": "test-node-example test/*"
},
"dependencies": {
"@chainsafe/libp2p-noise": "^15.0.0",
"@chainsafe/libp2p-yamux": "^6.0.1",
"@libp2p/bootstrap": "^10.1.0",
"@libp2p/circuit-relay-v2": "^1.0.5",
"@libp2p/floodsub": "^9.1.0",
"@libp2p/identify": "^2.1.0",
"@libp2p/kad-dht": "^12.1.0",
"@libp2p/mdns": "^10.0.5",
"@libp2p/mplex": "^10.1.0",
"@libp2p/pubsub-peer-discovery": "^10.0.1",
"@libp2p/tcp": "^9.0.4",
"libp2p": "^1.0.8"
"@chainsafe/libp2p-gossipsub": "^14.1.0",
"@chainsafe/libp2p-noise": "^16.0.0",
"@chainsafe/libp2p-yamux": "^7.0.0",
"@libp2p/bootstrap": "^11.0.0",
"@libp2p/circuit-relay-v2": "^2.0.0",
"@libp2p/identify": "^3.0.0",
"@libp2p/kad-dht": "^13.0.0",
"@libp2p/mdns": "^11.0.0",
"@libp2p/pubsub-peer-discovery": "^11.0.0",
"@libp2p/tcp": "^10.0.0",
"libp2p": "^2.0.0"
},
"devDependencies": {
"execa": "^9.2.0",
Expand Down

0 comments on commit 72f62ba

Please sign in to comment.