Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh committed Nov 6, 2023
1 parent 71a4730 commit 6cea82a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,22 @@ class TreeNode {
}

preload () {
const core = this.block.tree.core
if (this.block === null) return

const core = getBackingCore(this.block.tree.core)
const bitfield = core.core.bitfield

const missing = []
for (let i = 0; i < this.keys.length; i++) {
const k = this.keys[i]
if (k.value) continue
if (core.bitfield.get(k.seq)) continue
if (k.seq >= core.length || bitfield.get(k.seq)) continue
missing.push(k.seq)
}
for (let i = 0; i < this.children.length; i++) {
const c = this.children[i]
if (c.value) continue
if (core.bitfield.get(c.seq)) continue
if (c.seq >= core.length || bitfield.get(c.seq)) continue
missing.push(c.seq)
}

Expand Down Expand Up @@ -1437,6 +1441,12 @@ function defaultDiffer (currentSnap, previousSnap, opts) {
return currentSnap.createDiffStream(previousSnap, opts)
}

function getBackingCore (core) {
if (core._source) return core._source.originalCore
if (core.flush) return core.session
return core
}

function noop () {}

module.exports = Hyperbee

0 comments on commit 6cea82a

Please sign in to comment.