corestore 6.15.10 → 6.15.12

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 +3 -0
  2. package/index.js +8 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -85,6 +85,9 @@ Useful when an application wants to accept an optional Corestore, but needs to m
85
85
  }
86
86
  ```
87
87
 
88
+ #### `await store.close()`
89
+ Fully close this Corestore instance.
90
+
88
91
  #### `store.on('core-open', core)`
89
92
  Emitted when the first session for a core is opened.
90
93
 
package/index.js CHANGED
@@ -32,12 +32,14 @@ module.exports = class Corestore extends ReadyResource {
32
32
  this._keyStorage = null
33
33
  this._bootstrap = opts._bootstrap || null
34
34
  this._namespace = opts.namespace || DEFAULT_NAMESPACE
35
+ this._noCoreCache = root ? root._noCoreCache : new Xache({ maxSize: 65536 })
35
36
 
36
37
  this._root = root || this
37
38
  this._replicationStreams = root ? root._replicationStreams : []
38
39
  this._overwrite = opts.overwrite === true
39
40
  this._readonly = opts.writable === false
40
41
  this._attached = opts._attached || null
42
+ this._notDownloadingLinger = opts.notDownloadingLinger
41
43
 
42
44
  this._sessions = new Set() // sessions for THIS namespace
43
45
  this._rootStoreSessions = new Set()
@@ -276,6 +278,7 @@ module.exports = class Corestore extends ReadyResource {
276
278
  const storageRoot = [CORES_DIR, id.slice(0, 2), id.slice(2, 4), id].join('/')
277
279
  const core = new Hypercore(p => this.storage(storageRoot + '/' + p), {
278
280
  _preready: this._preready.bind(this),
281
+ notDownloadingLinger: this._notDownloadingLinger,
279
282
  autoClose: true,
280
283
  active: false,
281
284
  encryptionKey: opts.encryptionKey || null,
@@ -291,6 +294,7 @@ module.exports = class Corestore extends ReadyResource {
291
294
 
292
295
  if (this._root.closing) throw new Error('The corestore is closed')
293
296
  this.cores.set(id, core)
297
+ this._noCoreCache.delete(id)
294
298
  core.ready().then(() => {
295
299
  if (core.closing) return // extra safety here as ready is a tick after open
296
300
  if (hasKeyPair) core.setKeyPair(keyPair)
@@ -306,6 +310,7 @@ module.exports = class Corestore extends ReadyResource {
306
310
  // trigger once if the condition is already true
307
311
  if (core.replicator.downloading) ondownloading()
308
312
  }, () => {
313
+ this._noCoreCache.set(id, true)
309
314
  this.cores.delete(id)
310
315
  })
311
316
  core.once('close', () => {
@@ -391,6 +396,9 @@ module.exports = class Corestore extends ReadyResource {
391
396
  const stream = Hypercore.createProtocolStream(isInitiator, {
392
397
  ...opts,
393
398
  ondiscoverykey: async discoveryKey => {
399
+ const id = b4a.toString(discoveryKey, 'hex')
400
+ if (this._noCoreCache.get(id)) return
401
+
394
402
  const core = this.get({ _discoveryKey: discoveryKey, active: false })
395
403
 
396
404
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corestore",
3
- "version": "6.15.10",
3
+ "version": "6.15.12",
4
4
  "description": "A Hypercore factory that simplifies managing collections of cores.",
5
5
  "main": "index.js",
6
6
  "scripts": {