hypercore 11.27.0 → 11.27.2

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/index.js CHANGED
@@ -627,10 +627,19 @@ class Hypercore extends EventEmitter {
627
627
  return this.opened === false ? null : this.core.globalCache
628
628
  }
629
629
 
630
+ get recovering() {
631
+ return this.opened === false ? 0 : this.core.header.hints.recovering
632
+ }
633
+
630
634
  ready() {
631
635
  return this.opening
632
636
  }
633
637
 
638
+ async recover() {
639
+ if (this.opened === false) await this.opening
640
+ return this.state.waitForRecovery()
641
+ }
642
+
634
643
  async setUserData(key, value) {
635
644
  if (this.opened === false) await this.opening
636
645
  const existing = await this.getUserData(key)
package/lib/core.js CHANGED
@@ -966,7 +966,7 @@ function parseHeader(info) {
966
966
  reorgs: [],
967
967
  contiguousLength: info.hints ? info.hints.contiguousLength : 0,
968
968
  remoteContiguousLength: info.hints ? info.hints.remoteContiguousLength : 0,
969
- recovering: info.recovering || 0
969
+ recovering: info.hints ? info.hints.recovering : 0
970
970
  }
971
971
  }
972
972
  }
@@ -569,7 +569,7 @@ module.exports = class SessionState {
569
569
  }
570
570
 
571
571
  // simple tool to wait for other peers to catch us up
572
- async _waitForRecovery() {
572
+ async waitForRecovery() {
573
573
  const length = this.length
574
574
  const replicator = this.core.replicator
575
575
 
@@ -607,7 +607,7 @@ module.exports = class SessionState {
607
607
  async append(values, { signature, keyPair, preappend, postappend, maxLength = -1 } = {}) {
608
608
  if (!keyPair && this.isDefault()) keyPair = this.core.header.keyPair
609
609
 
610
- if (this.isDefault() && this.core.header.hints.recovering) await this._waitForRecovery()
610
+ if (this.isDefault() && this.core.header.hints.recovering) await this.waitForRecovery()
611
611
 
612
612
  await this.mutex.lock()
613
613
 
@@ -965,7 +965,7 @@ module.exports = class SessionState {
965
965
  throw ASSERTION('Cannot commit while repair mode is on')
966
966
  }
967
967
 
968
- if (this.core.header.hints.recovering) await this._waitForRecovery()
968
+ if (this.core.header.hints.recovering) await this.waitForRecovery()
969
969
 
970
970
  let srcLocked = false
971
971
  await this.mutex.lock()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.27.0",
3
+ "version": "11.27.2",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {