corestore 6.15.0 → 6.15.2

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 +16 -11
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -203,6 +203,18 @@ module.exports = class Corestore extends ReadyResource {
203
203
 
204
204
  const publicKey = opts.publicKey || keyPair.publicKey
205
205
 
206
+ if (opts.compat === false) {
207
+ const manifest = { signer: { publicKey } } // default manifest
208
+ const key = Hypercore.key(manifest)
209
+
210
+ return {
211
+ manifest,
212
+ keyPair,
213
+ key,
214
+ discoveryKey: crypto.discoveryKey(key)
215
+ }
216
+ }
217
+
206
218
  return {
207
219
  manifest: null,
208
220
  keyPair,
@@ -265,6 +277,7 @@ module.exports = class Corestore extends ReadyResource {
265
277
  const core = new Hypercore(p => this.storage(storageRoot + '/' + p), {
266
278
  _preready: this._preready.bind(this),
267
279
  autoClose: true,
280
+ active: false,
268
281
  encryptionKey: opts.encryptionKey || null,
269
282
  userData,
270
283
  manifest,
@@ -299,7 +312,7 @@ module.exports = class Corestore extends ReadyResource {
299
312
  }
300
313
 
301
314
  async createKeyPair (name, namespace = this._namespace) {
302
- if (!this.primaryKey) await this.ready()
315
+ if (!this.opened) await this.ready()
303
316
 
304
317
  const keyPair = {
305
318
  publicKey: b4a.allocUnsafe(sodium.crypto_sign_PUBLICKEYBYTES),
@@ -330,7 +343,7 @@ module.exports = class Corestore extends ReadyResource {
330
343
  ...opts,
331
344
  name: null,
332
345
  preload: async () => {
333
- if (!this.primaryKey) await this.ready()
346
+ if (!this.opened) await this.ready()
334
347
 
335
348
  const keys = await this._generateKeys(opts)
336
349
 
@@ -347,26 +360,18 @@ module.exports = class Corestore extends ReadyResource {
347
360
  this._findingPeers.push(core.findingPeers())
348
361
  }
349
362
 
350
- const updateReplication = () => {
351
- if (core.replicator !== null) {
352
- // if the only session left is the internal session + replication sessions, tell the replicator so it can gc
353
- core.replicator.setDownloading(core.replicator.sessions + 1 !== core.sessions.length)
354
- }
355
- }
356
-
357
363
  const gc = () => {
358
364
  // technically better to also clear _findingPeers if we added it,
359
365
  // but the lifecycle for those are pretty short so prob not worth the complexity
360
366
  // as _decFindingPeers clear them all.
361
367
  this._sessions.delete(core)
362
- updateReplication()
363
368
 
364
369
  if (!rw) return
365
370
  rw.write.unlock()
366
371
  if (!rw.write.locked) this._locks.delete(id)
367
372
  }
368
373
 
369
- core.ready().then(updateReplication, gc)
374
+ core.ready().catch(gc)
370
375
  core.once('close', gc)
371
376
 
372
377
  return core
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corestore",
3
- "version": "6.15.0",
3
+ "version": "6.15.2",
4
4
  "description": "A Hypercore factory that simplifies managing collections of cores.",
5
5
  "main": "index.js",
6
6
  "scripts": {