hypercore 11.38.0 → 11.39.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 +1 -1
- package/lib/core.js +25 -0
- package/package.json +2 -2
package/index.js
CHANGED
package/lib/core.js
CHANGED
|
@@ -939,6 +939,31 @@ module.exports = class Core {
|
|
|
939
939
|
await Promise.allSettled(all)
|
|
940
940
|
}
|
|
941
941
|
|
|
942
|
+
// closes every session and deletes the core from storage
|
|
943
|
+
async purge() {
|
|
944
|
+
if (this.closing !== null) throw new Error('Cannot purge a closed core')
|
|
945
|
+
|
|
946
|
+
const db = this.db
|
|
947
|
+
const ptr = this.storage.core
|
|
948
|
+
const autoClose = this.autoClose
|
|
949
|
+
|
|
950
|
+
// closing the last session would close the storage along with the core
|
|
951
|
+
this.autoClose = false
|
|
952
|
+
|
|
953
|
+
try {
|
|
954
|
+
await this.closeAllSessions(null)
|
|
955
|
+
if (this.hasSession() === true) throw new Error('Cannot purge while sessions are open')
|
|
956
|
+
await this.close()
|
|
957
|
+
} catch (err) {
|
|
958
|
+
this.autoClose = autoClose
|
|
959
|
+
throw err
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
await db.deleteCore(ptr)
|
|
963
|
+
|
|
964
|
+
if (autoClose) await db.close()
|
|
965
|
+
}
|
|
966
|
+
|
|
942
967
|
async destroy() {
|
|
943
968
|
if (this.destroyed === true) return
|
|
944
969
|
this.destroyed = true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hypercore",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.39.0",
|
|
4
4
|
"description": "Hypercore is a secure, distributed append-only log",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"hypercore-crypto": "^3.2.1",
|
|
55
55
|
"hypercore-errors": "^1.5.0",
|
|
56
56
|
"hypercore-id-encoding": "^1.2.0",
|
|
57
|
-
"hypercore-storage": "^3.2
|
|
57
|
+
"hypercore-storage": "^3.3.2",
|
|
58
58
|
"is-options": "^1.0.1",
|
|
59
59
|
"nanoassert": "^2.0.0",
|
|
60
60
|
"protomux": "^3.5.0",
|