@fireproof/core 0.5.14 → 0.5.16
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/dist/src/blockstore.js +3 -3
- package/dist/src/clock.js +1 -1
- package/dist/src/db-index.js +2 -1
- package/dist/src/fireproof.d.ts +1 -1
- package/dist/src/fireproof.js +226 -187
- package/dist/src/fireproof.js.map +1 -1
- package/dist/src/fireproof.mjs +226 -187
- package/dist/src/fireproof.mjs.map +1 -1
- package/dist/src/prolly.js +3 -0
- package/dist/src/sync.js +3 -2
- package/package.json +1 -1
- package/src/blockstore.js +3 -3
- package/src/clock.js +1 -1
- package/src/db-index.js +2 -1
- package/src/prolly.js +3 -0
- package/src/sync.js +3 -2
package/dist/src/prolly.js
CHANGED
@@ -125,6 +125,9 @@ const bulkFromEvents = (sorted, event) => {
|
|
125
125
|
const bulk = new Map();
|
126
126
|
for (const { value: event } of sorted) {
|
127
127
|
const { data: { type, value, key } } = event;
|
128
|
+
if (!key) {
|
129
|
+
throw new Error('key is required');
|
130
|
+
}
|
128
131
|
const bulkEvent = type === 'put' ? { key, value } : { key, del: true };
|
129
132
|
bulk.set(bulkEvent.key, bulkEvent); // last wins
|
130
133
|
}
|
package/dist/src/sync.js
CHANGED
@@ -181,14 +181,15 @@ export class Sync {
|
|
181
181
|
const allCIDs = await database.allCIDs();
|
182
182
|
const blocks = database.blocks;
|
183
183
|
const rootCIDs = database.clock;
|
184
|
-
const
|
184
|
+
const newCIDs = [...new Set([...rootCIDs, ...allCIDs])].filter(cid => !skip.includes(cid.toString()));
|
185
|
+
const syncCIDs = [...new Set([...rootCIDs, ...allCIDs.filter(cid => !skip.includes(cid.toString()))])];
|
185
186
|
// console.log(
|
186
187
|
// 'makeCar',
|
187
188
|
// rootCIDs.map(c => c.toString()),
|
188
189
|
// syncCIDs.map(c => c.toString()),
|
189
190
|
// allCIDs.map(c => c.toString())
|
190
191
|
// )
|
191
|
-
if (
|
192
|
+
if (newCIDs.length === 0) {
|
192
193
|
return null;
|
193
194
|
}
|
194
195
|
if (typeof key === 'undefined') {
|
package/package.json
CHANGED
package/src/blockstore.js
CHANGED
@@ -127,8 +127,8 @@ export class TransactionBlockstore {
|
|
127
127
|
*/
|
128
128
|
async * entries () {
|
129
129
|
for (const transaction of this.inflightTransactions) {
|
130
|
-
for (const [
|
131
|
-
yield { cid:
|
130
|
+
for (const [cid, bytes] of transaction.entries()) { // test for this?
|
131
|
+
yield { cid: cid.toString(), bytes }
|
132
132
|
}
|
133
133
|
}
|
134
134
|
for (const [str, bytes] of this.committedBlocks) {
|
@@ -179,7 +179,7 @@ export class TransactionBlockstore {
|
|
179
179
|
doCommit = async innerBlockstore => {
|
180
180
|
const cids = new Set()
|
181
181
|
for (const { cid, bytes } of innerBlockstore.entries()) {
|
182
|
-
const stringCid = cid.toString()
|
182
|
+
const stringCid = cid.toString()
|
183
183
|
if (this.committedBlocks.has(stringCid)) {
|
184
184
|
// console.log('Duplicate block: ' + stringCid) // todo some of this can be avoided, cost is extra size on car files
|
185
185
|
} else {
|
package/src/clock.js
CHANGED
@@ -242,7 +242,7 @@ export async function findEventsToSync (blocks, head) {
|
|
242
242
|
|
243
243
|
const toSync = ancestor ? await asyncFilter(sorted, async uks => !(await contains(events, ancestor, uks.cid))) : sorted
|
244
244
|
// console.timeEnd(callTag + '.contains')
|
245
|
-
console.log('
|
245
|
+
// console.log('optimize sorted', !!ancestor, sorted.length - toSync.length)
|
246
246
|
|
247
247
|
return { cids: events, events: toSync }
|
248
248
|
}
|
package/src/db-index.js
CHANGED
@@ -144,6 +144,8 @@ export class DbIndex {
|
|
144
144
|
this.mapFn = mapFn
|
145
145
|
this.mapFnString = mapFn.toString()
|
146
146
|
}
|
147
|
+
const matches = /=>\s*(.*)/.exec(this.mapFnString)
|
148
|
+
this.includeDocsDefault = matches && matches.length > 0
|
147
149
|
this.name = name || this.makeName()
|
148
150
|
}
|
149
151
|
|
@@ -157,7 +159,6 @@ export class DbIndex {
|
|
157
159
|
return this.mapFnString
|
158
160
|
} else {
|
159
161
|
// it's a consise arrow function, match everythign after the arrow
|
160
|
-
this.includeDocsDefault = true
|
161
162
|
return matches[1]
|
162
163
|
}
|
163
164
|
}
|
package/src/prolly.js
CHANGED
@@ -143,6 +143,9 @@ const bulkFromEvents = (sorted, event) => {
|
|
143
143
|
const {
|
144
144
|
data: { type, value, key }
|
145
145
|
} = event
|
146
|
+
if (!key) {
|
147
|
+
throw new Error('key is required')
|
148
|
+
}
|
146
149
|
const bulkEvent = type === 'put' ? { key, value } : { key, del: true }
|
147
150
|
bulk.set(bulkEvent.key, bulkEvent) // last wins
|
148
151
|
}
|
package/src/sync.js
CHANGED
@@ -193,14 +193,15 @@ export class Sync {
|
|
193
193
|
const blocks = database.blocks
|
194
194
|
const rootCIDs = database.clock
|
195
195
|
|
196
|
-
const
|
196
|
+
const newCIDs = [...new Set([...rootCIDs, ...allCIDs])].filter(cid => !skip.includes(cid.toString()))
|
197
|
+
const syncCIDs = [...new Set([...rootCIDs, ...allCIDs.filter(cid => !skip.includes(cid.toString()))])]
|
197
198
|
// console.log(
|
198
199
|
// 'makeCar',
|
199
200
|
// rootCIDs.map(c => c.toString()),
|
200
201
|
// syncCIDs.map(c => c.toString()),
|
201
202
|
// allCIDs.map(c => c.toString())
|
202
203
|
// )
|
203
|
-
if (
|
204
|
+
if (newCIDs.length === 0) {
|
204
205
|
return null
|
205
206
|
}
|
206
207
|
|