hypercore 11.33.4 → 11.34.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/lib/replicator.js +2 -2
- package/lib/session-state.js +20 -7
- package/package.json +2 -2
package/lib/replicator.js
CHANGED
|
@@ -1019,7 +1019,7 @@ class Peer {
|
|
|
1019
1019
|
}
|
|
1020
1020
|
|
|
1021
1021
|
let req = null
|
|
1022
|
-
const batch = this.core.storage.read()
|
|
1022
|
+
const batch = this.core.storage.read(this.core.state.fork)
|
|
1023
1023
|
try {
|
|
1024
1024
|
req = await this._getProof(batch, msg, true)
|
|
1025
1025
|
} catch (err) {
|
|
@@ -1051,7 +1051,7 @@ class Peer {
|
|
|
1051
1051
|
}
|
|
1052
1052
|
|
|
1053
1053
|
try {
|
|
1054
|
-
const batch = this.core.storage.read()
|
|
1054
|
+
const batch = this.core.storage.read(this.core.state.fork)
|
|
1055
1055
|
|
|
1056
1056
|
// TODO: could still be answerable if (index, fork) is an ancestor of the current fork
|
|
1057
1057
|
const req =
|
package/lib/session-state.js
CHANGED
|
@@ -46,6 +46,7 @@ class SessionState {
|
|
|
46
46
|
? Math.min(this.length, this.core.state.length)
|
|
47
47
|
: -1
|
|
48
48
|
this.lastTruncation = null
|
|
49
|
+
this.groupUpdated = false
|
|
49
50
|
|
|
50
51
|
this.active = 0
|
|
51
52
|
|
|
@@ -224,11 +225,8 @@ class SessionState {
|
|
|
224
225
|
|
|
225
226
|
tx.deleteGroupUpdate(pointer, this.core.header.tree.timestamp)
|
|
226
227
|
tx.putGroupUpdate(pointer, tree.timestamp, this.core.header.key)
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
length: tree.length,
|
|
230
|
-
fork: tree.fork
|
|
231
|
-
})
|
|
228
|
+
|
|
229
|
+
this.groupUpdated = true
|
|
232
230
|
}
|
|
233
231
|
|
|
234
232
|
_clearActiveBatch() {
|
|
@@ -248,6 +246,16 @@ class SessionState {
|
|
|
248
246
|
this.core.checkIfIdle()
|
|
249
247
|
}
|
|
250
248
|
|
|
249
|
+
_flushHooks() {
|
|
250
|
+
if (!this.groupUpdated) return
|
|
251
|
+
this.groupUpdated = false
|
|
252
|
+
this.core.ongroupupdate(this.core.header.group.key, {
|
|
253
|
+
key: this.core.key,
|
|
254
|
+
length: this.length,
|
|
255
|
+
fork: this.fork
|
|
256
|
+
})
|
|
257
|
+
}
|
|
258
|
+
|
|
251
259
|
async flush() {
|
|
252
260
|
const tx = this._activeTx
|
|
253
261
|
this._activeTx = null
|
|
@@ -311,9 +319,10 @@ class SessionState {
|
|
|
311
319
|
}
|
|
312
320
|
|
|
313
321
|
if (this.isDefault() && this.core.header.group) {
|
|
314
|
-
const tx =
|
|
322
|
+
const tx = this.createWriteBatch()
|
|
315
323
|
this.updateGroupIndex(tx, tree)
|
|
316
|
-
await
|
|
324
|
+
await this.flush()
|
|
325
|
+
this._flushHooks()
|
|
317
326
|
}
|
|
318
327
|
|
|
319
328
|
if (dependency) this.storage.setDependencyHead(dependency)
|
|
@@ -751,6 +760,8 @@ class SessionState {
|
|
|
751
760
|
for (let i = this.sessions.length - 1; i >= 0; i--) {
|
|
752
761
|
this.sessions[i].emit('append')
|
|
753
762
|
}
|
|
763
|
+
|
|
764
|
+
this._flushHooks()
|
|
754
765
|
}
|
|
755
766
|
|
|
756
767
|
ontruncate(tree, to, from, flushed) {
|
|
@@ -774,6 +785,8 @@ class SessionState {
|
|
|
774
785
|
for (let i = this.sessions.length - 1; i >= 0; i--) {
|
|
775
786
|
this.sessions[i].emit('truncate', to, tree.fork)
|
|
776
787
|
}
|
|
788
|
+
|
|
789
|
+
this._flushHooks()
|
|
777
790
|
}
|
|
778
791
|
|
|
779
792
|
_updateBitfield(bitfield, flushed) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hypercore",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.34.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.
|
|
57
|
+
"hypercore-storage": "^3.2.0",
|
|
58
58
|
"is-options": "^1.0.1",
|
|
59
59
|
"nanoassert": "^2.0.0",
|
|
60
60
|
"protomux": "^3.5.0",
|