hypercore 10.0.0-alpha.36 → 10.0.0-alpha.37
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/merkle-tree.js +2 -4
- package/lib/replicator.js +3 -3
- package/package.json +1 -1
package/lib/merkle-tree.js
CHANGED
|
@@ -228,6 +228,7 @@ class ReorgBatch extends MerkleTreeBatch {
|
|
|
228
228
|
|
|
229
229
|
let diff = null
|
|
230
230
|
const ite = flat.iterator(this.diff.index)
|
|
231
|
+
const startingDiff = this.diff
|
|
231
232
|
|
|
232
233
|
while ((ite.index & 1) !== 0) {
|
|
233
234
|
const left = n.get(ite.leftChild())
|
|
@@ -243,6 +244,7 @@ class ReorgBatch extends MerkleTreeBatch {
|
|
|
243
244
|
|
|
244
245
|
if ((this.diff.index & 1) === 0) return true
|
|
245
246
|
if (diff === null) return false
|
|
247
|
+
if (startingDiff !== this.diff) return false
|
|
246
248
|
|
|
247
249
|
return this._updateDiffRoot(diff)
|
|
248
250
|
}
|
|
@@ -255,10 +257,6 @@ class ReorgBatch extends MerkleTreeBatch {
|
|
|
255
257
|
const end = Math.min(this.treeLength, spans[1] / 2 + 1)
|
|
256
258
|
const len = end - start
|
|
257
259
|
|
|
258
|
-
if (this.diff !== null && len >= this.want.end - this.want.start) {
|
|
259
|
-
return false
|
|
260
|
-
}
|
|
261
|
-
|
|
262
260
|
this.ancestors = start
|
|
263
261
|
this.diff = diff
|
|
264
262
|
|
package/lib/replicator.js
CHANGED
|
@@ -717,7 +717,7 @@ class Peer {
|
|
|
717
717
|
}
|
|
718
718
|
|
|
719
719
|
_requestBlock (b) {
|
|
720
|
-
if (this.remoteBitfield.get(b.index) === false) return false
|
|
720
|
+
if (this.remoteBitfield.get(b.index) === false || b.fork !== this.remoteFork) return false
|
|
721
721
|
|
|
722
722
|
const req = this._makeRequest(b.fork, b.index >= this.core.tree.length)
|
|
723
723
|
if (req === null) return false
|
|
@@ -1286,14 +1286,14 @@ module.exports = class Replicator {
|
|
|
1286
1286
|
|
|
1287
1287
|
if (f.batch) {
|
|
1288
1288
|
await f.batch.update(data)
|
|
1289
|
-
} else {
|
|
1289
|
+
} else if (data.upgrade) {
|
|
1290
1290
|
f.batch = await this.core.tree.reorg(data)
|
|
1291
1291
|
|
|
1292
1292
|
// Remove "older" reorgs in progress as we just verified this one.
|
|
1293
1293
|
this._clearOldReorgs(f.fork)
|
|
1294
1294
|
}
|
|
1295
1295
|
|
|
1296
|
-
if (f.batch.finished) {
|
|
1296
|
+
if (f.batch && f.batch.finished) {
|
|
1297
1297
|
if (this._addUpgradeMaybe() !== null) {
|
|
1298
1298
|
await this._applyReorg(f)
|
|
1299
1299
|
}
|