Skip to content

Commit

Permalink
updated cacheKey with query params of decodedXcmMsgs and paraId
Browse files Browse the repository at this point in the history
- updated docs in blocks controller comments
  • Loading branch information
Imod7 committed Jan 12, 2024
1 parent 2090b46 commit 6ad6e16
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/controllers/blocks/BlocksController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ import AbstractController from '../AbstractController';
* - (Optional for `/blocks/head`) `finalized`: When set to `false`, it will fetch the head of
* the node's canon chain, which might not be finalized. When set to `true` it
* will fetch the head of the finalized chain.
* - (Optional) `noFees`: When set to `true`, it will not calculate the fee for each extrinsic.
* - (Optional for `/blocks/{blockId}`) `decodedXcmMsgs`: When set to `true`, it will show the
* decoded XCM messages within the extrinsics of the requested block.
* - (Optional for `/blocks/{blockId}) `paraId`: When it is set, it will return only the decoded
* XCM messages for the specified paraId/parachain Id. To activate this functionality, ensure
* that the `decodedXcmMsgs` parameter is set to true.
*
*
* Returns:
Expand Down Expand Up @@ -74,6 +80,8 @@ import AbstractController from '../AbstractController';
* is `true` and that the extrinsic is signed when reconciling old blocks.
* - `onFinalize`: Object with an array of `SanitizedEvent`s that occurred during block
* finalization with the `method` and `data` for each.
* - `decodedXcmMsgs`: An array of the decoded XCM messages found within the extrinsics
* of the requested block.
*
* Note: Block finalization does not correspond to consensus, i.e. whether the block is in the
* canonical chain. It denotes the finalization of block _construction._
Expand Down
8 changes: 7 additions & 1 deletion src/services/blocks/BlocksService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ export class BlocksService extends AbstractService {

// Create a key for the cache that is a concatenation of the block hash and all the query params included in the request
const cacheKey =
hash.toString() + Number(eventDocs) + Number(extrinsicDocs) + Number(checkFinalized) + Number(noFees);
hash.toString() +
Number(eventDocs) +
Number(extrinsicDocs) +
Number(checkFinalized) +
Number(noFees) +
Number(decodedXcmMsgsArg) +
Number(paraId);

// Before making any api calls check the cache if the queried block exists
const isBlockCached = this.blockStore.get(cacheKey);
Expand Down

0 comments on commit 6ad6e16

Please sign in to comment.