Skip to content

Commit 978eb36

Browse files
authoredJan 20, 2022
feat: async peerstore backed by datastores (#1058)
We have a peerstore that keeps all data for all observed peers in memory with no eviction. This is fine when you don't discover many peers but when using the DHT you encounter a significant number of peers so our peer storage grows and grows over time. We have a persistent peer store, but it just periodically writes peers into the datastore to be read at startup, still keeping them in memory. It also means a restart doesn't give you any temporary reprieve from the memory leak as the previously observed peer data is read into memory at startup. This change refactors the peerstore to use a datastore by default, reading and writing peer info as it arrives. It can be configured with a MemoryDatastore if desired. It was necessary to change the peerstore and *book interfaces to be asynchronous since the datastore api is asynchronous. BREAKING CHANGE: `libp2p.handle`, `libp2p.registrar.register` and the peerstore methods have become async
1 parent 0a4dc54 commit 978eb36

File tree

94 files changed

+3212
-3988
lines changed

Some content is hidden

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

94 files changed

+3212
-3988
lines changed
 

‎.github/workflows/examples.yml

+39-361
Large diffs are not rendered by default.

‎.github/workflows/main.yml

+9-115
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,14 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
os: [ubuntu-latest, macos-latest]
15+
os: [ubuntu-latest]
1616
node: [16]
1717
steps:
1818
- uses: actions/checkout@v2
1919
- uses: actions/setup-node@v2
2020
with:
2121
node-version: 16
22-
- uses: actions/cache@v2
23-
id: cache
24-
env:
25-
CACHE_NAME: cache-node-modules
26-
with:
27-
path: |
28-
~/.cache
29-
~/.npm
30-
./node_modules
31-
./dist
32-
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
33-
- name: Install Dependencies
34-
if: steps.cache.outputs.cache-hit != 'true'
35-
run: |
36-
npm install
37-
npm run build
22+
- uses: ipfs/aegir/actions/cache-node-modules@master
3823

3924
check:
4025
needs: build
@@ -43,23 +28,8 @@ jobs:
4328
- uses: actions/checkout@v2
4429
- uses: actions/setup-node@v2
4530
with:
46-
node-version: 16
47-
- uses: actions/cache@v2
48-
id: cache
49-
env:
50-
CACHE_NAME: cache-node-modules
51-
with:
52-
path: |
53-
~/.cache
54-
~/.npm
55-
./node_modules
56-
./dist
57-
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
58-
- name: Install Dependencies
59-
if: steps.cache.outputs.cache-hit != 'true'
60-
run: |
61-
npm install
62-
npm run build
31+
node-version: lts/*
32+
- uses: ipfs/aegir/actions/cache-node-modules@master
6333
- run: npx aegir lint
6434
- run: npx aegir dep-check
6535
- uses: ipfs/aegir/actions/bundle-size@master
@@ -80,23 +50,7 @@ jobs:
8050
- uses: actions/setup-node@v2
8151
with:
8252
node-version: ${{ matrix.node }}
83-
- uses: actions/cache@v2
84-
id: cache
85-
if: matrix.os != 'windows-latest'
86-
env:
87-
CACHE_NAME: cache-node-modules
88-
with:
89-
path: |
90-
~/.cache
91-
~/.npm
92-
./node_modules
93-
./dist
94-
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
95-
- name: Install Dependencies
96-
if: steps.cache.outputs.cache-hit != 'true'
97-
run: |
98-
npm install
99-
npm run build
53+
- uses: ipfs/aegir/actions/cache-node-modules@master
10054
- run: npm run test:node -- --cov --bail
10155
- uses: codecov/codecov-action@v1
10256
test-chrome:
@@ -107,22 +61,7 @@ jobs:
10761
- uses: actions/setup-node@v2
10862
with:
10963
node-version: lts/*
110-
- uses: actions/cache@v2
111-
id: cache
112-
env:
113-
CACHE_NAME: cache-node-modules
114-
with:
115-
path: |
116-
~/.cache
117-
~/.npm
118-
./node_modules
119-
./dist
120-
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
121-
- name: Install Dependencies
122-
if: steps.cache.outputs.cache-hit != 'true'
123-
run: |
124-
npm install
125-
npm run build
64+
- uses: ipfs/aegir/actions/cache-node-modules@master
12665
- run: npm run test:browser -- -t browser -t webworker --bail
12766
test-firefox:
12867
needs: check
@@ -132,22 +71,7 @@ jobs:
13271
- uses: actions/setup-node@v2
13372
with:
13473
node-version: lts/*
135-
- uses: actions/cache@v2
136-
id: cache
137-
env:
138-
CACHE_NAME: cache-node-modules
139-
with:
140-
path: |
141-
~/.cache
142-
~/.npm
143-
./node_modules
144-
./dist
145-
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
146-
- name: Install Dependencies
147-
if: steps.cache.outputs.cache-hit != 'true'
148-
run: |
149-
npm install
150-
npm run build
74+
- uses: ipfs/aegir/actions/cache-node-modules@master
15175
- run: npm run test:browser -- -t browser -t webworker --bail -- --browser firefox
15276
test-ts:
15377
needs: check
@@ -157,22 +81,7 @@ jobs:
15781
- uses: actions/setup-node@v2
15882
with:
15983
node-version: lts/*
160-
- uses: actions/cache@v2
161-
id: cache
162-
env:
163-
CACHE_NAME: cache-node-modules
164-
with:
165-
path: |
166-
~/.cache
167-
~/.npm
168-
./node_modules
169-
./dist
170-
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
171-
- name: Install Dependencies
172-
if: steps.cache.outputs.cache-hit != 'true'
173-
run: |
174-
npm install
175-
npm run build
84+
- uses: ipfs/aegir/actions/cache-node-modules@master
17685
- run: npm run test:ts
17786
test-interop:
17887
needs: check
@@ -182,20 +91,5 @@ jobs:
18291
- uses: actions/setup-node@v2
18392
with:
18493
node-version: lts/*
185-
- uses: actions/cache@v2
186-
id: cache
187-
env:
188-
CACHE_NAME: cache-node-modules
189-
with:
190-
path: |
191-
~/.cache
192-
~/.npm
193-
./node_modules
194-
./dist
195-
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
196-
- name: Install Dependencies
197-
if: steps.cache.outputs.cache-hit != 'true'
198-
run: |
199-
npm install
200-
npm run build
94+
- uses: ipfs/aegir/actions/cache-node-modules@master
20195
- run: npm run test:interop -- --bail -- --exit

0 commit comments

Comments
 (0)
Please sign in to comment.