@fireproof/core 0.7.2-dev.6 → 0.7.2-dev.8

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.
@@ -38908,6 +38908,7 @@ class Base {
38908
38908
  lastCid: clock[0],
38909
38909
  get: cid => allBlocks.get(cid.toString())
38910
38910
  };
38911
+ console.log('compact', this.instanceId, this.name, blocks.lastCid.toString(), dataCids.length);
38911
38912
  await this.parkCar(blocks, dataCids);
38912
38913
  }
38913
38914
 
@@ -39052,6 +39053,7 @@ class Base {
39052
39053
 
39053
39054
  async mapForIPLDHashmapCarCid (carCid) {
39054
39055
  // console.log('mapForIPLDHashmapCarCid', carCid)
39056
+ // todo why is this writeable?
39055
39057
  const carMapReader = await this.getWriteableCarReader(carCid);
39056
39058
  const indexNode = await load$1(carMapReader, carMapReader.root.cid, {
39057
39059
  blockHasher: blockOpts$1.hasher,
@@ -39090,7 +39092,19 @@ class Base {
39090
39092
  return combinedReader
39091
39093
  }
39092
39094
 
39095
+ async xgetCarReader (carCid) {
39096
+ return this.getCarReaderImpl(carCid)
39097
+ }
39098
+
39099
+ carReaderCache = new Map()
39093
39100
  async getCarReader (carCid) {
39101
+ if (!this.carReaderCache.has(carCid)) {
39102
+ this.carReaderCache.set(carCid, this.getCarReaderImpl(carCid));
39103
+ }
39104
+ return this.carReaderCache.get(carCid)
39105
+ }
39106
+
39107
+ async getCarReaderImpl (carCid) {
39094
39108
  carCid = carCid.toString();
39095
39109
  const carBytes = await this.readCar(carCid);
39096
39110
  // console.log('getCarReader', this.constructor.name, carCid, carBytes.length)
@@ -40081,19 +40095,6 @@ class Valet {
40081
40095
  }
40082
40096
  }
40083
40097
 
40084
- // async compact() {
40085
- // const carCids = []
40086
- // // for await (const { cid } of this.valet.cids()) {
40087
- // // yield { cid }
40088
- // // }
40089
- // // create a blockstore with all data
40090
- // {
40091
- // entries: () => syncCIDs.map(cid => ({ cid })),
40092
- // get: async cid => await blocks.get(cid)
40093
- // }
40094
- // // park it
40095
- // }
40096
-
40097
40098
  /**
40098
40099
  * Iterate over all blocks in the store.
40099
40100
  *