hypercore 11.21.2 → 11.21.4
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 +8 -10
- package/package.json +1 -1
package/lib/replicator.js
CHANGED
|
@@ -461,7 +461,7 @@ class Peer {
|
|
|
461
461
|
this.remoteBitfield = new RemoteBitfield()
|
|
462
462
|
this.missingBlocks = new RemoteBitfield()
|
|
463
463
|
|
|
464
|
-
this.
|
|
464
|
+
this.pushedLength = 0
|
|
465
465
|
|
|
466
466
|
this.remoteFork = 0
|
|
467
467
|
this.remoteLength = 0
|
|
@@ -909,15 +909,17 @@ class Peer {
|
|
|
909
909
|
priority: 0
|
|
910
910
|
}
|
|
911
911
|
|
|
912
|
+
const remoteLength = Math.max(this.remoteLength, this.pushedLength)
|
|
913
|
+
|
|
912
914
|
msg.block = {
|
|
913
915
|
index,
|
|
914
|
-
nodes: MerkleTree.maxMissingNodes(2 * index,
|
|
916
|
+
nodes: MerkleTree.maxMissingNodes(2 * index, remoteLength)
|
|
915
917
|
}
|
|
916
918
|
|
|
917
919
|
if (index >= this.remoteLength) {
|
|
918
920
|
msg.upgrade = {
|
|
919
|
-
start:
|
|
920
|
-
length: this.core.state.length -
|
|
921
|
+
start: remoteLength,
|
|
922
|
+
length: this.core.state.length - remoteLength
|
|
921
923
|
}
|
|
922
924
|
}
|
|
923
925
|
|
|
@@ -998,13 +1000,9 @@ class Peer {
|
|
|
998
1000
|
this.replicator._onupload(proof.block.index, proof.block.value.byteLength, this)
|
|
999
1001
|
}
|
|
1000
1002
|
|
|
1001
|
-
|
|
1002
|
-
// to produce better push upgrade proofs as we can better predict what length the remote
|
|
1003
|
-
// is going to be at.
|
|
1004
|
-
if ((pushing || this.pushing) && proof.upgrade) {
|
|
1005
|
-
this.pushing = true
|
|
1003
|
+
if (proof.upgrade) {
|
|
1006
1004
|
const remoteLength = proof.upgrade.start + proof.upgrade.length
|
|
1007
|
-
if (remoteLength > this.
|
|
1005
|
+
if (remoteLength > this.pushedLength) this.pushedLength = remoteLength
|
|
1008
1006
|
}
|
|
1009
1007
|
|
|
1010
1008
|
this.wireData.send({
|