@fireproof/core 0.5.15 → 0.5.17

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.
@@ -115,8 +115,8 @@ export class TransactionBlockstore {
115
115
  */
116
116
  async *entries() {
117
117
  for (const transaction of this.inflightTransactions) {
118
- for (const [str, bytes] of transaction) {
119
- yield { cid: str, bytes };
118
+ for (const [cid, bytes] of transaction.entries()) { // test for this?
119
+ yield { cid: cid.toString(), bytes };
120
120
  }
121
121
  }
122
122
  for (const [str, bytes] of this.committedBlocks) {
@@ -164,7 +164,7 @@ export class TransactionBlockstore {
164
164
  doCommit = async (innerBlockstore) => {
165
165
  const cids = new Set();
166
166
  for (const { cid, bytes } of innerBlockstore.entries()) {
167
- const stringCid = cid.toString(); // unnecessary string conversion, can we fix upstream?
167
+ const stringCid = cid.toString();
168
168
  if (this.committedBlocks.has(stringCid)) {
169
169
  // console.log('Duplicate block: ' + stringCid) // todo some of this can be avoided, cost is extra size on car files
170
170
  }
package/dist/src/clock.js CHANGED
@@ -223,11 +223,11 @@ export async function findEventsToSync(blocks, head) {
223
223
  // console.time(callTag + '.findCommonAncestorWithSortedEvents')
224
224
  const { ancestor, sorted } = await findCommonAncestorWithSortedEvents(events, head);
225
225
  // console.timeEnd(callTag + '.findCommonAncestorWithSortedEvents')
226
- // console.log('sorted', !!ancestor, sorted.length)
226
+ // console.log('sorted', !!ancestor, sorted)
227
227
  // console.time(callTag + '.contains')
228
228
  const toSync = ancestor ? await asyncFilter(sorted, async (uks) => !(await contains(events, ancestor, uks.cid))) : sorted;
229
229
  // console.timeEnd(callTag + '.contains')
230
- console.log('toSync', !!ancestor, sorted.length - toSync.length);
230
+ console.log('optimize sorted', !!ancestor, sorted.length - toSync.length);
231
231
  return { cids: events, events: toSync };
232
232
  }
233
233
  const asyncFilter = async (arr, predicate) => Promise.all(arr.map(predicate)).then(results => arr.filter((_v, index) => results[index]));