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.
Files changed (2) hide show
  1. package/lib/replicator.js +8 -10
  2. 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.pushing = false
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, this.remoteLength)
916
+ nodes: MerkleTree.maxMissingNodes(2 * index, remoteLength)
915
917
  }
916
918
 
917
919
  if (index >= this.remoteLength) {
918
920
  msg.upgrade = {
919
- start: this.remoteLength,
920
- length: this.core.state.length - this.remoteLength
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
- // TODO: we should prob move to a sep length prop for this. This is just quick and dirty
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.remoteLength) this.remoteLength = remoteLength
1005
+ if (remoteLength > this.pushedLength) this.pushedLength = remoteLength
1008
1006
  }
1009
1007
 
1010
1008
  this.wireData.send({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.21.2",
3
+ "version": "11.21.4",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {