corestore 6.16.2 → 6.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +10 -2
  2. package/index.js +8 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -24,11 +24,18 @@ const core2 = store.get({ name: 'core-2' })
24
24
  ```
25
25
 
26
26
  ### API
27
- #### `const store = new Corestore(storage)`
27
+ #### `const store = new Corestore(storage, opts = {})`
28
28
  Create a new Corestore instance.
29
29
 
30
30
  `storage` can be either a random-access-storage module, a string, or a function that takes a path and returns an random-access-storage instance.
31
31
 
32
+ Opts include:
33
+ ```js
34
+ {
35
+ inflightRange: null // Advanced option. Forwarded to the Hypercores created by corestore.get(...)
36
+ }
37
+ ```
38
+
32
39
  #### `const core = store.get(key | { name: 'a-name', exclusive, ...hypercoreOpts})`
33
40
  Loads a Hypercore, either by name (if the `name` option is provided), or from the provided key (if the first argument is a Buffer or String with hex/z32 key, or if the `key` options is set).
34
41
 
@@ -81,7 +88,8 @@ Useful when an application wants to accept an optional Corestore, but needs to m
81
88
  {
82
89
  primaryKey, // Overrides the primaryKey for this session
83
90
  namespace, // If set to null it will reset to the DEFAULT_NAMESPACE
84
- detach: true // By disabling this, closing the session will also close the store that created the session
91
+ detach: true, // By disabling this, closing the session will also close the store that created the session
92
+ inflightRange: null // Advanced option. Forwarded to the Hypercores created by `session.get(...)
85
93
  }
86
94
  ```
87
95
 
package/index.js CHANGED
@@ -17,6 +17,7 @@ const USERDATA_NAME_KEY = 'corestore/name'
17
17
  const USERDATA_NAMESPACE_KEY = 'corestore/namespace'
18
18
  const POOL_SIZE = 512 // how many open fds to aim for before cycling them
19
19
  const DEFAULT_MANIFEST = 0 // bump to 1 when this is more widely deployed
20
+ const DEFAULT_COMPAT = true
20
21
 
21
22
  module.exports = class Corestore extends ReadyResource {
22
23
  constructor (storage, opts = {}) {
@@ -30,6 +31,8 @@ module.exports = class Corestore extends ReadyResource {
30
31
  this.primaryKey = opts.primaryKey || null
31
32
  this.passive = !!opts.passive
32
33
  this.manifestVersion = typeof opts.manifestVersion === 'number' ? opts.manifestVersion : (root ? root.manifestVersion : DEFAULT_MANIFEST)
34
+ this.compat = typeof opts.compat === 'boolean' ? opts.compat : (root ? root.compat : DEFAULT_COMPAT)
35
+ this.inflightRange = opts.inflightRange || null
33
36
 
34
37
  this._keyStorage = null
35
38
  this._bootstrap = opts._bootstrap || null
@@ -219,7 +222,7 @@ module.exports = class Corestore extends ReadyResource {
219
222
 
220
223
  const publicKey = opts.publicKey || keyPair.publicKey
221
224
 
222
- if (opts.compat === false) {
225
+ if (opts.compat === false || (opts.compat !== true && !this.compat)) {
223
226
  let manifest = { version: this.manifestVersion, signers: [{ publicKey }] } // default manifest
224
227
  let key = Hypercore.key(manifest)
225
228
  let discoveryKey = crypto.discoveryKey(key)
@@ -382,6 +385,9 @@ module.exports = class Corestore extends ReadyResource {
382
385
  if (this._readonly && opts.writable !== false) {
383
386
  opts.writable = false
384
387
  }
388
+ if (!opts.inflightRange && this.inflightRange) {
389
+ opts.inflightRange = this.inflightRange
390
+ }
385
391
 
386
392
  let rw = null
387
393
  let id = null
@@ -481,6 +487,7 @@ module.exports = class Corestore extends ReadyResource {
481
487
  writable: !this._readonly,
482
488
  _attached: opts && opts.detach === false ? this : null,
483
489
  _root: this._root,
490
+ inflightRange: this.inflightRange,
484
491
  ...opts
485
492
  })
486
493
  if (this === this._root) this._rootStoreSessions.add(session)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corestore",
3
- "version": "6.16.2",
3
+ "version": "6.18.0",
4
4
  "description": "A Hypercore factory that simplifies managing collections of cores.",
5
5
  "main": "index.js",
6
6
  "scripts": {