corestore 7.5.0 → 7.6.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 -5
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const sodium = require('sodium-universal')
|
|
|
5
5
|
const crypto = require('hypercore-crypto')
|
|
6
6
|
const ID = require('hypercore-id-encoding')
|
|
7
7
|
const { isAndroid } = require('which-runtime')
|
|
8
|
-
const { STORAGE_EMPTY } = require('hypercore-errors')
|
|
8
|
+
const { STORAGE_EMPTY, ASSERTION } = require('hypercore-errors')
|
|
9
9
|
|
|
10
10
|
const auditStore = require('./lib/audit.js')
|
|
11
11
|
|
|
@@ -255,6 +255,12 @@ class Corestore extends ReadyResource {
|
|
|
255
255
|
this._findingPeers = null // here for legacy
|
|
256
256
|
this._ongcBound = this._ongc.bind(this)
|
|
257
257
|
|
|
258
|
+
if (opts.primaryKey && !this.root && !opts.unsafe) {
|
|
259
|
+
throw ASSERTION(
|
|
260
|
+
'Passing the primary key is unsafe unless you know what you are doing. Set unsafe: true to acknowledge that'
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
|
|
258
264
|
if (this.root) this.corestores.add(this)
|
|
259
265
|
|
|
260
266
|
this.ready().catch(noop)
|
|
@@ -301,11 +307,11 @@ class Corestore extends ReadyResource {
|
|
|
301
307
|
if (!this.storage.readOnly) await this.storage.db.flush()
|
|
302
308
|
if (!this.shouldSuspend) return
|
|
303
309
|
await log('Suspending db...')
|
|
304
|
-
await this.storage.
|
|
310
|
+
await this.storage.suspend()
|
|
305
311
|
}
|
|
306
312
|
|
|
307
313
|
resume() {
|
|
308
|
-
return this.storage.
|
|
314
|
+
return this.storage.resume()
|
|
309
315
|
}
|
|
310
316
|
|
|
311
317
|
session(opts) {
|
|
@@ -388,7 +394,7 @@ class Corestore extends ReadyResource {
|
|
|
388
394
|
if (this.opened === false) await this.ready()
|
|
389
395
|
if (
|
|
390
396
|
!this.cores.opened(toHex(discoveryKey)) &&
|
|
391
|
-
!(await this.storage.
|
|
397
|
+
!(await this.storage.hasCore(discoveryKey, { ifMigrated: true }))
|
|
392
398
|
)
|
|
393
399
|
return
|
|
394
400
|
if (this.closing) return
|
|
@@ -511,7 +517,7 @@ class Corestore extends ReadyResource {
|
|
|
511
517
|
}
|
|
512
518
|
|
|
513
519
|
async _preloadCheckIfExists(opts) {
|
|
514
|
-
const has = await this.storage.
|
|
520
|
+
const has = await this.storage.hasCore(opts.discoveryKey)
|
|
515
521
|
if (!has) throw STORAGE_EMPTY('No Hypercore is stored here')
|
|
516
522
|
return this._preload(opts)
|
|
517
523
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corestore",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.0",
|
|
4
4
|
"description": "A Hypercore factory that simplifies managing collections of cores.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"b4a": "^1.6.7",
|
|
12
|
-
"hypercore": "^11.
|
|
12
|
+
"hypercore": "^11.19.0",
|
|
13
13
|
"hypercore-crypto": "^3.4.2",
|
|
14
14
|
"hypercore-errors": "^1.4.0",
|
|
15
15
|
"hypercore-id-encoding": "^1.3.0",
|