hypercore 11.21.5 → 11.21.7

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/README.md CHANGED
@@ -66,7 +66,7 @@ Alternatively you can pass a [Hypercore Storage](https://github.com/holepunchto/
66
66
  }
67
67
  ```
68
68
 
69
- You can also set `valueEncoding` to any [compact-encoding](https://github.com/compact-encoding) instance.
69
+ You can also set `valueEncoding` to any [compact-encoding](https://github.com/holepunchto/compact-encoding) instance.
70
70
 
71
71
  `valueEncoding`s will be applied to individual blocks, even if you append batches. If you want to control encoding at the batch-level, you can use the `encodeBatch` option, which is a function that takes a batch and returns a binary-encoded batch. If you provide a custom `valueEncoding`, it will not be applied prior to `encodeBatch`.
72
72
 
@@ -169,7 +169,7 @@ Check if the core has all blocks between `start` and `end`.
169
169
 
170
170
  #### `const updated = await core.update([options])`
171
171
 
172
- Waits for initial proof of the new core length until all `findingPeers` calls has finished.
172
+ Waits for initial proof of the new core length until all `findingPeers` calls have finished.
173
173
 
174
174
  ```js
175
175
  const updated = await core.update()
@@ -414,7 +414,7 @@ Register a custom protocol extension. This is a legacy implementation and is no
414
414
  ```
415
415
  {
416
416
  encoding: 'json' | 'utf-8' | 'binary', // Compact encoding to use for messages. Defaults to buffer
417
- onmessage: (message, peer) => { ... } // Callback for when a message for the extension is receive
417
+ onmessage: (message, peer) => { ... } // Callback for when a message for the extension is received
418
418
  }
419
419
  ```
420
420
 
@@ -438,7 +438,7 @@ You must close any session you make.
438
438
 
439
439
  Options are inherited from the parent instance, unless they are re-set.
440
440
 
441
- `options` are the same as in the constructor with the follow additions:
441
+ `options` are the same as in the constructor with the following additions:
442
442
 
443
443
  ```
444
444
  {
@@ -588,7 +588,7 @@ Populated after `ready` has been emitted. Will be `0` before the event.
588
588
 
589
589
  #### `core.signedLength`
590
590
 
591
- How many blocks of data are available on this core that have been signed by a quorum. This is equal to `core.length` for Hypercores's with a single signer.
591
+ How many blocks of data are available on this core that have been signed by a quorum. This is equal to `core.length` for Hypercores with a single signer.
592
592
 
593
593
  Populated after `ready` has been emitted. Will be `0` before the event.
594
594
 
@@ -730,9 +730,9 @@ Returns the key for a given manifest.
730
730
 
731
731
  ```
732
732
  {
733
- compat: false, // Whether the manifest has a single singer whose public key is the key
734
- version, // Manifest version if the manifest argument is the public key of a single singer
735
- namespace // The signer namespace if the manifest argument is the public key of a single singer
733
+ compat: false, // Whether the manifest has a single signer whose public key is the key
734
+ version, // Manifest version if the manifest argument is the public key of a single signer
735
+ namespace // The signer namespace if the manifest argument is the public key of a single signer
736
736
  }
737
737
  ```
738
738
 
package/lib/replicator.js CHANGED
@@ -401,7 +401,7 @@ class Peer {
401
401
  this.remoteSupportsSeeks = false
402
402
  this.inflightRange = inflightRange
403
403
  this.remoteSegmentsWanted = new Set()
404
- this.fullyDownloadedSignaled = false
404
+ this.fullyDownloadedSignaled = 0
405
405
 
406
406
  this.paused = false
407
407
  this.removed = false
@@ -511,9 +511,6 @@ class Peer {
511
511
  }
512
512
 
513
513
  signalUpgrade() {
514
- if (this.fullyDownloadedSignaled && !this.replicator.fullyDownloaded()) {
515
- this.fullyDownloadedSignaled = false
516
- }
517
514
  if (this._shouldUpdateCanUpgrade() === true) this._updateCanUpgradeAndSync()
518
515
  else this.sendSync()
519
516
  }
@@ -546,8 +543,8 @@ class Peer {
546
543
  length = this.core.state.length
547
544
 
548
545
  // Always send the broadcast when we switch from sparse to fully contiguous, so remote knows too
549
- if (!this.fullyDownloadedSignaled) {
550
- this.fullyDownloadedSignaled = true
546
+ if (this.fullyDownloadedSignaled < length) {
547
+ this.fullyDownloadedSignaled = length
551
548
  force = true
552
549
  }
553
550
  }
@@ -896,6 +893,7 @@ class Peer {
896
893
 
897
894
  async push(index) {
898
895
  if (!this.remoteAllowPush) return
896
+ if (!this.remoteDownloading) return
899
897
  if (this.core.state.fork !== this.remoteFork) return
900
898
  if (this.remoteBitfield.get(index)) return
901
899
 
@@ -1891,7 +1889,10 @@ module.exports = class Replicator {
1891
1889
  }
1892
1890
  }
1893
1891
 
1894
- for (const peer of this.peers) peer._unclearLocalRange(newLength, truncated)
1892
+ for (const peer of this.peers) {
1893
+ peer.fullyDownloadedSignaled = 0
1894
+ peer._unclearLocalRange(newLength, truncated)
1895
+ }
1895
1896
  }
1896
1897
 
1897
1898
  // Called externally when a upgrade has been processed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.21.5",
3
+ "version": "11.21.7",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {