corestore 7.5.0 → 7.6.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 +13 -6
- 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
|
|
|
@@ -235,7 +235,8 @@ class Corestore extends ReadyResource {
|
|
|
235
235
|
: Hypercore.defaultStorage(storage, {
|
|
236
236
|
id: opts.id,
|
|
237
237
|
allowBackup: opts.allowBackup,
|
|
238
|
-
readOnly: opts.readOnly
|
|
238
|
+
readOnly: opts.readOnly,
|
|
239
|
+
wait: opts.wait
|
|
239
240
|
})
|
|
240
241
|
this.streamTracker = this.root ? this.root.streamTracker : new StreamTracker()
|
|
241
242
|
this.cores = this.root ? this.root.cores : new CoreTracker()
|
|
@@ -255,6 +256,12 @@ class Corestore extends ReadyResource {
|
|
|
255
256
|
this._findingPeers = null // here for legacy
|
|
256
257
|
this._ongcBound = this._ongc.bind(this)
|
|
257
258
|
|
|
259
|
+
if (opts.primaryKey && !this.root && !opts.unsafe) {
|
|
260
|
+
throw ASSERTION(
|
|
261
|
+
'Passing the primary key is unsafe unless you know what you are doing. Set unsafe: true to acknowledge that'
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
|
|
258
265
|
if (this.root) this.corestores.add(this)
|
|
259
266
|
|
|
260
267
|
this.ready().catch(noop)
|
|
@@ -301,11 +308,11 @@ class Corestore extends ReadyResource {
|
|
|
301
308
|
if (!this.storage.readOnly) await this.storage.db.flush()
|
|
302
309
|
if (!this.shouldSuspend) return
|
|
303
310
|
await log('Suspending db...')
|
|
304
|
-
await this.storage.
|
|
311
|
+
await this.storage.suspend()
|
|
305
312
|
}
|
|
306
313
|
|
|
307
314
|
resume() {
|
|
308
|
-
return this.storage.
|
|
315
|
+
return this.storage.resume()
|
|
309
316
|
}
|
|
310
317
|
|
|
311
318
|
session(opts) {
|
|
@@ -388,7 +395,7 @@ class Corestore extends ReadyResource {
|
|
|
388
395
|
if (this.opened === false) await this.ready()
|
|
389
396
|
if (
|
|
390
397
|
!this.cores.opened(toHex(discoveryKey)) &&
|
|
391
|
-
!(await this.storage.
|
|
398
|
+
!(await this.storage.hasCore(discoveryKey, { ifMigrated: true }))
|
|
392
399
|
)
|
|
393
400
|
return
|
|
394
401
|
if (this.closing) return
|
|
@@ -511,7 +518,7 @@ class Corestore extends ReadyResource {
|
|
|
511
518
|
}
|
|
512
519
|
|
|
513
520
|
async _preloadCheckIfExists(opts) {
|
|
514
|
-
const has = await this.storage.
|
|
521
|
+
const has = await this.storage.hasCore(opts.discoveryKey)
|
|
515
522
|
if (!has) throw STORAGE_EMPTY('No Hypercore is stored here')
|
|
516
523
|
return this._preload(opts)
|
|
517
524
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corestore",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.1",
|
|
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",
|