hypercore 11.0.27 → 11.0.29

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
@@ -80,7 +80,7 @@ class Hypercore extends EventEmitter {
80
80
  this._preappend = preappend.bind(this)
81
81
  this._snapshot = null
82
82
  this._findingPeers = 0
83
- this._active = opts.active !== false
83
+ this._active = opts.weak ? !!opts.active : opts.active !== false
84
84
 
85
85
  this._sessionIndex = -1
86
86
  this._stateIndex = -1 // maintained by session state
@@ -833,7 +833,7 @@ module.exports = class SessionState {
833
833
  return { tree, flushed }
834
834
  }
835
835
 
836
- async commit (state, { signature, keyPair, length = state.length, treeLength = state.flushedLength(), overwrite = false } = {}) {
836
+ async commit (state, { signature, keyPair, length = state.length, treeLength = -1, overwrite = false } = {}) {
837
837
  assert(this.isDefault() || (this.parent && this.parent.isDefault()), 'Can only commit into default state')
838
838
 
839
839
  let srcLocked = false
@@ -843,6 +843,8 @@ module.exports = class SessionState {
843
843
  await state.mutex.lock()
844
844
  srcLocked = true
845
845
 
846
+ if (treeLength === -1) treeLength = state.flushedLength()
847
+
846
848
  if (!(await this.core._validateCommit(state, treeLength))) return null
847
849
  if (this.length > length) return null
848
850
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.0.27",
3
+ "version": "11.0.29",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {