corestore 6.5.0 → 6.5.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 +12 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -27,7 +27,7 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
27
27
|
this.primaryKey = opts.primaryKey || null
|
|
28
28
|
|
|
29
29
|
this._keyStorage = null
|
|
30
|
-
this._bootstrap = opts.
|
|
30
|
+
this._bootstrap = opts._bootstrap || null
|
|
31
31
|
this._namespace = opts.namespace || DEFAULT_NAMESPACE
|
|
32
32
|
|
|
33
33
|
this._root = root || this
|
|
@@ -35,6 +35,7 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
35
35
|
this._overwrite = opts.overwrite === true
|
|
36
36
|
|
|
37
37
|
this._sessions = new Set() // sessions for THIS namespace
|
|
38
|
+
this._rootStoreSessions = new Set()
|
|
38
39
|
|
|
39
40
|
this._findingPeersCount = 0
|
|
40
41
|
this._findingPeers = []
|
|
@@ -63,6 +64,11 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
63
64
|
|
|
64
65
|
_emitCore (name, core) {
|
|
65
66
|
this.emit(name, core)
|
|
67
|
+
for (const session of this._root._rootStoreSessions) {
|
|
68
|
+
if (session !== this) {
|
|
69
|
+
session.emit(name, core)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
66
72
|
if (this !== this._root) this._root.emit(name, core)
|
|
67
73
|
}
|
|
68
74
|
|
|
@@ -314,18 +320,20 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
314
320
|
|
|
315
321
|
namespace (name) {
|
|
316
322
|
if (name instanceof Hypercore) {
|
|
317
|
-
return this.session({
|
|
323
|
+
return this.session({ _bootstrap: name })
|
|
318
324
|
}
|
|
319
325
|
return this.session({ namespace: generateNamespace(this._namespace, name) })
|
|
320
326
|
}
|
|
321
327
|
|
|
322
328
|
session (opts) {
|
|
323
|
-
|
|
329
|
+
const session = new Corestore(this.storage, {
|
|
324
330
|
namespace: this._namespace,
|
|
325
331
|
cache: this.cache,
|
|
326
332
|
_root: this._root,
|
|
327
333
|
...opts
|
|
328
334
|
})
|
|
335
|
+
if (this === this._root) this._rootStoreSessions.add(session)
|
|
336
|
+
return session
|
|
329
337
|
}
|
|
330
338
|
|
|
331
339
|
_closeNamespace () {
|
|
@@ -357,6 +365,7 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
357
365
|
|
|
358
366
|
async _close () {
|
|
359
367
|
await this._opening
|
|
368
|
+
this._root._rootStoreSessions.delete(this)
|
|
360
369
|
await this._closeNamespace()
|
|
361
370
|
if (this._root === this) {
|
|
362
371
|
await this._closePrimaryNamespace()
|