hypercore 11.35.3 → 11.35.5

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 (3) hide show
  1. package/index.js +4 -0
  2. package/lib/core.js +10 -0
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -376,6 +376,10 @@ class Hypercore extends EventEmitter {
376
376
  async _openSession(opts) {
377
377
  if (this.core.opened === false) await this.core.ready()
378
378
 
379
+ if (opts.group && !this.core.header.group) {
380
+ await this.core.setGroup(opts.group)
381
+ }
382
+
379
383
  if (this.keyPair === null) this.keyPair = opts.keyPair || this.core.header.keyPair
380
384
 
381
385
  const parent = opts.parent || null
package/lib/core.js CHANGED
@@ -154,6 +154,12 @@ module.exports = class Core {
154
154
  }
155
155
 
156
156
  this.opened = true
157
+
158
+ // always make sure we get an initial update
159
+ if (this.state.length === 0 && !isWritableHeader(this.header)) {
160
+ this.replicator.setDownloading(true)
161
+ this.replicator.setDownloading(false)
162
+ }
157
163
  }
158
164
 
159
165
  async _tryOpen(opts) {
@@ -1034,6 +1040,10 @@ async function maybeGetRootsFromStorage(storage, length) {
1034
1040
  }
1035
1041
  }
1036
1042
 
1043
+ function isWritableHeader(header) {
1044
+ return !!(header && header.keyPair && header.keyPair.secretKey)
1045
+ }
1046
+
1037
1047
  function noop() {}
1038
1048
 
1039
1049
  async function getCoreInfo(storage) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.35.3",
3
+ "version": "11.35.5",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {