@fireproof/core 0.7.2-dev.5 → 0.7.2-dev.7

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.
@@ -38935,10 +38935,12 @@ class Base {
38935
38935
  const block = await this.getLoaderBlock(cid);
38936
38936
  allBlocks.set(cid, block);
38937
38937
  }
38938
+ cidMap.clear();
38938
38939
  const blocks = {
38939
38940
  lastCid: clock[0],
38940
38941
  get: cid => allBlocks.get(cid.toString())
38941
38942
  };
38943
+ console.log('compact', this.instanceId, this.name, blocks.lastCid.toString(), dataCids.length);
38942
38944
  await this.parkCar(blocks, dataCids);
38943
38945
  }
38944
38946
 
@@ -39083,6 +39085,7 @@ class Base {
39083
39085
 
39084
39086
  async mapForIPLDHashmapCarCid (carCid) {
39085
39087
  // console.log('mapForIPLDHashmapCarCid', carCid)
39088
+ // todo why is this writeable?
39086
39089
  const carMapReader = await this.getWriteableCarReader(carCid);
39087
39090
  const indexNode = await load$1(carMapReader, carMapReader.root.cid, {
39088
39091
  blockHasher: blockOpts$1.hasher,
@@ -39121,7 +39124,21 @@ class Base {
39121
39124
  return combinedReader
39122
39125
  }
39123
39126
 
39127
+ async xgetCarReader (carCid) {
39128
+ return this.getCarReaderImpl(carCid)
39129
+ }
39130
+
39131
+ carReaderCache = new Map()
39124
39132
  async getCarReader (carCid) {
39133
+ if (this.carReaderCache.has(carCid)) {
39134
+ return this.carReaderCache.get(carCid)
39135
+ }
39136
+ const result = await this.getCarReaderImpl(carCid);
39137
+ this.carReaderCache.set(carCid, result);
39138
+ return result
39139
+ }
39140
+
39141
+ async getCarReaderImpl (carCid) {
39125
39142
  carCid = carCid.toString();
39126
39143
  const carBytes = await this.readCar(carCid);
39127
39144
  // console.log('getCarReader', this.constructor.name, carCid, carBytes.length)
@@ -40112,19 +40129,6 @@ class Valet {
40112
40129
  }
40113
40130
  }
40114
40131
 
40115
- // async compact() {
40116
- // const carCids = []
40117
- // // for await (const { cid } of this.valet.cids()) {
40118
- // // yield { cid }
40119
- // // }
40120
- // // create a blockstore with all data
40121
- // {
40122
- // entries: () => syncCIDs.map(cid => ({ cid })),
40123
- // get: async cid => await blocks.get(cid)
40124
- // }
40125
- // // park it
40126
- // }
40127
-
40128
40132
  /**
40129
40133
  * Iterate over all blocks in the store.
40130
40134
  *