Skip to content

Commit

Permalink
fix: add finalizedKey query param to /blocks/{blockId} (#1362)
Browse files Browse the repository at this point in the history
* add build to inspect

* fix: add `finalized` query param to `/blocks/{blockId}`

* docs

* change key to finalizedKey
  • Loading branch information
TarikGul committed Nov 29, 2023
1 parent 87d2092 commit ecd1518
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/dist/app.bundle.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions docs/src/openapi-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,14 @@ paths:
schema:
type: boolean
default: false
- name: finalizedKey
in: query
description: When set to false, this will override the chain-config, and omit the
finalized key in the response. This can increase performance slightly by avoiding an additional
RPC call to the node.
required: false
schema:
type: boolean
responses:
"200":
description: successful operation
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"main": "node ./build/src/main.js",
"dev": "ts-node-dev --respawn --transpile-only ./src/main.ts",
"deploy": "yarn build && npm publish",
"inspect": "node --inspect=127.0.0.1:8081 ./build/src/main.js",
"inspect": "yarn build && node --inspect=127.0.0.1:8081 ./build/src/main.js",
"build": "substrate-exec-rimraf build/ && substrate-exec-tsc && echo Build Finished",
"build:calc": "bash ./calc/build.sh",
"build:docker": "docker build -t substrate-api-sidecar .",
Expand Down
9 changes: 7 additions & 2 deletions src/controllers/blocks/BlocksController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default class BlocksController extends AbstractController<BlocksService>
* @param res Express Response
*/
private getBlockById: RequestHandler<INumberParam> = async (
{ params: { number }, query: { eventDocs, extrinsicDocs } },
{ params: { number }, query: { eventDocs, extrinsicDocs, finalizedKey } },
res,
): Promise<void> => {
const checkFinalized = isHex(number);
Expand All @@ -168,9 +168,14 @@ export default class BlocksController extends AbstractController<BlocksService>

const eventDocsArg = eventDocs === 'true';
const extrinsicDocsArg = extrinsicDocs === 'true';
const finalizeOverride = finalizedKey === 'false';

const queryFinalizedHead = !this.options.finalizes ? false : true;
const omitFinalizedTag = !this.options.finalizes ? true : false;
let omitFinalizedTag = !this.options.finalizes ? true : false;

if (finalizeOverride) {
omitFinalizedTag = true;
}

const options = {
eventDocs: eventDocsArg,
Expand Down

0 comments on commit ecd1518

Please sign in to comment.