Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit bceed1b

Browse files
committed
chore: update examples
1 parent 5c7355c commit bceed1b

File tree

4 files changed

+19
-26
lines changed

4 files changed

+19
-26
lines changed

examples/custom-libp2p/index.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ const IPFS = require('ipfs')
55
const TCP = require('libp2p-tcp')
66
const MulticastDNS = require('libp2p-mdns')
77
const Bootstrap = require('libp2p-bootstrap')
8-
const SPDY = require('libp2p-spdy')
98
const KadDHT = require('libp2p-kad-dht')
109
const MPLEX = require('libp2p-mplex')
1110
const SECIO = require('libp2p-secio')
1211

1312
/**
1413
* Options for the libp2p bundle
1514
* @typedef {Object} libp2pBundle~options
16-
* @property {PeerInfo} peerInfo - The PeerInfo of the IPFS node
17-
* @property {PeerBook} peerBook - The PeerBook of the IPFS node
15+
* @property {PeerId} peerId - The PeerId of the IPFS node
1816
* @property {Object} config - The config of the IPFS node
1917
* @property {Object} options - The options given to the IPFS node
2018
*/
@@ -27,15 +25,16 @@ const SECIO = require('libp2p-secio')
2725
*/
2826
const libp2pBundle = (opts) => {
2927
// Set convenience variables to clearly showcase some of the useful things that are available
30-
const peerInfo = opts.peerInfo
31-
const peerBook = opts.peerBook
28+
const peerId = opts.peerId
3229
const bootstrapList = opts.config.Bootstrap
3330

3431
// Build and return our libp2p node
3532
// n.b. for full configuration options, see https://github.com/libp2p/js-libp2p/blob/master/doc/CONFIGURATION.md
3633
return new Libp2p({
37-
peerInfo,
38-
peerBook,
34+
peerId,
35+
addresses: {
36+
listen: ['/ip4/127.0.0.1/tcp/0']
37+
},
3938
// Lets limit the connection managers peers and have it check peer health less frequently
4039
connectionManager: {
4140
minPeers: 25,
@@ -47,8 +46,7 @@ const libp2pBundle = (opts) => {
4746
TCP
4847
],
4948
streamMuxer: [
50-
MPLEX,
51-
SPDY
49+
MPLEX
5250
],
5351
connEncryption: [
5452
SECIO

examples/custom-libp2p/package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
"license": "MIT",
1212
"dependencies": {
1313
"ipfs": "^0.45.0",
14-
"libp2p": "^0.27.7",
15-
"libp2p-bootstrap": "^0.10.3",
16-
"libp2p-kad-dht": "^0.18.7",
17-
"libp2p-mdns": "^0.13.1",
18-
"libp2p-mplex": "^0.9.3",
19-
"libp2p-secio": "^0.12.2",
20-
"libp2p-spdy": "^0.13.3",
14+
"libp2p": "^0.28.0-rc.0",
15+
"libp2p-bootstrap": "^0.11.0",
16+
"libp2p-kad-dht": "^0.19.1",
17+
"libp2p-mdns": "^0.14.1",
18+
"libp2p-mplex": "^0.9.5",
19+
"libp2p-secio": "^0.12.4",
2120
"libp2p-tcp": "^0.14.5"
2221
},
2322
"devDependencies": {

examples/custom-libp2p/test.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ const path = require('path')
44
const execa = require('execa')
55
const Libp2p = require('libp2p')
66
const TCP = require('libp2p-tcp')
7-
const SPDY = require('libp2p-spdy')
87
const MPLEX = require('libp2p-mplex')
98
const SECIO = require('libp2p-secio')
10-
const PeerInfo = require('peer-info')
119
const PeerId = require('peer-id')
12-
const multiaddr = require('multiaddr')
1310

1411
async function test () {
1512
let output = ''
@@ -29,18 +26,18 @@ async function test () {
2926

3027
console.info('Dialling', address)
3128

32-
const peerInfo = new PeerInfo(await PeerId.create())
33-
peerInfo.multiaddrs.add(multiaddr('/ip4/127.0.0.1/tcp/0'))
34-
29+
const peerId = await PeerId.create()
3530
const libp2p = new Libp2p({
36-
peerInfo,
31+
peerId,
32+
addresses: {
33+
listen: ['/ip4/127.0.0.1/tcp/0']
34+
},
3735
modules: {
3836
transport: [
3937
TCP
4038
],
4139
streamMuxer: [
42-
MPLEX,
43-
SPDY
40+
MPLEX
4441
],
4542
connEncryption: [
4643
SECIO

packages/ipfs/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@
136136
"libp2p-floodsub": "^0.21.0",
137137
"libp2p-gossipsub": "^0.4.0",
138138
"libp2p-kad-dht": "^0.19.1",
139-
"libp2p-keychain": "^0.6.0",
140139
"libp2p-mdns": "^0.14.1",
141140
"libp2p-mplex": "^0.9.3",
142141
"libp2p-record": "^0.7.3",

0 commit comments

Comments
 (0)