corestore 6.4.3 → 6.5.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 +14 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -27,6 +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._bootstrap || null
|
|
30
31
|
this._namespace = opts.namespace || DEFAULT_NAMESPACE
|
|
31
32
|
|
|
32
33
|
this._root = root || this
|
|
@@ -81,10 +82,18 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
async _openNamespaceFromBootstrap () {
|
|
86
|
+
const ns = await this._bootstrap.getUserData(USERDATA_NAMESPACE_KEY)
|
|
87
|
+
if (ns) {
|
|
88
|
+
this._namespace = ns
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
84
92
|
async _open () {
|
|
85
93
|
if (this._root !== this) {
|
|
86
94
|
await this._root._opening
|
|
87
95
|
if (!this.primaryKey) this.primaryKey = this._root.primaryKey
|
|
96
|
+
if (this._bootstrap) await this._openNamespaceFromBootstrap()
|
|
88
97
|
return
|
|
89
98
|
}
|
|
90
99
|
|
|
@@ -107,6 +116,8 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
107
116
|
})
|
|
108
117
|
})
|
|
109
118
|
})
|
|
119
|
+
|
|
120
|
+
if (this._bootstrap) await this._openNamespaceFromBootstrap()
|
|
110
121
|
}
|
|
111
122
|
|
|
112
123
|
async _generateKeys (opts) {
|
|
@@ -302,6 +313,9 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
302
313
|
}
|
|
303
314
|
|
|
304
315
|
namespace (name) {
|
|
316
|
+
if (name instanceof Hypercore) {
|
|
317
|
+
return this.session({ _bootstrap: name })
|
|
318
|
+
}
|
|
305
319
|
return this.session({ namespace: generateNamespace(this._namespace, name) })
|
|
306
320
|
}
|
|
307
321
|
|