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