hyperbee2 2.4.2 → 2.4.3

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
@@ -367,9 +367,10 @@ async function inflateKeyCohort(context, d, ptr, block, config) {
367
367
  return new DeltaCohort(false, p, await Promise.all(promises))
368
368
  }
369
369
 
370
- function inflateChild(context, d, ptr, block, config) {
370
+ async function inflateChild(context, d, ptr, block, config) {
371
371
  if (d.type === OP_COHORT) return inflateChildCohort(context, d, ptr, block, config)
372
- return Promise.resolve(inflateChildDelta(context, d, ptr, block, config))
372
+ if (d.pointer && !context.hasCore(d.pointer.core)) await context.update(config)
373
+ return inflateChildDelta(context, d, ptr, block, config)
373
374
  }
374
375
 
375
376
  function inflateChildDelta(context, d, ptr, block, config) {
@@ -391,6 +392,7 @@ async function inflateChildCohort(context, d, ptr, block, config) {
391
392
 
392
393
  for (let i = 0; i < cohort.length; i++) {
393
394
  const c = cohort[i]
395
+ if (c.pointer && !context.hasCore(c.pointer.core)) await context.update(config)
394
396
  deltas[i] = inflateChildDelta(context, c, co, blk, config)
395
397
  }
396
398
 
package/lib/cache.js CHANGED
@@ -88,6 +88,6 @@ module.exports = class NodeCache {
88
88
  }
89
89
 
90
90
  function cacheId(node) {
91
- const id = node.core === 0 ? node.context.core.id : node.context.opened[node.core - 1].id
91
+ const id = node.context.getCore(node.core).id
92
92
  return id + '@' + node.seq + '.' + node.offset
93
93
  }
package/lib/context.js CHANGED
@@ -41,6 +41,10 @@ class CoreContext {
41
41
  await this._inflateCheckpoint(length, block, config)
42
42
  }
43
43
 
44
+ hasCore(core) {
45
+ return core <= this.opened.length
46
+ }
47
+
44
48
  async _inflateCheckpoint(length, block, config) {
45
49
  const checkpoint = block.checkpoint
46
50
 
@@ -149,11 +153,6 @@ class CoreContext {
149
153
  const buffer = await hc.get(seq, config)
150
154
  if (buffer === null) throw BLOCK_NOT_AVAILABLE()
151
155
  const block = decodeBlock(buffer, seq)
152
-
153
- if (block.checkpoint > this.checkpoint) {
154
- await this._inflateCheckpoint(seq + 1, block, config)
155
- }
156
-
157
156
  return block
158
157
  }
159
158
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperbee2",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "description": "btree",
5
5
  "main": "index.js",
6
6
  "files": [