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