corestore 7.0.0 → 7.0.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.
- package/index.js +22 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -273,13 +273,14 @@ class Corestore extends ReadyResource {
|
|
|
273
273
|
|
|
274
274
|
const conf = {
|
|
275
275
|
preload: null,
|
|
276
|
-
parent: null,
|
|
276
|
+
parent: opts.parent || null,
|
|
277
277
|
sessions: null,
|
|
278
278
|
ongc: null,
|
|
279
279
|
core: null,
|
|
280
280
|
active: opts.active !== false,
|
|
281
|
-
|
|
282
|
-
|
|
281
|
+
encryption: opts.encryption || null,
|
|
282
|
+
encryptionKey: opts.encryptionKey || null, // back compat, should remove
|
|
283
|
+
isBlockKey: !!opts.isBlockKey, // back compat, should remove
|
|
283
284
|
valueEncoding: opts.valueEncoding || null,
|
|
284
285
|
exclusive: !!opts.exclusive,
|
|
285
286
|
manifest: opts.manifest || null,
|
|
@@ -291,7 +292,20 @@ class Corestore extends ReadyResource {
|
|
|
291
292
|
writable: opts.writable
|
|
292
293
|
}
|
|
293
294
|
|
|
294
|
-
|
|
295
|
+
// name requires us to rt to storage + ready, so needs preload
|
|
296
|
+
// same goes if user has defined async preload obvs
|
|
297
|
+
if (opts.name || opts.preload) {
|
|
298
|
+
conf.preload = this._preload(opts)
|
|
299
|
+
return new Hypercore(null, null, conf)
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// if not not we can sync create it, which just is easier for the
|
|
303
|
+
// upstream user in terms of guarantees (key is there etc etc)
|
|
304
|
+
const core = this._getCore(null, opts)
|
|
305
|
+
|
|
306
|
+
conf.core = core
|
|
307
|
+
conf.sessions = this.sessions.get(core.id)
|
|
308
|
+
conf.ongc = this._ongcBound
|
|
295
309
|
|
|
296
310
|
return new Hypercore(null, null, conf)
|
|
297
311
|
}
|
|
@@ -310,11 +324,12 @@ class Corestore extends ReadyResource {
|
|
|
310
324
|
|
|
311
325
|
return {
|
|
312
326
|
parent: opts.parent || null,
|
|
327
|
+
core,
|
|
313
328
|
sessions: this.sessions.get(core.id),
|
|
314
329
|
ongc: this._ongcBound,
|
|
315
|
-
|
|
316
|
-
encryptionKey: opts.encryptionKey || null,
|
|
317
|
-
isBlockKey: !!opts.isBlockKey
|
|
330
|
+
encryption: opts.encryption || null,
|
|
331
|
+
encryptionKey: opts.encryptionKey || null, // back compat, should remove
|
|
332
|
+
isBlockKey: !!opts.isBlockKey // back compat, should remove
|
|
318
333
|
}
|
|
319
334
|
}
|
|
320
335
|
|