corestore 7.6.1 → 7.8.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/README.md +1 -1
- package/index.js +47 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Corestore
|
|
2
2
|
|
|
3
|
-
### [See the full API docs at docs.
|
|
3
|
+
### [See the full API docs at docs.pears.com](https://docs.pears.com/helpers/corestore)
|
|
4
4
|
|
|
5
5
|
Corestore is a Hypercore factory that makes it easier to manage large collections of named Hypercores.
|
|
6
6
|
|
package/index.js
CHANGED
|
@@ -396,8 +396,9 @@ class Corestore extends ReadyResource {
|
|
|
396
396
|
if (
|
|
397
397
|
!this.cores.opened(toHex(discoveryKey)) &&
|
|
398
398
|
!(await this.storage.hasCore(discoveryKey, { ifMigrated: true }))
|
|
399
|
-
)
|
|
399
|
+
) {
|
|
400
400
|
return
|
|
401
|
+
}
|
|
401
402
|
if (this.closing) return
|
|
402
403
|
|
|
403
404
|
const core = this._openCore(discoveryKey, { createIfMissing: false })
|
|
@@ -457,6 +458,50 @@ class Corestore extends ReadyResource {
|
|
|
457
458
|
}
|
|
458
459
|
}
|
|
459
460
|
|
|
461
|
+
async staticify(core, opts) {
|
|
462
|
+
if (!this.opened) await this.ready()
|
|
463
|
+
if (!core.opened) await core.ready()
|
|
464
|
+
|
|
465
|
+
const rx = core.state.storage.read()
|
|
466
|
+
|
|
467
|
+
const headPromise = rx.getHead()
|
|
468
|
+
const authPromise = rx.getAuth()
|
|
469
|
+
|
|
470
|
+
rx.tryFlush()
|
|
471
|
+
|
|
472
|
+
const [head, auth] = await Promise.all([headPromise, authPromise])
|
|
473
|
+
if (!head || head.length === 0) throw new Error('Core must have data')
|
|
474
|
+
|
|
475
|
+
const prologue = {
|
|
476
|
+
length: head.length,
|
|
477
|
+
hash: head.rootHash
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
const manifest = {
|
|
481
|
+
version: 1,
|
|
482
|
+
hash: auth.manifest.hash,
|
|
483
|
+
quorum: 0,
|
|
484
|
+
signers: [],
|
|
485
|
+
prologue
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
const c = {
|
|
489
|
+
key: null,
|
|
490
|
+
discoveryKey: null,
|
|
491
|
+
manifest,
|
|
492
|
+
core: core.state.storage.core
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
c.key = Hypercore.key(c.manifest)
|
|
496
|
+
c.discoveryKey = Hypercore.discoveryKey(c.key)
|
|
497
|
+
|
|
498
|
+
await this.storage.createCore(c)
|
|
499
|
+
|
|
500
|
+
const staticCore = this.get({ ...opts, key: c.key })
|
|
501
|
+
await staticCore.ready()
|
|
502
|
+
return staticCore
|
|
503
|
+
}
|
|
504
|
+
|
|
460
505
|
get(opts) {
|
|
461
506
|
this._maybeClosed()
|
|
462
507
|
|
|
@@ -477,6 +522,7 @@ class Corestore extends ReadyResource {
|
|
|
477
522
|
manifest: opts.manifest || null,
|
|
478
523
|
keyPair: opts.keyPair || null,
|
|
479
524
|
onwait: opts.onwait || null,
|
|
525
|
+
pushOnly: opts.pushOnly === true,
|
|
480
526
|
wait: opts.wait !== false,
|
|
481
527
|
timeout: opts.timeout || 0,
|
|
482
528
|
draft: !!opts.draft,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corestore",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.0",
|
|
4
4
|
"description": "A Hypercore factory that simplifies managing collections of cores.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"brittle": "^3.7.0",
|
|
22
|
+
"lunte": "^1.3.0",
|
|
22
23
|
"prettier": "^3.6.2",
|
|
23
24
|
"prettier-config-holepunch": "^2.0.0",
|
|
24
25
|
"rache": "^1.0.0",
|
|
@@ -26,8 +27,10 @@
|
|
|
26
27
|
},
|
|
27
28
|
"scripts": {
|
|
28
29
|
"format": "prettier --write .",
|
|
29
|
-
"test": "
|
|
30
|
-
"test:bare": "bare test
|
|
30
|
+
"test": "npm run test:node && npm run test:bare",
|
|
31
|
+
"test:bare": "brittle-bare --coverage test/*.js",
|
|
32
|
+
"lint": "prettier --check . && lunte",
|
|
33
|
+
"test:node": "brittle-node --coverage test/*.js"
|
|
31
34
|
},
|
|
32
35
|
"repository": {
|
|
33
36
|
"type": "git",
|