corestore 6.13.0 → 6.14.0
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 +11 -3
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -206,7 +206,6 @@ module.exports = class Corestore extends ReadyResource {
|
|
|
206
206
|
|
|
207
207
|
const namespace = this._getPrereadyUserData(core, USERDATA_NAMESPACE_KEY)
|
|
208
208
|
const keyPair = await this.createKeyPair(b4a.toString(name), namespace)
|
|
209
|
-
|
|
210
209
|
core.setKeyPair(keyPair)
|
|
211
210
|
}
|
|
212
211
|
|
|
@@ -330,18 +329,26 @@ module.exports = class Corestore extends ReadyResource {
|
|
|
330
329
|
this._findingPeers.push(core.findingPeers())
|
|
331
330
|
}
|
|
332
331
|
|
|
332
|
+
const updateReplication = () => {
|
|
333
|
+
if (core.replicator !== null) {
|
|
334
|
+
// if the only session left is the internal session + replication sessions, tell the replicator so it can gc
|
|
335
|
+
core.replicator.setDownloading(core.replicator.sessions + 1 !== core.sessions.length)
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
333
339
|
const gc = () => {
|
|
334
340
|
// technically better to also clear _findingPeers if we added it,
|
|
335
341
|
// but the lifecycle for those are pretty short so prob not worth the complexity
|
|
336
342
|
// as _decFindingPeers clear them all.
|
|
337
343
|
this._sessions.delete(core)
|
|
344
|
+
updateReplication()
|
|
338
345
|
|
|
339
346
|
if (!rw) return
|
|
340
347
|
rw.write.unlock()
|
|
341
|
-
if (rw.write.
|
|
348
|
+
if (!rw.write.locked) this._locks.delete(id)
|
|
342
349
|
}
|
|
343
350
|
|
|
344
|
-
core.ready().
|
|
351
|
+
core.ready().then(updateReplication, gc)
|
|
345
352
|
core.once('close', gc)
|
|
346
353
|
|
|
347
354
|
return core
|
|
@@ -361,6 +368,7 @@ module.exports = class Corestore extends ReadyResource {
|
|
|
361
368
|
}
|
|
362
369
|
|
|
363
370
|
if (this.passive && !core.closing) core.replicate(stream, { session: true })
|
|
371
|
+
await core.close()
|
|
364
372
|
}
|
|
365
373
|
})
|
|
366
374
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corestore",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.14.0",
|
|
4
4
|
"description": "A Hypercore factory that simplifies managing collections of cores.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"b4a": "^1.6.4",
|
|
34
|
-
"hypercore": "^10.
|
|
34
|
+
"hypercore": "^10.22.2",
|
|
35
35
|
"hypercore-crypto": "^3.4.0",
|
|
36
36
|
"hypercore-id-encoding": "^1.2.0",
|
|
37
37
|
"read-write-mutexify": "^2.1.0",
|