@fireproof/core 0.5.8 → 0.5.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireproof/core",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "description": "Cloudless database for apps, the browser, and IPFS",
5
5
  "main": "dist/src/fireproof.js",
6
6
  "module": "dist/src/fireproof.mjs",
package/src/fireproof.js CHANGED
@@ -24,7 +24,7 @@ export class Fireproof {
24
24
  if (existing) {
25
25
  const existingConfig = JSON.parse(existing)
26
26
  const fp = new Database(new TransactionBlockstore(name, existingConfig.key), [], opts)
27
- return this.fromJSON(existingConfig, fp)
27
+ return Fireproof.fromJSON(existingConfig, fp)
28
28
  } else {
29
29
  const instanceKey = randomBytes(32).toString('hex') // pass null to disable encryption
30
30
  return new Database(new TransactionBlockstore(name, instanceKey), [], opts)
@@ -67,7 +67,7 @@ export class Fireproof {
67
67
  index.clock.db = null
68
68
  })
69
69
  }
70
- const snappedDb = this.fromJSON(definition, withBlocks)
70
+ const snappedDb = Fireproof.fromJSON(definition, withBlocks)
71
71
  ;[...database.indexes.values()].forEach(index => {
72
72
  snappedDb.indexes.get(index.mapFnString).mapFn = index.mapFn
73
73
  })
package/src/sync.js CHANGED
@@ -97,6 +97,10 @@ export class Sync {
97
97
  // get the roots parents
98
98
  const parents = await Promise.all(roots.map(async (cid) => {
99
99
  const rbl = await reader.get(cid)
100
+ if (!rbl) {
101
+ console.log('missing root block', cid.toString(), reader)
102
+ throw new Error('missing root block')
103
+ }
100
104
  const block = await decodeEventBlock(rbl.bytes)
101
105
  return block.value.parents
102
106
  }))
@@ -113,7 +117,7 @@ export class Sync {
113
117
  } else if (message.clock) {
114
118
  const reqCidDiff = message
115
119
  // this might be a CID diff
116
- // console.log('got diff', reqCidDiff)
120
+ console.log('got diff', reqCidDiff)
117
121
  const carBlock = await Sync.makeCar(this.database, null, reqCidDiff.cids)
118
122
  if (!carBlock) {
119
123
  // we are full synced