corestore 6.15.11 → 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 +6 -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,6 +32,7 @@ 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 : []
@@ -293,6 +294,7 @@ module.exports = class Corestore extends ReadyResource {
293
294
 
294
295
  if (this._root.closing) throw new Error('The corestore is closed')
295
296
  this.cores.set(id, core)
297
+ this._noCoreCache.delete(id)
296
298
  core.ready().then(() => {
297
299
  if (core.closing) return // extra safety here as ready is a tick after open
298
300
  if (hasKeyPair) core.setKeyPair(keyPair)
@@ -308,6 +310,7 @@ module.exports = class Corestore extends ReadyResource {
308
310
  // trigger once if the condition is already true
309
311
  if (core.replicator.downloading) ondownloading()
310
312
  }, () => {
313
+ this._noCoreCache.set(id, true)
311
314
  this.cores.delete(id)
312
315
  })
313
316
  core.once('close', () => {
@@ -393,6 +396,9 @@ module.exports = class Corestore extends ReadyResource {
393
396
  const stream = Hypercore.createProtocolStream(isInitiator, {
394
397
  ...opts,
395
398
  ondiscoverykey: async discoveryKey => {
399
+ const id = b4a.toString(discoveryKey, 'hex')
400
+ if (this._noCoreCache.get(id)) return
401
+
396
402
  const core = this.get({ _discoveryKey: discoveryKey, active: false })
397
403
 
398
404
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corestore",
3
- "version": "6.15.11",
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": {