1
1
# ipfs-bitswap <!-- omit in toc -->
2
2
3
- [ ![ ] ( https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square )] ( http://ipn.io )
4
- [ ![ ] ( https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square )] ( http://ipfs.io/ )
5
- [ ![ ] ( https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square )] ( http://webchat.freenode.net/?channels=%23ipfs )
6
- [ ![ Build Status] ( https://github.com/ipfs/js-ipfs-bitswap/actions/workflows/js-test-and-release.yml/badge.svg?branch=master )] ( https://github.com/ipfs/js-ipfs-bitswap/actions/workflows/js-test-and-release.yml )
7
- [ ![ ] ( https://coveralls.io/repos/github/ipfs/js-ipfs-bitswap/badge.svg?branch=master )] ( https://coveralls.io/github/ipfs/js-ipfs-bitswap?branch=master )
8
- [ ![ ] ( https://david-dm.org/ipfs/js-ipfs-bitswap.svg?style=flat-square )] ( https://david-dm.org/ipfs/js-ipfs-bitswap )
9
- [ ![ ] ( https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square )] ( https://github.com/feross/standard )
10
- [ ![ ] ( https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square )] ( https://github.com/RichardLitt/standard-readme )
11
- ![ ] ( https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square )
12
- ![ ] ( https://img.shields.io/badge/Node.js-%3E%3D4.0.0-orange.svg?style=flat-square )
3
+ [ ![ ipfs.io] ( https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square )] ( http://ipfs.io )
4
+ [ ![ IRC] ( https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square )] ( http://webchat.freenode.net/?channels=%23ipfs )
5
+ [ ![ Discord] ( https://img.shields.io/discord/806902334369824788?style=flat-square )] ( https://discord.gg/ipfs )
6
+ [ ![ codecov] ( https://img.shields.io/codecov/c/github/ipfs/js-ipfs-bitswap.svg?style=flat-square )] ( https://codecov.io/gh/ipfs/js-ipfs-bitswap )
7
+ [ ![ CI] ( https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square )] ( https://github.com/ipfs/js-ipfs-bitswap/actions/workflows/js-test-and-release.yml )
13
8
14
- > JavaScript implementation of the Bitswap ' data exchange' protocol used by IPFS
9
+ > JavaScript implementation of the Bitswap data exchange protocol used by IPFS
15
10
16
- ## Table of Contents <!-- omit in toc -->
11
+ ## Table of contents <!-- omit in toc -->
17
12
18
13
- [ Install] ( #install )
19
- - [ npm] ( #npm )
20
14
- [ Use in Node.js or in the browser with browserify, webpack or any other bundler] ( #use-in-nodejs-or-in-the-browser-with-browserify-webpack-or-any-other-bundler )
21
15
- [ Use in a browser using a script tag] ( #use-in-a-browser-using-a-script-tag )
22
16
- [ API] ( #api )
28
22
- [ Structure] ( #structure )
29
23
- [ Performance tests] ( #performance-tests )
30
24
- [ Profiling] ( #profiling )
31
- - [ Contribute] ( #contribute )
32
25
- [ License] ( #license )
26
+ - [ Contribute] ( #contribute )
33
27
34
28
## Install
35
29
36
- ### npm
30
+ ``` console
31
+ $ npm i ipfs-bitswap
32
+ ```
37
33
38
34
``` bash
39
35
> npm install ipfs-bitswap
@@ -57,7 +53,7 @@ Loading this module through a script tag will make the `IpfsBitswap` object avai
57
53
58
54
## API
59
55
60
- See https://ipfs.github.io/js-ipfs-bitswap
56
+ See < https://ipfs.github.io/js-ipfs-bitswap >
61
57
62
58
### Stats
63
59
@@ -119,25 +115,25 @@ const movingAverages = stats.movingAverages
119
115
120
116
This object contains these properties:
121
117
122
- * 'blocksReceived',
123
- * 'dataReceived',
124
- * 'dupBlksReceived',
125
- * 'dupDataReceived',
126
- * 'blocksSent',
127
- * 'dataSent',
128
- * 'providesBufferLength',
129
- * 'wantListLength',
130
- * 'peerCount'
118
+ - 'blocksReceived',
119
+ - 'dataReceived',
120
+ - 'dupBlksReceived',
121
+ - 'dupDataReceived',
122
+ - 'blocksSent',
123
+ - 'dataSent',
124
+ - 'providesBufferLength',
125
+ - 'wantListLength',
126
+ - 'peerCount'
131
127
132
128
``` js
133
129
const dataReceivedMovingAverages = movingAverages .dataReceived
134
130
```
135
131
136
132
Each one of these will contain one key per interval (miliseconds), being the default intervals defined:
137
133
138
- * 60000 (1 minute)
139
- * 300000 (5 minutes)
140
- * 900000 (15 minutes)
134
+ - 60000 (1 minute)
135
+ - 300000 (5 minutes)
136
+ - 900000 (15 minutes)
141
137
142
138
You can then select one of them
143
139
@@ -158,19 +154,19 @@ This object will be a [movingAverage](https://github.com/pgte/moving-average#rea
158
154
src
159
155
├── constants.js
160
156
├── decision-engine
161
- │ ├── index.js
162
- │ └── ledger.js
157
+ │ ├── index.js
158
+ │ └── ledger.js
163
159
├── index.js
164
160
├── network.js # Handles peerSet and open new conns
165
161
├── notifications.js # Handles tracking of incomning blocks and wants/unwants.
166
162
├─── want-manager # Keeps track of all blocks the peer (self) wants
167
- │ ├── index.js
168
- │ └── msg-queue.js # Messages to send queue, one per peer
163
+ │ ├── index.js
164
+ │ └── msg-queue.js # Messages to send queue, one per peer
169
165
└─── types
170
166
├── message # (Type) message that is put in the wire
171
- │ ├── entry.js
172
- │ ├── index.js
173
- │ └── message.proto.js
167
+ │ ├── entry.js
168
+ │ ├── index.js
169
+ │ └── message.proto.js
174
170
└── wantlist # (Type) track wanted blocks
175
171
├── entry.js
176
172
└── index.js
180
176
181
177
You can run performance tests like this:
182
178
183
- ```
184
- $ npm run benchmarks
185
- ```
179
+ $ npm run benchmarks
186
180
187
181
### Profiling
188
182
@@ -205,14 +199,17 @@ Use the browser Chrome to open and inspect the generated graph.
205
199
206
200
![ Flame graph] ( https://ipfs.io/ipfs/QmVbyLgYfkLewNtzTAFwAEMmP2hTJgs8sSqsRTBNBjyQ1y )
207
201
202
+ ## License
203
+
204
+ Licensed under either of
205
+
206
+ - Apache 2.0, ([ LICENSE-APACHE] ( LICENSE-APACHE ) / < http://www.apache.org/licenses/LICENSE-2.0 > )
207
+ - MIT ([ LICENSE-MIT] ( LICENSE-MIT ) / < http://opensource.org/licenses/MIT > )
208
+
208
209
## Contribute
209
210
210
- Feel free to join in. All welcome. Open an [ issue] ( https://github.com/ipfs/js-ipfs-bitswap /issues ) !
211
+ Feel free to join in. All welcome. Open an [ issue] ( https://github.com/ipfs/js-ipfs-unixfs-importer /issues ) !
211
212
212
213
This repository falls under the IPFS [ Code of Conduct] ( https://github.com/ipfs/community/blob/master/code-of-conduct.md ) .
213
214
214
215
[ ![ ] ( https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif )] ( https://github.com/ipfs/community/blob/master/CONTRIBUTING.md )
215
-
216
- ## License
217
-
218
- [ MIT] ( LICENSE )
0 commit comments