Skip to content

Commit 7c66738

Browse files
authored
Optimize /block call to getHeader by parallelize-ing (#233)
1 parent 3ce5b70 commit 7c66738

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/services/blocks/BlocksService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ export class BlocksService extends AbstractService {
3838
*/
3939
async fetchBlock(hash: BlockHash): Promise<IBlock> {
4040
const api = await this.ensureMeta(hash);
41-
const [{ block }, events] = await Promise.all([
41+
const [{ block }, events, headerDerive] = await Promise.all([
4242
api.rpc.chain.getBlock(hash),
4343
this.fetchEvents(api, hash),
44+
api.derive.chain.getHeader(hash),
4445
]);
4546

4647
const { parentHash, number, stateRoot, extrinsicsRoot } = block.header;
4748

48-
const header = await api.derive.chain.getHeader(hash);
49-
const authorId = header?.author;
49+
const authorId = headerDerive?.author;
5050

5151
const logs = block.header.digest.logs.map((log) => {
5252
const { type, index, value } = log;

0 commit comments

Comments
 (0)