Skip to content

Commit 2c0a2f9

Browse files
authored
fix: use all params for cache key (#1805)
1 parent d8bf37b commit 2c0a2f9

File tree

4 files changed

+9
-75
lines changed

4 files changed

+9
-75
lines changed

src/controllers/blocks/BlocksController.ts

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,7 @@ export default class BlocksController extends AbstractController<BlocksService>
234234
};
235235

236236
// Create a key for the cache that is a concatenation of the block hash and all the query params included in the request
237-
const cacheKey =
238-
ahHash.toString() +
239-
Number(options.eventDocs) +
240-
Number(options.extrinsicDocs) +
241-
Number(options.checkFinalized) +
242-
Number(options.noFees) +
243-
Number(options.checkDecodedXcm) +
244-
Number(options.paraId) +
245-
Number(options.useEvmAddressFormat);
237+
const cacheKey = ahHash.toString() + Object.values(options).join();
246238

247239
const isBlockCached = this.blockStore.get(cacheKey);
248240

@@ -318,15 +310,7 @@ export default class BlocksController extends AbstractController<BlocksService>
318310
useEvmAddressFormat: useEvmFormat === 'true',
319311
};
320312
// Create a key for the cache that is a concatenation of the block hash and all the query params included in the request
321-
const cacheKey =
322-
hash.toString() +
323-
Number(options.eventDocs) +
324-
Number(options.extrinsicDocs) +
325-
Number(options.checkFinalized) +
326-
Number(options.noFees) +
327-
Number(options.checkDecodedXcm) +
328-
Number(options.paraId) +
329-
Number(options.useEvmAddressFormat);
313+
const cacheKey = hash.toString() + Object.values(options).join();
330314

331315
const isBlockCached = this.blockStore.get(cacheKey);
332316

@@ -409,15 +393,7 @@ export default class BlocksController extends AbstractController<BlocksService>
409393
};
410394

411395
// Create a key for the cache that is a concatenation of the block hash and all the query params included in the request
412-
const cacheKey =
413-
ahHash.toString() +
414-
Number(options.eventDocs) +
415-
Number(options.extrinsicDocs) +
416-
Number(options.checkFinalized) +
417-
Number(options.noFees) +
418-
Number(options.checkDecodedXcm) +
419-
Number(options.paraId) +
420-
Number(options.useEvmAddressFormat);
396+
const cacheKey = ahHash.toString() + Object.values(options).join();
421397

422398
const isBlockCached = this.blockStore.get(cacheKey);
423399

@@ -490,15 +466,7 @@ export default class BlocksController extends AbstractController<BlocksService>
490466
};
491467

492468
// Create a key for the cache that is a concatenation of the block hash and all the query params included in the request
493-
const cacheKey =
494-
hash.toString() +
495-
Number(options.eventDocs) +
496-
Number(options.extrinsicDocs) +
497-
Number(options.checkFinalized) +
498-
Number(options.noFees) +
499-
Number(options.checkDecodedXcm) +
500-
Number(options.paraId) +
501-
Number(options.useEvmAddressFormat);
469+
const cacheKey = hash.toString() + Object.values(options).join();
502470

503471
const isBlockCached = this.blockStore.get(cacheKey);
504472

src/controllers/blocks/BlocksExtrinsicsController.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,7 @@ export default class BlocksExtrinsicsController extends AbstractController<Block
8383
useEvmAddressFormat: useEvmFormat === 'true',
8484
};
8585

86-
const cacheKey =
87-
ahHash.toString() +
88-
Number(options.eventDocs) +
89-
Number(options.extrinsicDocs) +
90-
Number(options.checkFinalized) +
91-
Number(options.noFees) +
92-
Number(options.checkDecodedXcm) +
93-
Number(options.useEvmAddressFormat);
86+
const cacheKey = ahHash.toString() + Object.values(options).join();
9487

9588
const isBlockCached = this.blockStore.get(cacheKey);
9689
const historicApi = await this.api.at(ahHash);
@@ -145,14 +138,7 @@ export default class BlocksExtrinsicsController extends AbstractController<Block
145138
useEvmAddressFormat: useEvmFormat === 'true',
146139
};
147140

148-
const cacheKey =
149-
hash.toString() +
150-
Number(options.eventDocs) +
151-
Number(options.extrinsicDocs) +
152-
Number(options.checkFinalized) +
153-
Number(options.noFees) +
154-
Number(options.checkDecodedXcm) +
155-
Number(options.useEvmAddressFormat);
141+
const cacheKey = hash.toString() + Object.values(options).join();
156142

157143
const isBlockCached = this.blockStore.get(cacheKey);
158144
const historicApi = await this.api.at(hash);

src/controllers/rc/blocks/RcBlocksController.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,7 @@ export default class RcBlocksController extends AbstractController<BlocksService
144144
paraId: paraIdArg,
145145
};
146146

147-
const cacheKey =
148-
hash.toString() +
149-
Number(options.eventDocs) +
150-
Number(options.extrinsicDocs) +
151-
Number(options.checkFinalized) +
152-
Number(options.noFees) +
153-
Number(options.checkDecodedXcm) +
154-
Number(options.paraId);
147+
const cacheKey = hash.toString() + Object.values(options).join();
155148

156149
const isBlockCached = this.blockStore.get(cacheKey);
157150

@@ -219,14 +212,7 @@ export default class RcBlocksController extends AbstractController<BlocksService
219212
paraId: paraIdArg,
220213
};
221214

222-
const cacheKey =
223-
hash.toString() +
224-
Number(options.eventDocs) +
225-
Number(options.extrinsicDocs) +
226-
Number(options.checkFinalized) +
227-
Number(options.noFees) +
228-
Number(options.checkDecodedXcm) +
229-
Number(options.paraId);
215+
const cacheKey = hash.toString() + Object.values(options).join();
230216

231217
const isBlockCached = this.blockStore.get(cacheKey);
232218

src/controllers/rc/blocks/RcBlocksExtrinsicsController.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,7 @@ export default class RcBlocksExtrinsicsController extends AbstractController<Blo
7474
paraId: undefined,
7575
};
7676

77-
const cacheKey =
78-
hash.toString() +
79-
Number(options.eventDocs) +
80-
Number(options.extrinsicDocs) +
81-
Number(options.checkFinalized) +
82-
Number(options.noFees) +
83-
Number(options.checkDecodedXcm);
77+
const cacheKey = hash.toString() + Object.values(options).join();
8478

8579
const isBlockCached = this.blockStore.get(cacheKey);
8680
const historicApi = await rcApi.at(hash);

0 commit comments

Comments
 (0)