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

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