You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
* docs: make constructor options linkable
This PR changes the constructor options into headings so that people can link the relevant options. I have needed this multiple times but haven't been able to give people a link to the correct part of the page.
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
* Fix README typos and add links where we now can
This also unifies the style in all the places where default values are different in various environments: use a comma between each environment.
License: MIT
Signed-off-by: Rob Brackett <[email protected]>
@@ -202,56 +202,122 @@ const node = new IPFS([options])
202
202
203
203
Creates and returns an instance of an IPFS node. Use the `options` argument to specify advanced configuration. It is an object with any of these properties:
204
204
205
-
-`repo` (string or [`ipfs.Repo`](https://github.com/ipfs/js-ipfs-repo) instance): The file path at which to store the IPFS node’s data. Alternatively, you can set up a customized storage system by providing an [`ipfs.Repo`](https://github.com/ipfs/js-ipfs-repo) instance. (Default: `'~/.jsipfs'` in Node.js, `'ipfs'` in browsers.)
206
205
207
-
Example:
206
+
##### `options.repo`
208
207
209
-
```js
210
-
// Store data outside your user directory
211
-
constnode=newIPFS({ repo:'/var/ipfs/data' })
212
-
```
208
+
| Type | Default |
209
+
|------|---------|
210
+
| string or [`ipfs.Repo`](https://github.com/ipfs/js-ipfs-repo) instance |`'~/.jsipfs'` in Node.js, `'ipfs'` in browsers |
211
+
212
+
The file path at which to store the IPFS node’s data. Alternatively, you can set up a customized storage system by providing an [`ipfs.Repo`](https://github.com/ipfs/js-ipfs-repo) instance.
213
+
214
+
Example:
215
+
216
+
```js
217
+
// Store data outside your user directory
218
+
constnode=newIPFS({ repo:'/var/ipfs/data' })
219
+
```
220
+
221
+
##### `options.init`
222
+
223
+
| Type | Default |
224
+
|------|---------|
225
+
| boolean or object |`true`|
226
+
227
+
Initialize the repo when creating the IPFS node.
228
+
229
+
If you have already initialized a repo before creating your IPFS node (e.g. you are loading a repo that was saved to disk from a previous run of your program), you must make sure to set this to `false`. Note that *initializing* a repo is different from creating an instance of [`ipfs.Repo`](https://github.com/ipfs/js-ipfs-repo). The IPFS constructor sets many special properties when initializing a repo, so you should usually not try and call `repoInstance.init()` yourself.
230
+
231
+
Instead of a boolean, you may provide an object with custom initialization options. All properties are optional:
232
+
233
+
-`emptyRepo` (boolean) Whether to remove built-in assets, like the instructional tour and empty mutable file system, from the repo. (Default: `false`)
234
+
-`bits` (number) Number of bits to use in the generated key pair. (Default: `2048`)
235
+
-`pass` (string) A passphrase to encrypt keys. You should generally use the [top-level `pass` option](#optionspass) instead of the `init.pass` option (this one will take its value from the top-level option if not set).
236
+
237
+
##### `options.start`
238
+
239
+
| Type | Default |
240
+
|------|---------|
241
+
| boolean |`true`|
242
+
243
+
If `false`, do not automatically start the IPFS node. Instead, you’ll need to manually call [`node.start()`](#nodestartcallback) yourself.
Configure circuit relay (see the [circuit relay tutorial](https://github.com/ipfs/js-ipfs/tree/master/examples/circuit-relaying) to learn more).
260
+
261
+
-`enabled` (boolean): Enable circuit relay dialer and listener. (Default: `false`)
262
+
-`hop` (object)
263
+
-`enabled` (boolean): Make this node a relay (other nodes can connect *through* it). (Default: `false`)
264
+
-`active` (boolean): Make this an *active* relay node. Active relay nodes will attempt to dial a destination peer even if that peer is not yet connected to the relay. (Default: `false`)
265
+
266
+
##### `options.preload`
267
+
268
+
| Type | Default |
269
+
|------|---------|
270
+
| object |`{ enabled: true, addresses: [...] }`|
271
+
272
+
Configure external nodes that will preload content added to this node.
-`addresses` (array): Multiaddr API addresses of nodes that should preload content. **NOTE:** nodes specified here should also be added to your node's bootstrap address list at [`config.Boostrap`](#optionsconfig).
-`sharding` (boolean): Enable directory sharding. Directories that have many child objects will be represented by multiple DAG nodes instead of just one. It can improve lookup performance when a directory has several thousand files or more. (Default: `false`)
287
+
-`dht` (boolean): Enable KadDHT. **This is currently not interopable with `go-ipfs`.**
215
288
216
-
If you have already initialized a repo before creating your IPFSnode (e.g. you are loading a repo that was saved to disk from a previous run of your program), you must make sure to set this to `false`. Note that *initializing* a repo is different from creating an instance of [`ipfs.Repo`](https://github.com/ipfs/js-ipfs-repo). The IPFS constructor sets many special properties when initializing a repo, so you should usually not try and call `repoInstance.init()` yourself.
289
+
##### `options.config`
217
290
218
-
Instead of a boolean, you may provide an object with custom initialization options. All properties are optional:
291
+
| Type | Default |
292
+
|------|---------|
293
+
| object |[`config-nodejs.js`](https://github.com/ipfs/js-ipfs/tree/master/src/core/runtime/config-nodejs.js) in Node.js, [`config-browser.js`](https://github.com/ipfs/js-ipfs/tree/master/src/core/runtime/config-browser.js) in browsers |
219
294
220
-
-`init.emptyRepo` (boolean) Whether to remove built-in assets, like the instructional tour and empty mutable file system, from the repo. (Default:`false`)
221
-
-`init.bits` (number) Numberof bits to use in the generated key pair. (Default:`2048`)
222
-
-`init.pass` (string) A passphrase to encrypt keys. You should generally use the top-level `pass` option instead of the `init.pass`option (this one will take its value from the top-level option if not set).
295
+
Modify the default IPFS node config. This object will be *merged* with the default config; it will not replace it.
223
296
224
-
-`start` (boolean): If `false`, do not automatically start the IPFSnode. Instead, you’ll need to manually call `node.start()` yourself. (Default:`true`)
297
+
##### `options.libp2p`
225
298
226
-
-`pass` (string):A passphrase to encrypt/decrypt your keys.
299
+
| Type | Default |
300
+
|------|---------|
301
+
| object |[`libp2p-nodejs.js`](https://github.com/ipfs/js-ipfs/blob/master/src/core/runtime/libp2p-nodejs.js) in Node.js, [`libp2p-browser.js`](https://github.com/ipfs/js-ipfs/blob/master/src/core/runtime/libp2p-browser.js) in browsers |
227
302
228
-
-`relay` (object): Configure circuit relay (see the [circuit relay tutorial](https://github.com/ipfs/js-ipfs/tree/master/examples/circuit-relaying) to learn more).
229
-
-`enabled` (boolean): Enable circuit relay dialer and listener. (Default:`false`)
230
-
-`hop` (object)
231
-
-`enabled` (boolean): Make this node a relay (other nodes can connect *through* it). (Default:`false`)
232
-
-`active` (boolean): Make this an *active* relay node. Active relay nodes will attempt to dial a destination peer even if that peer is not yet connected to the relay. (Default:`false`)
303
+
Add custom modules to the libp2p stack of your node.
233
304
234
-
-`preload` (object): Configure external nodes that will preload content added to this node
-`addresses` (array): Multiaddr API addresses of nodes that should preload content. NOTE: nodes specified here should also be added to your node's bootstrap address list at `config.Boostrap`
237
-
- `EXPERIMENTAL` (object): Enable and configure experimental features.
- `sharding` (boolean): Enable directory sharding. Directories that have many child objects will be represented by multiple DAG nodes instead of just one. It can improve lookup performance when a directory has several thousand files or more. (Default: `false`)
240
-
- `dht` (boolean): Enable KadDHT. **This is currently not interopable with `go-ipfs`.**
305
+
-`modules` (object):
306
+
-`transport` (Array<[libp2p.Transport](https://github.com/libp2p/interface-transport)>): An array of Libp2p transport classes/instances to use _instead_ of the defaults. See [libp2p/interface-transport](https://github.com/libp2p/interface-transport) for details.
307
+
-`peerDiscovery` (Array<[libp2p.PeerDiscovery](https://github.com/libp2p/interface-peer-discovery)>): An array of Libp2p peer discovery classes/instances to use _instead_ of the defaults. See [libp2p/peer-discovery](https://github.com/libp2p/interface-peer-discovery) for details. If passing a class, configuration can be passed using the config section below under the key corresponding to you module's unique `tag` (a static property on the class)
308
+
-`config` (object):
309
+
-`peerDiscovery` (object):
310
+
- `[PeerDiscovery.tag]` (object): configuration for a peer discovery module
311
+
- `enabled` (boolean): whether this module is enabled or disabled
312
+
- `[custom config]` (any): other keys are specific to the module
241
313
242
-
- `config` (object) Modify the default IPFS node config. Find the Node.js defaults at [`src/core/runtime/config-nodejs.js`](https://github.com/ipfs/js-ipfs/tree/master/src/core/runtime/config-nodejs.js) and the browser defaults at [`src/core/runtime/config-browser.js`](https://github.com/ipfs/js-ipfs/tree/master/src/core/runtime/config-browser.js). This object will be *merged* with the default config; it will not replace it.
314
+
##### `options.connectionManager`
243
315
244
-
- `libp2p` (object) add custom modules to the libp2p stack of your node
245
-
- `modules` (object):
246
-
- `transport` (Array<[libp2p.Transport](https://github.com/libp2p/interface-transport)>): An array of Libp2p transport classes/instances to use _instead_ of the defaults. See [libp2p/interface-transport](https://github.com/libp2p/interface-transport) for details.
247
-
- `peerDiscovery` (Array<[libp2p.PeerDiscovery](https://github.com/libp2p/interface-peer-discovery)>): An array of Libp2p peer discovery classes/instances to use _instead_ of the defaults. See [libp2p/peer-discovery](https://github.com/libp2p/interface-peer-discovery) for details. If passing a class, configuration can be passed using the config section below under the key corresponding to you module's unique `tag` (a static property on the class)
248
-
-`config` (object):
249
-
-`peerDiscovery` (object):
250
-
-`[PeerDiscovery.tag]` (object): configuration for a peer discovery module
251
-
-`enabled` (boolean): whether thismodule is enabled or disabled
252
-
-`[custom config]` (any): other keys are specific to the module
-`connectionManager` (object):Configure the libp2p connection manager, see the [documentation for available options](https://github.com/libp2p/js-libp2p-connection-manager#create-a-connectionmanager).
320
+
Configure the libp2p connection manager.
255
321
256
322
#### Events
257
323
@@ -363,10 +429,10 @@ The core API is grouped into several areas:
-[`ipfs.files.cat(ipfsPath, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filescat). Alias to `ipfs.cat`.
-[`ipfs.files.get(ipfsPath, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesget). Alias to `ipfs.get`.
0 commit comments