hypercore 11.33.3 → 11.33.5
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 +1 -1
- package/lib/session-state.js +20 -7
- package/package.json +1 -1
package/lib/replicator.js
CHANGED
|
@@ -2271,7 +2271,7 @@ module.exports = class Replicator {
|
|
|
2271
2271
|
|
|
2272
2272
|
static clearRequests(session, err) {
|
|
2273
2273
|
if (session.length === 0) return
|
|
2274
|
-
if (session.length
|
|
2274
|
+
if (session.length === 1 && session[0] === null) return
|
|
2275
2275
|
|
|
2276
2276
|
const updated = new Set()
|
|
2277
2277
|
|
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) {
|