hypercore 11.0.17 → 11.0.19
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/lib/session-state.js +19 -5
- package/package.json +1 -5
package/lib/session-state.js
CHANGED
|
@@ -850,14 +850,21 @@ module.exports = class SessionState {
|
|
|
850
850
|
return head
|
|
851
851
|
}
|
|
852
852
|
|
|
853
|
-
_moveToCore (core) {
|
|
853
|
+
_moveToCore (core, truncated, appended) {
|
|
854
854
|
const head = this.core.sessionStates.pop()
|
|
855
855
|
if (head !== this) this.core.sessionStates[(head.index = this.index)] = head
|
|
856
856
|
|
|
857
857
|
this.core = core
|
|
858
858
|
this.index = this.core.sessionStates.push(this) - 1
|
|
859
859
|
|
|
860
|
-
for (let i = this.sessions.length - 1; i >= 0; i--)
|
|
860
|
+
for (let i = this.sessions.length - 1; i >= 0; i--) {
|
|
861
|
+
const s = this.sessions[i]
|
|
862
|
+
const manifest = s.manifest
|
|
863
|
+
s.transferSession(this.core)
|
|
864
|
+
if (!manifest && s.manifest) s.emit('manifest')
|
|
865
|
+
if (truncated) s.emit('truncate', truncated.to, truncated.fork)
|
|
866
|
+
if (appended) s.emit('append')
|
|
867
|
+
}
|
|
861
868
|
}
|
|
862
869
|
|
|
863
870
|
async moveTo (core, length) {
|
|
@@ -872,6 +879,9 @@ module.exports = class SessionState {
|
|
|
872
879
|
|
|
873
880
|
const treeLength = this.length
|
|
874
881
|
|
|
882
|
+
let truncated = null
|
|
883
|
+
let appended = false
|
|
884
|
+
|
|
875
885
|
if (!this.isSnapshot()) {
|
|
876
886
|
if (this.lingers === null) this.lingers = []
|
|
877
887
|
this.lingers.push(this.storage)
|
|
@@ -900,10 +910,14 @@ module.exports = class SessionState {
|
|
|
900
910
|
this.roots = await this.tree.getRoots(length)
|
|
901
911
|
|
|
902
912
|
if (truncation) {
|
|
903
|
-
const { dependency
|
|
913
|
+
const { dependency } = truncation
|
|
904
914
|
|
|
905
915
|
if (dependency) this.storage.updateDependencyLength(dependency.length, true)
|
|
906
|
-
|
|
916
|
+
truncated = { to: treeLength, fork }
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
if (this.length > treeLength) {
|
|
920
|
+
appended = true
|
|
907
921
|
}
|
|
908
922
|
}
|
|
909
923
|
|
|
@@ -913,7 +927,7 @@ module.exports = class SessionState {
|
|
|
913
927
|
if (state.name === this.name) state._moveToCore(core.core)
|
|
914
928
|
}
|
|
915
929
|
|
|
916
|
-
this._moveToCore(core.core)
|
|
930
|
+
this._moveToCore(core.core, truncated, appended)
|
|
917
931
|
} finally {
|
|
918
932
|
this.mutex.unlock()
|
|
919
933
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hypercore",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.19",
|
|
4
4
|
"description": "Hypercore is a secure, distributed append-only log",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"bare-events": "^2.2.0",
|
|
47
47
|
"big-sparse-array": "^1.0.3",
|
|
48
48
|
"compact-encoding": "^2.11.0",
|
|
49
|
-
"crc-universal": "^1.0.2",
|
|
50
49
|
"fast-fifo": "^1.3.0",
|
|
51
50
|
"flat-tree": "^1.9.0",
|
|
52
51
|
"hypercore-crypto": "^3.2.1",
|
|
@@ -56,7 +55,6 @@
|
|
|
56
55
|
"is-options": "^1.0.1",
|
|
57
56
|
"protomux": "^3.5.0",
|
|
58
57
|
"quickbit-universal": "^2.2.0",
|
|
59
|
-
"random-access-file": "^4.0.0",
|
|
60
58
|
"random-array-iterator": "^1.0.0",
|
|
61
59
|
"safety-catch": "^1.0.1",
|
|
62
60
|
"sodium-universal": "^4.0.0",
|
|
@@ -69,8 +67,6 @@
|
|
|
69
67
|
"debugging-stream": "^3.1.0",
|
|
70
68
|
"hyperswarm": "^4.3.6",
|
|
71
69
|
"rache": "^1.0.0",
|
|
72
|
-
"random-access-memory": "^6.1.0",
|
|
73
|
-
"random-access-memory-overlay": "^3.0.0",
|
|
74
70
|
"range-parser": "^1.2.1",
|
|
75
71
|
"speedometer": "^1.1.0",
|
|
76
72
|
"standard": "^17.0.0",
|