hypercore 11.39.4 → 11.39.6
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 +12 -1
- package/lib/session-state.js +6 -4
- package/package.json +1 -1
package/lib/replicator.js
CHANGED
|
@@ -1411,6 +1411,12 @@ class Peer {
|
|
|
1411
1411
|
const has = drop === false
|
|
1412
1412
|
|
|
1413
1413
|
if (drop === true && start < this._remoteContiguousLength) {
|
|
1414
|
+
const end = start + length
|
|
1415
|
+
if (end < this._remoteContiguousLength) {
|
|
1416
|
+
this.remoteBitfield.setRange(end, this._remoteContiguousLength, true)
|
|
1417
|
+
this.missingBlocks.setRange(end, this._remoteContiguousLength, true)
|
|
1418
|
+
this._clearLocalRange(end, this._remoteContiguousLength - end)
|
|
1419
|
+
}
|
|
1414
1420
|
this._remoteContiguousLength = start
|
|
1415
1421
|
}
|
|
1416
1422
|
|
|
@@ -3040,7 +3046,11 @@ module.exports = class Replicator {
|
|
|
3040
3046
|
const blks = new RandomIterator(this._queued)
|
|
3041
3047
|
|
|
3042
3048
|
for (const b of blks) {
|
|
3043
|
-
if (b.queued === false
|
|
3049
|
+
if (b.queued === false) {
|
|
3050
|
+
blks.dequeue()
|
|
3051
|
+
continue
|
|
3052
|
+
}
|
|
3053
|
+
if (peer._requestBlock(b) === true) {
|
|
3044
3054
|
b.queued = false
|
|
3045
3055
|
blks.dequeue()
|
|
3046
3056
|
return true
|
|
@@ -3163,6 +3173,7 @@ module.exports = class Replicator {
|
|
|
3163
3173
|
|
|
3164
3174
|
attachTo(protomux) {
|
|
3165
3175
|
if (this.destroyed) return
|
|
3176
|
+
if (protomux.stream.destroying) return
|
|
3166
3177
|
|
|
3167
3178
|
const makePeer = this._makePeer.bind(this, protomux)
|
|
3168
3179
|
|
package/lib/session-state.js
CHANGED
|
@@ -153,8 +153,9 @@ class SessionState {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
async _updateSnapshotStorage(storage) {
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
const atom = this.atomized
|
|
157
|
+
if (!atom || !atom.flushing) return this.treeInfo()
|
|
158
|
+
while (atom.flushing) await atom.flushed()
|
|
158
159
|
|
|
159
160
|
let rx = storage.read()
|
|
160
161
|
const headPromise = rx.getHead()
|
|
@@ -597,11 +598,12 @@ class SessionState {
|
|
|
597
598
|
const [left, right] = flat.spans(b)
|
|
598
599
|
const s = left / 2
|
|
599
600
|
const e = right / 2 + 1
|
|
600
|
-
const has =
|
|
601
|
+
const has = start <= s && e <= end ? false : this.core.bitfield.hasSet(s, e - s)
|
|
601
602
|
if (has) break
|
|
602
603
|
|
|
603
604
|
tx.deleteTreeNode(a)
|
|
604
|
-
|
|
605
|
+
// delete the whole sibling subtree as it isnt needed per `has` check
|
|
606
|
+
tx.deleteTreeNodeRange(left, right + 1)
|
|
605
607
|
}
|
|
606
608
|
|
|
607
609
|
if (this.isDefault()) {
|