corestore 6.15.11 → 6.15.13

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 +7 -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,10 +294,12 @@ 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)
299
301
  this._emitCore('core-open', core)
302
+ if (this.passive) return
300
303
 
301
304
  const ondownloading = () => {
302
305
  for (const { stream } of this._replicationStreams) {
@@ -308,6 +311,7 @@ module.exports = class Corestore extends ReadyResource {
308
311
  // trigger once if the condition is already true
309
312
  if (core.replicator.downloading) ondownloading()
310
313
  }, () => {
314
+ this._noCoreCache.set(id, true)
311
315
  this.cores.delete(id)
312
316
  })
313
317
  core.once('close', () => {
@@ -393,6 +397,9 @@ module.exports = class Corestore extends ReadyResource {
393
397
  const stream = Hypercore.createProtocolStream(isInitiator, {
394
398
  ...opts,
395
399
  ondiscoverykey: async discoveryKey => {
400
+ const id = b4a.toString(discoveryKey, 'hex')
401
+ if (this._noCoreCache.get(id)) return
402
+
396
403
  const core = this.get({ _discoveryKey: discoveryKey, active: false })
397
404
 
398
405
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corestore",
3
- "version": "6.15.11",
3
+ "version": "6.15.13",
4
4
  "description": "A Hypercore factory that simplifies managing collections of cores.",
5
5
  "main": "index.js",
6
6
  "scripts": {