hypercore 10.28.9 → 10.28.11

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 CHANGED
@@ -919,12 +919,21 @@ async function flushHeader (oplog, bigHeader, header) {
919
919
  function noop () {}
920
920
 
921
921
  function maximumSegmentStart (start, src, dst) {
922
- const a = src.firstSet(start)
923
- const b = dst.firstUnset(start)
922
+ while (true) {
923
+ const a = src.firstSet(start)
924
+ const b = dst.firstUnset(start)
924
925
 
925
- if (a === -1) return -1
926
- if (b === -1) return a
927
- return a < b ? b : a
926
+ if (a === -1) return -1
927
+ if (b === -1) return a
928
+
929
+ // if dst has the segment, restart
930
+ if (a < b) {
931
+ start = b
932
+ continue
933
+ }
934
+
935
+ return a
936
+ }
928
937
  }
929
938
 
930
939
  function minimumSegmentEnd (start, src, dst) {
package/lib/replicator.js CHANGED
@@ -821,7 +821,7 @@ class Peer {
821
821
  // We need an upgrade for the seek, if non can be provided, skip
822
822
  if (req === null) return false
823
823
 
824
- req.seek = { bytes: s.seeker.bytes }
824
+ req.seek = { bytes: s.seeker.padding * s.seeker.start + s.seeker.bytes }
825
825
 
826
826
  s.inflight.push(req)
827
827
  this._send(req)
@@ -851,7 +851,7 @@ class Peer {
851
851
  const req = this._makeRequest(false, h.priority)
852
852
 
853
853
  req.hash = { index: 2 * index, nodes: 0 }
854
- req.seek = { bytes: s.seeker.bytes }
854
+ req.seek = { bytes: s.seeker.padding * s.seeker.start + s.seeker.bytes }
855
855
 
856
856
  s.inflight.push(req)
857
857
  h.inflight.push(req)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.28.9",
3
+ "version": "10.28.11",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {