hypercore 10.38.0 → 10.38.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
@@ -559,6 +559,10 @@ module.exports = class Hypercore extends EventEmitter {
559
559
  return this.core.tree.length
560
560
  }
561
561
 
562
+ get signedLength () {
563
+ return this.length
564
+ }
565
+
562
566
  get indexedLength () {
563
567
  return this.length
564
568
  }
package/lib/audit.js CHANGED
@@ -3,6 +3,8 @@ const flat = require('flat-tree')
3
3
  const c = require('compact-encoding')
4
4
  const b4a = require('b4a')
5
5
 
6
+ const empty = b4a.alloc(32)
7
+
6
8
  // this is optimised for speed over mem atm
7
9
  // can be tweaked in the future
8
10
 
@@ -33,6 +35,8 @@ module.exports = async function auditCore (core) {
33
35
  const leftNode = getNode(left)
34
36
  const rightNode = getNode(right)
35
37
 
38
+ if (!rightNode && !leftNode) continue
39
+
36
40
  stack.push(leftNode, rightNode)
37
41
 
38
42
  if (valid[node.index]) {
@@ -93,9 +97,11 @@ module.exports = async function auditCore (core) {
93
97
  return corrections
94
98
 
95
99
  function getNode (index) {
100
+ if (index * 40 + 40 > tree.byteLength) return null
96
101
  const state = { start: index * 40, end: index * 40 + 40, buffer: tree }
97
102
  const size = c.uint64.decode(state)
98
103
  const hash = c.fixed32.decode(state)
104
+ if (size === 0 && hash.equals(empty)) return null
99
105
  return { index, size, hash }
100
106
  }
101
107
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.38.0",
3
+ "version": "10.38.2",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {