Skip to content

Commit a4c596a

Browse files
jacobheunAlan Shaw
authored and
Alan Shaw
committed
feat: use libp2p auto dial (#1983)
1 parent 86eec38 commit a4c596a

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

index.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ const libp2pBundle = (opts) => {
4444
peerBook,
4545
// Lets limit the connection managers peers and have it check peer health less frequently
4646
connectionManager: {
47-
maxPeers: 25,
47+
minPeers: 25,
48+
maxPeers: 100,
4849
pollInterval: 5000
4950
},
5051
modules: {
@@ -68,12 +69,13 @@ const libp2pBundle = (opts) => {
6869
},
6970
config: {
7071
peerDiscovery: {
72+
autoDial: true, // auto dial to peers we find when we have less peers than `connectionManager.minPeers`
7173
mdns: {
7274
interval: 10000,
7375
enabled: true
7476
},
7577
bootstrap: {
76-
interval: 10000,
78+
interval: 30e3,
7779
enabled: true,
7880
list: bootstrapList
7981
}
@@ -87,10 +89,15 @@ const libp2pBundle = (opts) => {
8789
}
8890
},
8991
dht: {
90-
kBucketSize: 20
92+
enabled: true,
93+
kBucketSize: 20,
94+
randomWalk: {
95+
enabled: true,
96+
interval: 10e3, // This is set low intentionally, so more peers are discovered quickly. Higher intervals are recommended
97+
timeout: 2e3 // End the query quickly since we're running so frequently
98+
}
9199
},
92100
EXPERIMENTAL: {
93-
dht: true,
94101
pubsub: true
95102
}
96103
}

package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
"license": "MIT",
1111
"dependencies": {
1212
"ipfs": "file:../../",
13-
"libp2p": "~0.24.0",
14-
"libp2p-bootstrap": "~0.9.3",
15-
"libp2p-kad-dht": "~0.11.1",
16-
"libp2p-mdns": "~0.12.0",
17-
"libp2p-mplex": "~0.8.4",
18-
"libp2p-secio": "~0.10.1",
19-
"libp2p-spdy": "~0.13.0",
13+
"libp2p": "~0.25.0",
14+
"libp2p-bootstrap": "~0.9.7",
15+
"libp2p-kad-dht": "~0.14.12",
16+
"libp2p-mdns": "~0.12.2",
17+
"libp2p-mplex": "~0.8.5",
18+
"libp2p-secio": "~0.11.1",
19+
"libp2p-spdy": "~0.13.3",
2020
"libp2p-tcp": "~0.13.0",
21-
"libp2p-websocket-star": "~0.9.0"
21+
"libp2p-websocket-star": "~0.10.2"
2222
}
2323
}

0 commit comments

Comments
 (0)