Skip to content

Commit 9f8258d

Browse files
committed
deps!: update libp2p to v1 (#610)
Updates all libp2p deps to the v1 release. BREAKING CHANGE: requires libp2p v1
1 parent ee728e7 commit 9f8258d

28 files changed

+296
-244
lines changed

.github/workflows/js-test-and-release.yml

Lines changed: 187 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: test & maybe release
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77
pull_request:
88
workflow_dispatch:
99

@@ -16,10 +16,189 @@ concurrency:
1616
cancel-in-progress: true
1717

1818
jobs:
19-
js-test-and-release:
20-
uses: pl-strflt/uci/.github/workflows/[email protected]
21-
secrets:
22-
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
23-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
24-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
25-
UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }}
19+
check:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v3
23+
- uses: actions/setup-node@v3
24+
with:
25+
node-version: lts/*
26+
- uses: ipfs/aegir/actions/cache-node-modules@master
27+
- run: npm run --if-present lint
28+
- run: npm run --if-present dep-check
29+
- run: npm run --if-present doc-check
30+
31+
test-node:
32+
needs: check
33+
runs-on: ${{ matrix.os }}
34+
strategy:
35+
matrix:
36+
os: [windows-latest, ubuntu-latest, macos-latest]
37+
node: [lts/*]
38+
fail-fast: true
39+
steps:
40+
- uses: actions/checkout@v3
41+
- uses: actions/setup-node@v3
42+
with:
43+
node-version: ${{ matrix.node }}
44+
- uses: ipfs/aegir/actions/cache-node-modules@master
45+
- run: npm run --if-present test:node
46+
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
47+
with:
48+
flags: node
49+
files: .coverage/*,packages/*/.coverage/*
50+
51+
test-chrome:
52+
needs: check
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v3
56+
- uses: actions/setup-node@v3
57+
with:
58+
node-version: lts/*
59+
- uses: ipfs/aegir/actions/cache-node-modules@master
60+
- run: npm run --if-present test:chrome
61+
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
62+
with:
63+
flags: chrome
64+
files: .coverage/*,packages/*/.coverage/*
65+
66+
test-chrome-webworker:
67+
needs: check
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v3
71+
- uses: actions/setup-node@v3
72+
with:
73+
node-version: lts/*
74+
- uses: ipfs/aegir/actions/cache-node-modules@master
75+
- run: npm run --if-present test:chrome-webworker
76+
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
77+
with:
78+
flags: chrome-webworker
79+
files: .coverage/*,packages/*/.coverage/*
80+
81+
test-firefox:
82+
needs: check
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/checkout@v3
86+
- uses: actions/setup-node@v3
87+
with:
88+
node-version: lts/*
89+
- uses: ipfs/aegir/actions/cache-node-modules@master
90+
- run: npm run --if-present test:firefox
91+
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
92+
with:
93+
flags: firefox
94+
files: .coverage/*,packages/*/.coverage/*
95+
96+
test-firefox-webworker:
97+
needs: check
98+
runs-on: ubuntu-latest
99+
steps:
100+
- uses: actions/checkout@v3
101+
- uses: actions/setup-node@v3
102+
with:
103+
node-version: lts/*
104+
- uses: ipfs/aegir/actions/cache-node-modules@master
105+
- run: npm run --if-present test:firefox-webworker
106+
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
107+
with:
108+
flags: firefox-webworker
109+
files: .coverage/*,packages/*/.coverage/*
110+
111+
test-webkit:
112+
needs: check
113+
runs-on: ${{ matrix.os }}
114+
strategy:
115+
matrix:
116+
os: [ubuntu-latest, macos-latest]
117+
node: [lts/*]
118+
fail-fast: true
119+
steps:
120+
- uses: actions/checkout@v3
121+
- uses: actions/setup-node@v3
122+
with:
123+
node-version: lts/*
124+
- uses: ipfs/aegir/actions/cache-node-modules@master
125+
- run: npm run --if-present test:webkit
126+
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
127+
with:
128+
flags: webkit
129+
files: .coverage/*,packages/*/.coverage/*
130+
131+
test-webkit-webworker:
132+
needs: check
133+
runs-on: ${{ matrix.os }}
134+
strategy:
135+
matrix:
136+
os: [ubuntu-latest, macos-latest]
137+
node: [lts/*]
138+
fail-fast: true
139+
steps:
140+
- uses: actions/checkout@v3
141+
- uses: actions/setup-node@v3
142+
with:
143+
node-version: lts/*
144+
- uses: ipfs/aegir/actions/cache-node-modules@master
145+
- run: npm run --if-present test:webkit-webworker
146+
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
147+
with:
148+
flags: webkit-webworker
149+
files: .coverage/*,packages/*/.coverage/*
150+
151+
test-electron-main:
152+
needs: check
153+
runs-on: ubuntu-latest
154+
steps:
155+
- uses: actions/checkout@v3
156+
- uses: actions/setup-node@v3
157+
with:
158+
node-version: lts/*
159+
- uses: ipfs/aegir/actions/cache-node-modules@master
160+
- run: npx xvfb-maybe npm run --if-present test:electron-main
161+
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
162+
with:
163+
flags: electron-main
164+
files: .coverage/*,packages/*/.coverage/*
165+
166+
test-electron-renderer:
167+
needs: check
168+
runs-on: ubuntu-latest
169+
steps:
170+
- uses: actions/checkout@v3
171+
- uses: actions/setup-node@v3
172+
with:
173+
node-version: lts/*
174+
- uses: ipfs/aegir/actions/cache-node-modules@master
175+
- run: npx xvfb-maybe npm run --if-present test:electron-renderer
176+
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
177+
with:
178+
flags: electron-renderer
179+
files: .coverage/*,packages/*/.coverage/*
180+
181+
release:
182+
needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-webkit, test-webkit-webworker, test-electron-main, test-electron-renderer]
183+
runs-on: ubuntu-latest
184+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
185+
permissions:
186+
id-token: write
187+
contents: write
188+
pull-requests: write
189+
steps:
190+
- uses: actions/checkout@v3
191+
with:
192+
fetch-depth: 0
193+
- uses: actions/setup-node@v3
194+
with:
195+
node-version: lts/*
196+
- uses: ipfs/aegir/actions/cache-node-modules@master
197+
- uses: ipfs/aegir/actions/docker-login@master
198+
with:
199+
docker-token: ${{ secrets.DOCKER_TOKEN }}
200+
docker-username: ${{ secrets.DOCKER_USERNAME }}
201+
- run: npm run --if-present release
202+
env:
203+
GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN || github.token }}
204+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Semantic PR
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
main:
12+
uses: pl-strflt/.github/.github/workflows/[email protected]

README.md

Lines changed: 6 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,169 +1,36 @@
1-
# ipfs-bitswap <!-- omit in toc -->
2-
31
[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
42
[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
53
[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs-bitswap.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-bitswap)
6-
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/js-ipfs-bitswap/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/ipfs/js-ipfs-bitswap/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
4+
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/js-ipfs-bitswap/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/js-ipfs-bitswap/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
75

86
> JavaScript implementation of the Bitswap data exchange protocol used by IPFS
97
10-
## Table of contents <!-- omit in toc -->
11-
12-
- [Install](#install)
13-
- [Browser `<script>` tag](#browser-script-tag)
14-
- [Stats](#stats)
15-
- [Peer accessor:](#peer-accessor)
16-
- [Global snapshot accessor:](#global-snapshot-accessor)
17-
- [Moving average accessor:](#moving-average-accessor)
18-
- [Performance tests](#performance-tests)
19-
- [Profiling](#profiling)
20-
- [API Docs](#api-docs)
21-
- [License](#license)
22-
- [Contribute](#contribute)
23-
24-
## Install
8+
# Install
259

2610
```console
2711
$ npm i ipfs-bitswap
2812
```
2913

30-
### Browser `<script>` tag
14+
## Browser `<script>` tag
3115

3216
Loading this module through a script tag will make it's exports available as `IpfsBitswap` in the global namespace.
3317

3418
```html
3519
<script src="https://unpkg.com/ipfs-bitswap/dist/index.min.js"></script>
3620
```
3721

38-
## Stats
39-
40-
```js
41-
const bitswapNode = // ...
42-
43-
const stats = bitswapNode.stats
44-
```
45-
46-
Stats contains a snapshot accessor, a moving average acessor and a peer accessor.
47-
48-
Besides that, it emits "update" events every time it is updated.
49-
50-
```js
51-
stats.on('update', (stats) => {
52-
console.log('latest stats snapshot: %j', stats)
53-
})
54-
```
55-
56-
### Peer accessor:
57-
58-
You can get the stats for a specific peer by doing:
59-
60-
```js
61-
const peerStats = stats.forPeer(peerId)
62-
```
63-
64-
The returned object behaves like the root stats accessor (has a snapshot, a moving average accessors and is an event emitter).
65-
66-
### Global snapshot accessor:
67-
68-
```js
69-
const snapshot = stats.snapshot
70-
console.log('stats: %j', snapshot)
71-
```
72-
73-
the snapshot will contain the following keys, with the values being [bignumber.js](https://github.com/MikeMcl/bignumber.js#readme) instances:
74-
75-
```js
76-
// stats: {
77-
// "dataReceived":"96",
78-
// "blocksReceived":"2",
79-
// "dataReceived":"96",
80-
// "dupBlksReceived":"0",
81-
// "dupDataReceived":"0",
82-
// "blocksSent":"0",
83-
// "dataSent":"0",
84-
// "providesBufferLength":"0",
85-
// "wantListLength":"0",
86-
// "peerCount":"1"
87-
// }
88-
```
89-
90-
### Moving average accessor:
91-
92-
```js
93-
const movingAverages = stats.movingAverages
94-
```
95-
96-
This object contains these properties:
97-
98-
- 'blocksReceived',
99-
- 'dataReceived',
100-
- 'dupBlksReceived',
101-
- 'dupDataReceived',
102-
- 'blocksSent',
103-
- 'dataSent',
104-
- 'providesBufferLength',
105-
- 'wantListLength',
106-
- 'peerCount'
107-
108-
```js
109-
const dataReceivedMovingAverages = movingAverages.dataReceived
110-
```
111-
112-
Each one of these will contain one key per interval (miliseconds), being the default intervals defined:
113-
114-
- 60000 (1 minute)
115-
- 300000 (5 minutes)
116-
- 900000 (15 minutes)
117-
118-
You can then select one of them
119-
120-
```js
121-
const oneMinuteDataReceivedMovingAverages = dataReceivedMovingAverages[60000]
122-
```
123-
124-
This object will be a [movingAverage](https://github.com/pgte/moving-average#readme) instance.
125-
126-
## Performance tests
127-
128-
You can run performance tests like this:
129-
130-
```
131-
$ npm run benchmarks
132-
```
133-
134-
### Profiling
135-
136-
You can run each of the individual performance tests with a profiler like 0x.
137-
138-
To do that, you need to install 0x:
139-
140-
```bash
141-
$ npm install 0x --global
142-
```
143-
144-
And then run the test:
145-
146-
```bash
147-
$ 0x test/benchmarks/get-many
148-
```
149-
150-
This will output a flame graph and print the location for it.
151-
Use the browser Chrome to open and inspect the generated graph.
152-
153-
![Flame graph](https://ipfs.io/ipfs/QmVbyLgYfkLewNtzTAFwAEMmP2hTJgs8sSqsRTBNBjyQ1y)
154-
155-
## API Docs
22+
# API Docs
15623

15724
- <https://ipfs.github.io/js-ipfs-bitswap>
15825

159-
## License
26+
# License
16027

16128
Licensed under either of
16229

16330
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
16431
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
16532

166-
## Contribute
33+
# Contribute
16734

16835
Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs-bitswap/issues).
16936

0 commit comments

Comments
 (0)