corestore 6.13.0 → 6.14.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/LICENSE +21 -0
- package/index.js +12 -3
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Holepunch Inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
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
|
|
|
@@ -263,6 +262,7 @@ module.exports = class Corestore extends ReadyResource {
|
|
|
263
262
|
this.cores.set(id, core)
|
|
264
263
|
core.ready().then(() => {
|
|
265
264
|
if (core.closing) return // extra safety here as ready is a tick after open
|
|
265
|
+
if (keyPair && keyPair.secretKey) core.setKeyPair(keyPair)
|
|
266
266
|
this._emitCore('core-open', core)
|
|
267
267
|
for (const { stream } of this._replicationStreams) {
|
|
268
268
|
core.replicate(stream, { session: true })
|
|
@@ -330,18 +330,26 @@ module.exports = class Corestore extends ReadyResource {
|
|
|
330
330
|
this._findingPeers.push(core.findingPeers())
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
+
const updateReplication = () => {
|
|
334
|
+
if (core.replicator !== null) {
|
|
335
|
+
// if the only session left is the internal session + replication sessions, tell the replicator so it can gc
|
|
336
|
+
core.replicator.setDownloading(core.replicator.sessions + 1 !== core.sessions.length)
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
333
340
|
const gc = () => {
|
|
334
341
|
// technically better to also clear _findingPeers if we added it,
|
|
335
342
|
// but the lifecycle for those are pretty short so prob not worth the complexity
|
|
336
343
|
// as _decFindingPeers clear them all.
|
|
337
344
|
this._sessions.delete(core)
|
|
345
|
+
updateReplication()
|
|
338
346
|
|
|
339
347
|
if (!rw) return
|
|
340
348
|
rw.write.unlock()
|
|
341
|
-
if (rw.write.
|
|
349
|
+
if (!rw.write.locked) this._locks.delete(id)
|
|
342
350
|
}
|
|
343
351
|
|
|
344
|
-
core.ready().
|
|
352
|
+
core.ready().then(updateReplication, gc)
|
|
345
353
|
core.once('close', gc)
|
|
346
354
|
|
|
347
355
|
return core
|
|
@@ -361,6 +369,7 @@ module.exports = class Corestore extends ReadyResource {
|
|
|
361
369
|
}
|
|
362
370
|
|
|
363
371
|
if (this.passive && !core.closing) core.replicate(stream, { session: true })
|
|
372
|
+
await core.close()
|
|
364
373
|
}
|
|
365
374
|
})
|
|
366
375
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corestore",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.14.1",
|
|
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.24.1",
|
|
35
35
|
"hypercore-crypto": "^3.4.0",
|
|
36
36
|
"hypercore-id-encoding": "^1.2.0",
|
|
37
37
|
"read-write-mutexify": "^2.1.0",
|