hypercore 10.37.17 → 10.37.18

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 +14 -3
  2. package/package.json +1 -1
package/lib/replicator.js CHANGED
@@ -972,8 +972,8 @@ class Peer {
972
972
  this._remoteContiguousLength = start
973
973
  }
974
974
 
975
- if (start === 0 && drop === false && length > this._remoteContiguousLength) {
976
- this._remoteContiguousLength = length
975
+ if (start === 0 && drop === false) {
976
+ if (length > this._remoteContiguousLength) this._remoteContiguousLength = length
977
977
  } else if (length === 1) {
978
978
  const bitfield = this.core.skipBitfield === null ? this.core.bitfield : this.core.skipBitfield
979
979
  this.remoteBitfield.set(start, has)
@@ -1095,7 +1095,7 @@ class Peer {
1095
1095
  let index = off + i
1096
1096
  if (index > s.seeker.end) index -= len
1097
1097
 
1098
- if (this.remoteBitfield.get(index) === false) continue
1098
+ if (this._remoteHasBlock(index) === false) continue
1099
1099
  if (this.core.bitfield.get(index) === true) continue
1100
1100
  if (!this._hasTreeParent(index)) continue
1101
1101
 
@@ -1997,6 +1997,17 @@ module.exports = class Replicator {
1997
1997
  }
1998
1998
 
1999
1999
  _onwant (peer, start, length) {
2000
+ const contig = Math.min(this.core.tree.length, this.core.header.hints.contiguousLength)
2001
+
2002
+ if (start + length < contig || (this.core.tree.length === contig)) {
2003
+ peer.wireRange.send({
2004
+ drop: false,
2005
+ start: 0,
2006
+ length: contig
2007
+ })
2008
+ return
2009
+ }
2010
+
2000
2011
  length = Math.min(length, this.core.tree.length - start)
2001
2012
 
2002
2013
  peer.protomux.cork()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.37.17",
3
+ "version": "10.37.18",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {