corestore 6.15.1 → 6.15.3

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 (2) hide show
  1. package/index.js +4 -11
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -277,6 +277,7 @@ module.exports = class Corestore extends ReadyResource {
277
277
  const core = new Hypercore(p => this.storage(storageRoot + '/' + p), {
278
278
  _preready: this._preready.bind(this),
279
279
  autoClose: true,
280
+ active: false,
280
281
  encryptionKey: opts.encryptionKey || null,
281
282
  userData,
282
283
  manifest,
@@ -311,7 +312,7 @@ module.exports = class Corestore extends ReadyResource {
311
312
  }
312
313
 
313
314
  async createKeyPair (name, namespace = this._namespace) {
314
- if (!this.primaryKey) await this.ready()
315
+ if (!this.opened) await this.ready()
315
316
 
316
317
  const keyPair = {
317
318
  publicKey: b4a.allocUnsafe(sodium.crypto_sign_PUBLICKEYBYTES),
@@ -342,7 +343,7 @@ module.exports = class Corestore extends ReadyResource {
342
343
  ...opts,
343
344
  name: null,
344
345
  preload: async () => {
345
- if (!this.primaryKey) await this.ready()
346
+ if (!this.opened) await this.ready()
346
347
 
347
348
  const keys = await this._generateKeys(opts)
348
349
 
@@ -359,26 +360,18 @@ module.exports = class Corestore extends ReadyResource {
359
360
  this._findingPeers.push(core.findingPeers())
360
361
  }
361
362
 
362
- const updateReplication = () => {
363
- if (core.replicator !== null) {
364
- // if the only session left is the internal session + replication sessions, tell the replicator so it can gc
365
- core.replicator.setDownloading(core.replicator.sessions + 1 !== core.sessions.length)
366
- }
367
- }
368
-
369
363
  const gc = () => {
370
364
  // technically better to also clear _findingPeers if we added it,
371
365
  // but the lifecycle for those are pretty short so prob not worth the complexity
372
366
  // as _decFindingPeers clear them all.
373
367
  this._sessions.delete(core)
374
- updateReplication()
375
368
 
376
369
  if (!rw) return
377
370
  rw.write.unlock()
378
371
  if (!rw.write.locked) this._locks.delete(id)
379
372
  }
380
373
 
381
- core.ready().then(updateReplication, gc)
374
+ core.ready().catch(gc)
382
375
  core.once('close', gc)
383
376
 
384
377
  return core
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corestore",
3
- "version": "6.15.1",
3
+ "version": "6.15.3",
4
4
  "description": "A Hypercore factory that simplifies managing collections of cores.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "b4a": "^1.6.4",
34
- "hypercore": "^10.24.2",
34
+ "hypercore": "^10.24.10",
35
35
  "hypercore-crypto": "^3.4.0",
36
36
  "hypercore-id-encoding": "^1.2.0",
37
37
  "read-write-mutexify": "^2.1.0",