hypercore 11.31.0 → 11.33.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/core.js +1 -0
- package/lib/replicator.js +7 -31
- package/lib/session-state.js +5 -2
- package/package.json +1 -1
package/lib/core.js
CHANGED
package/lib/replicator.js
CHANGED
|
@@ -233,13 +233,12 @@ class RangeBatchRequest extends Attachable {
|
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
class RangeRequest extends Attachable {
|
|
236
|
-
constructor(replicator, ranges, start, end, linear,
|
|
236
|
+
constructor(replicator, ranges, start, end, linear, blocks) {
|
|
237
237
|
super(replicator)
|
|
238
238
|
|
|
239
239
|
this.start = start
|
|
240
240
|
this.end = end
|
|
241
241
|
this.linear = linear
|
|
242
|
-
this.ifAvailable = ifAvailable
|
|
243
242
|
this.blocks = blocks
|
|
244
243
|
this.ranges = ranges
|
|
245
244
|
this.batches = []
|
|
@@ -2230,14 +2229,7 @@ module.exports = class Replicator {
|
|
|
2230
2229
|
|
|
2231
2230
|
addRange(
|
|
2232
2231
|
session,
|
|
2233
|
-
{
|
|
2234
|
-
start = 0,
|
|
2235
|
-
end = -1,
|
|
2236
|
-
length = toLength(start, end),
|
|
2237
|
-
blocks = null,
|
|
2238
|
-
linear = false,
|
|
2239
|
-
ifAvailable = false
|
|
2240
|
-
} = {}
|
|
2232
|
+
{ start = 0, end = -1, length = toLength(start, end), blocks = null, linear = false } = {}
|
|
2241
2233
|
) {
|
|
2242
2234
|
if (blocks !== null) {
|
|
2243
2235
|
// if using blocks, start, end just acts as frames around the blocks array
|
|
@@ -2251,7 +2243,6 @@ module.exports = class Replicator {
|
|
|
2251
2243
|
start,
|
|
2252
2244
|
length === -1 ? -1 : start + length,
|
|
2253
2245
|
linear,
|
|
2254
|
-
ifAvailable,
|
|
2255
2246
|
blocks
|
|
2256
2247
|
)
|
|
2257
2248
|
|
|
@@ -2460,7 +2451,11 @@ module.exports = class Replicator {
|
|
|
2460
2451
|
}
|
|
2461
2452
|
|
|
2462
2453
|
this._onpeerupdate(false, peer)
|
|
2463
|
-
if (inflight)
|
|
2454
|
+
if (inflight) {
|
|
2455
|
+
this.updateAll()
|
|
2456
|
+
} else {
|
|
2457
|
+
this._checkUpgradeIfAvailable()
|
|
2458
|
+
}
|
|
2464
2459
|
}
|
|
2465
2460
|
|
|
2466
2461
|
_queueBlock(b) {
|
|
@@ -2653,23 +2648,6 @@ module.exports = class Replicator {
|
|
|
2653
2648
|
if (this._inflight.idle || updateAll) this.updateAll()
|
|
2654
2649
|
}
|
|
2655
2650
|
|
|
2656
|
-
_maybeResolveIfAvailableRanges() {
|
|
2657
|
-
if (this._ifAvailable > 0 || !this._inflight.idle || !this._ranges.length) return
|
|
2658
|
-
|
|
2659
|
-
for (let i = 0; i < this.peers.length; i++) {
|
|
2660
|
-
if (this.peers[i].dataProcessing > 0) return
|
|
2661
|
-
}
|
|
2662
|
-
|
|
2663
|
-
for (let i = 0; i < this._ranges.length; i++) {
|
|
2664
|
-
const r = this._ranges[i]
|
|
2665
|
-
|
|
2666
|
-
if (r.ifAvailable) {
|
|
2667
|
-
this._resolveRangeRequest(r)
|
|
2668
|
-
i--
|
|
2669
|
-
}
|
|
2670
|
-
}
|
|
2671
|
-
}
|
|
2672
|
-
|
|
2673
2651
|
_clearRequest(peer, req) {
|
|
2674
2652
|
if (req.block !== null) {
|
|
2675
2653
|
this._clearInflightBlock(this._blocks, req)
|
|
@@ -3020,7 +2998,6 @@ module.exports = class Replicator {
|
|
|
3020
2998
|
}
|
|
3021
2999
|
|
|
3022
3000
|
this._checkUpgradeIfAvailable()
|
|
3023
|
-
this._maybeResolveIfAvailableRanges()
|
|
3024
3001
|
}
|
|
3025
3002
|
|
|
3026
3003
|
updateAll() {
|
|
@@ -3048,7 +3025,6 @@ module.exports = class Replicator {
|
|
|
3048
3025
|
}
|
|
3049
3026
|
|
|
3050
3027
|
this._checkUpgradeIfAvailable()
|
|
3051
|
-
this._maybeResolveIfAvailableRanges()
|
|
3052
3028
|
}
|
|
3053
3029
|
|
|
3054
3030
|
onpeerdestroy() {
|
package/lib/session-state.js
CHANGED
|
@@ -224,6 +224,11 @@ class SessionState {
|
|
|
224
224
|
|
|
225
225
|
tx.deleteGroupUpdate(pointer, this.core.header.tree.timestamp)
|
|
226
226
|
tx.putGroupUpdate(pointer, tree.timestamp, this.core.header.key)
|
|
227
|
+
this.core.ongroupupdate(this.core.header.group.key, {
|
|
228
|
+
key: this.core.key,
|
|
229
|
+
length: tree.length,
|
|
230
|
+
fork: tree.fork
|
|
231
|
+
})
|
|
227
232
|
}
|
|
228
233
|
|
|
229
234
|
_clearActiveBatch() {
|
|
@@ -306,8 +311,6 @@ class SessionState {
|
|
|
306
311
|
}
|
|
307
312
|
|
|
308
313
|
if (this.isDefault() && this.core.header.group) {
|
|
309
|
-
const { pointer } = this.core.header.group
|
|
310
|
-
|
|
311
314
|
const tx = await this.createWriteBatch()
|
|
312
315
|
this.updateGroupIndex(tx, tree)
|
|
313
316
|
await tx.flush()
|