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

Commit a6b201a

Browse files
authored
feat: libp2p async peerstore (#4018)
Refactors interfaces and classes used by `libp2p-interfaces` to use the async peer store from libp2p/js-libp2p#1058 Fixes memory leak in libp2p, discussion in linked issue above. BREAKING CHANGE: peerstore methods are now all async, the repo is migrated to v12
1 parent b7746b5 commit a6b201a

File tree

48 files changed

+360
-184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+360
-184
lines changed

.github/workflows/test.yml

+26-45
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- uses: actions/checkout@v2
1717
- uses: actions/setup-node@v2
1818
with:
19-
node-version: 16
19+
node-version: lts/*
2020
- uses: ipfs/aegir/actions/cache-node-modules@master
2121
with:
2222
build: |
@@ -30,7 +30,7 @@ jobs:
3030
- uses: actions/checkout@v2
3131
- uses: actions/setup-node@v2
3232
with:
33-
node-version: 16
33+
node-version: lts/*
3434
- uses: ipfs/aegir/actions/cache-node-modules@master
3535
with:
3636
build: |
@@ -41,7 +41,7 @@ jobs:
4141
npm run dep-check -- -- -- -- --unused
4242
4343
test-node:
44-
name: Unit tests ${{ matrix.project }} node ${{ matrix.node }} ${{ matrix.os }}
44+
name: Unit tests node ${{ matrix.node }} ${{ matrix.os }}
4545
needs: build
4646
runs-on: ${{ matrix.os }}
4747
strategy:
@@ -62,11 +62,10 @@ jobs:
6262
- run: npm run test:node -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
6363
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
6464
with:
65-
directory: '**/.nyc_output'
6665
flags: node
6766

6867
test-chrome:
69-
name: Unit tests ${{ matrix.project }} ${{ matrix.browser }} ${{ matrix.type }}
68+
name: Unit tests chrome
7069
needs: build
7170
runs-on: ubuntu-latest
7271
steps:
@@ -83,21 +82,12 @@ jobs:
8382
- run: npm run test:chrome -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
8483
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
8584
with:
86-
directory: '**/.nyc_output'
8785
flags: chrome
8886

8987
test-chrome-webworker:
90-
name: Unit tests ${{ matrix.project }} ${{ matrix.browser }} ${{ matrix.type }}
88+
name: Unit tests chrome-webworker
9189
needs: build
9290
runs-on: ubuntu-latest
93-
strategy:
94-
matrix:
95-
browser:
96-
- chromium
97-
- firefox
98-
type:
99-
- browser
100-
- webworker
10191
steps:
10292
- uses: actions/checkout@v2
10393
with:
@@ -112,11 +102,10 @@ jobs:
112102
- run: npm run test:chrome-webworker -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
113103
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
114104
with:
115-
directory: '**/.nyc_output'
116105
flags: chrome-webworker
117106

118107
test-firefox:
119-
name: Unit tests ${{ matrix.project }} ${{ matrix.browser }} ${{ matrix.type }}
108+
name: Unit tests firefox
120109
needs: build
121110
runs-on: ubuntu-latest
122111
steps:
@@ -133,21 +122,12 @@ jobs:
133122
- run: npm run test:firefox -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
134123
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
135124
with:
136-
directory: '**/.nyc_output'
137125
flags: firefox
138126

139127
test-firefox-webworker:
140-
name: Unit tests ${{ matrix.project }} ${{ matrix.browser }} ${{ matrix.type }}
128+
name: Unit tests firefox-webworker
141129
needs: build
142130
runs-on: ubuntu-latest
143-
strategy:
144-
matrix:
145-
browser:
146-
- chromium
147-
- firefox
148-
type:
149-
- browser
150-
- webworker
151131
steps:
152132
- uses: actions/checkout@v2
153133
with:
@@ -159,10 +139,10 @@ jobs:
159139
with:
160140
build: |
161141
npm run link
142+
- run: npx playwright install --with-deps
162143
- run: npm run test:firefox-webworker -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
163144
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
164145
with:
165-
directory: '**/.nyc_output'
166146
flags: firefox-webworker
167147

168148
test-electron-main:
@@ -175,7 +155,7 @@ jobs:
175155
fetch-depth: 0
176156
- uses: actions/setup-node@v2
177157
with:
178-
node-version: 16
158+
node-version: lts/*
179159
- uses: ipfs/aegir/actions/cache-node-modules@master
180160
with:
181161
build: |
@@ -185,7 +165,6 @@ jobs:
185165
run: npm run test:electron-main -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- --bail
186166
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
187167
with:
188-
directory: '**/.nyc_output'
189168
flags: electron-main
190169

191170
test-electron-renderer:
@@ -198,7 +177,7 @@ jobs:
198177
fetch-depth: 0
199178
- uses: actions/setup-node@v2
200179
with:
201-
node-version: 16
180+
node-version: lts/*
202181
- uses: ipfs/aegir/actions/cache-node-modules@master
203182
with:
204183
build: |
@@ -208,12 +187,10 @@ jobs:
208187
run: npm run test:electron-renderer -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- --bail
209188
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
210189
with:
211-
directory: '**/.nyc_output'
212190
flags: electron-renderer
213191

214192
test-interop:
215193
name: Interop tests ${{ matrix.project }} ${{ matrix.type }}
216-
needs: build
217194
runs-on: ubuntu-latest
218195
strategy:
219196
matrix:
@@ -228,20 +205,22 @@ jobs:
228205
fetch-depth: 0
229206
- uses: actions/setup-node@v2
230207
with:
231-
node-version: 16
208+
node-version: lts/*
232209
- uses: ipfs/aegir/actions/cache-node-modules@master
233210
with:
234211
build: |
235212
npm run link
236-
- run: npm run test:interop -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- -- -t ${{ matrix.type }}
213+
- run: |
214+
npm install
215+
npm run build
216+
npm run link
217+
npm run test:interop -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- -- -t ${{ matrix.type }}
237218
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
238219
with:
239-
directory: '**/.nyc_output'
240220
flags: interop-${{ matrix.type }}
241221

242222
test-interface:
243223
name: Interface tests ${{ matrix.suite }} ${{ matrix.type }}
244-
needs: build
245224
runs-on: ubuntu-latest
246225
strategy:
247226
matrix:
@@ -261,15 +240,14 @@ jobs:
261240
fetch-depth: 0
262241
- uses: actions/setup-node@v2
263242
with:
264-
node-version: 16
265-
- uses: ipfs/aegir/actions/cache-node-modules@master
266-
with:
267-
build: |
268-
npm run link
269-
- run: npm run ${{ matrix.suite }} -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- -t ${{ matrix.type }}
243+
node-version: lts/*
244+
- run: |
245+
npm install
246+
npm run build
247+
npm run link
248+
npm run ${{ matrix.suite }} -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- -t ${{ matrix.type }}
270249
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
271250
with:
272-
directory: '**/.nyc_output'
273251
flags: interface-${{ matrix.type }}
274252

275253
test-interface-message-port-client:
@@ -282,11 +260,12 @@ jobs:
282260
fetch-depth: 0
283261
- uses: actions/setup-node@v2
284262
with:
285-
node-version: 16
263+
node-version: lts/*
286264
- uses: ipfs/aegir/actions/cache-node-modules@master
287265
with:
288266
build: |
289267
npm run link
268+
- run: npx playwright install --with-deps
290269
- run: npm run test:interface:message-port-client -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
291270

292271
release:
@@ -314,6 +293,8 @@ jobs:
314293
manifest-file: .release-please-manifest.json
315294
config-file: .release-please.json
316295
- uses: actions/checkout@v2
296+
with:
297+
fetch-depth: 0
317298
- uses: actions/setup-node@v2
318299
with:
319300
node-version: lts/*

README.md

-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ We've come a long way, but this project is still in Alpha, lots of development i
3636
* See https://blog.ipfs.io for news and more
3737
* Need help? Please ask 'How do I?' questions on https://discuss.ipfs.io
3838

39-
## Lead Maintainer <!-- omit in toc -->
40-
41-
[Alex Potsides](http://github.com/achingbrain)
42-
4339
## Table of Contents <!-- omit in toc -->
4440

4541
- [Getting started](#getting-started)

packages/interface-ipfs-core/README.md

-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88

99
> A test suite and interface you can use to implement an IPFS core interface.
1010
11-
## Lead Maintainer <!-- omit in toc -->
12-
13-
[Alex Potsides](http://github.com/achingbrain)
14-
1511
## Table of Contents <!-- omit in toc -->
1612

1713
- [Background](#background)

packages/interface-ipfs-core/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@
8989
"it-pushable": "^1.4.2",
9090
"it-tar": "^4.0.0",
9191
"it-to-buffer": "^2.0.0",
92-
"libp2p-crypto": "^0.21.0",
92+
"libp2p-crypto": "^0.21.1",
9393
"libp2p-websockets": "^0.16.2",
94+
"merge-options": "^3.0.4",
9495
"multiaddr": "^10.0.0",
9596
"multiformats": "^9.4.13",
9697
"nanoid": "^3.1.23",

packages/interface-ipfs-core/src/miscellaneous/id.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function testId (factory, options) {
4848

4949
expect(res).to.have.a.property('protocols').that.is.an('array')
5050

51-
expect(res.protocols).to.have.members([
51+
expect(res.protocols).to.include.members([
5252
'/floodsub/1.0.0',
5353
'/ipfs/bitswap/1.0.0',
5454
'/ipfs/bitswap/1.1.0',

packages/interface-ipfs-core/src/miscellaneous/resolve.js

+35-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { getDescribe, getIt } from '../utils/mocha.js'
99
import all from 'it-all'
1010
import { isWebWorker } from 'ipfs-utils/src/env.js'
1111
import { ipfsOptionsWebsocketsFilterAll } from '../utils/ipfs-options-websockets-filter-all.js'
12+
import merge from 'merge-options'
1213

1314
/**
1415
* @typedef {import('ipfsd-ctl').Factory} Factory
@@ -31,7 +32,16 @@ export function testResolve (factory, options) {
3132
let ipfsId
3233

3334
before(async () => {
34-
ipfs = (await factory.spawn({ type: 'proc', ipfsOptions })).api
35+
ipfs = (await factory.spawn({
36+
type: 'proc',
37+
ipfsOptions: merge(ipfsOptions, {
38+
config: {
39+
Routing: {
40+
Type: 'none'
41+
}
42+
}
43+
})
44+
})).api
3545
ipfsId = await ipfs.id()
3646
})
3747

@@ -97,7 +107,16 @@ export function testResolve (factory, options) {
97107
// @ts-ignore this is mocha
98108
this.timeout(20 * 1000)
99109
// webworkers are not dialable because webrtc is not available
100-
const node = (await factory.spawn({ type: isWebWorker ? 'go' : undefined })).api
110+
const node = (await factory.spawn({
111+
type: isWebWorker ? 'go' : undefined,
112+
ipfsOptions: {
113+
config: {
114+
Routing: {
115+
Type: 'none'
116+
}
117+
}
118+
}
119+
})).api
101120
const nodeId = await node.id()
102121
await ipfs.swarm.connect(nodeId.addresses[0])
103122
const { path } = await ipfs.add(uint8ArrayFromString('should resolve a record recursive === true'))
@@ -106,15 +125,24 @@ export function testResolve (factory, options) {
106125
await ipfs.name.publish(path, { allowOffline: true })
107126
await ipfs.name.publish(`/ipns/${ipfsId.id}`, { allowOffline: true, key: 'key-name', resolve: false })
108127

109-
return expect(await ipfs.resolve(`/ipns/${keyId}`))
110-
.to.eq(`/ipfs/${path}`)
128+
return expect(ipfs.resolve(`/ipns/${keyId}`))
129+
.to.eventually.equal(`/ipfs/${path}`)
111130
})
112131

113132
it('should resolve IPNS link non-recursively if recursive==false', async function () {
114133
// @ts-ignore this is mocha
115134
this.timeout(20 * 1000)
116135
// webworkers are not dialable because webrtc is not available
117-
const node = (await factory.spawn({ type: isWebWorker ? 'go' : undefined })).api
136+
const node = (await factory.spawn({
137+
type: isWebWorker ? 'go' : undefined,
138+
ipfsOptions: {
139+
config: {
140+
Routing: {
141+
Type: 'none'
142+
}
143+
}
144+
}
145+
})).api
118146
const nodeId = await node.id()
119147
await ipfs.swarm.connect(nodeId.addresses[0])
120148
const { path } = await ipfs.add(uint8ArrayFromString('should resolve an IPNS key if recursive === false'))
@@ -123,8 +151,8 @@ export function testResolve (factory, options) {
123151
await ipfs.name.publish(path, { allowOffline: true })
124152
await ipfs.name.publish(`/ipns/${ipfsId.id}`, { allowOffline: true, key: 'new-key-name', resolve: false })
125153

126-
return expect(await ipfs.resolve(`/ipns/${keyId}`, { recursive: false }))
127-
.to.eq(`/ipns/${ipfsId.id}`)
154+
return expect(ipfs.resolve(`/ipns/${keyId}`, { recursive: false }))
155+
.to.eventually.equal(`/ipns/${ipfsId.id}`)
128156
})
129157
})
130158
}

packages/interface-ipfs-core/src/name/publish.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ export function testPublish (factory, options) {
2828
let nodeId
2929

3030
before(async () => {
31-
ipfs = (await factory.spawn()).api
31+
ipfs = (await factory.spawn({
32+
ipfsOptions: {
33+
config: {
34+
Routing: {
35+
Type: 'none'
36+
}
37+
}
38+
}
39+
})).api
3240
const peerInfo = await ipfs.id()
3341
nodeId = peerInfo.id
3442
await ipfs.add(fixture.data, { pin: false })

packages/interface-ipfs-core/src/name/resolve.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ export function testResolve (factory, options) {
2828
let nodeId
2929

3030
before(async () => {
31-
ipfs = (await factory.spawn()).api
31+
ipfs = (await factory.spawn({
32+
ipfsOptions: {
33+
config: {
34+
Routing: {
35+
Type: 'none'
36+
}
37+
}
38+
}
39+
})).api
3240
const peerInfo = await ipfs.id()
3341
nodeId = peerInfo.id
3442
})

packages/ipfs-cli/README.md

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
> The implementation of the js-IPFS CLI
44
5-
## Lead Maintainer <!-- omit in toc -->
6-
7-
[Alex Potsides](http://github.com/achingbrain)
8-
95
## Table of Contents <!-- omit in toc -->
106

117
- [Install](#install)

0 commit comments

Comments
 (0)