From 58f8713292b7886a46f13bcf3f910d8d852d8757 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Wed, 29 Sep 2021 15:50:27 -0400 Subject: [PATCH] explorer: Display confirmed block's child slot (#20322) --- explorer/src/components/block/BlockOverviewCard.tsx | 8 ++++++++ explorer/src/providers/block.tsx | 8 +++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/explorer/src/components/block/BlockOverviewCard.tsx b/explorer/src/components/block/BlockOverviewCard.tsx index 514f1d72f..162f3f58f 100644 --- a/explorer/src/components/block/BlockOverviewCard.tsx +++ b/explorer/src/components/block/BlockOverviewCard.tsx @@ -98,6 +98,14 @@ export function BlockOverviewCard({ {block.previousBlockhash} + {confirmedBlock.data.child && ( + + Child Slot + + + + + )} Processed Transactions diff --git a/explorer/src/providers/block.tsx b/explorer/src/providers/block.tsx index facf9102f..724132bb2 100644 --- a/explorer/src/providers/block.tsx +++ b/explorer/src/providers/block.tsx @@ -17,6 +17,7 @@ export enum ActionType { type Block = { block?: BlockResponse; + child?: number; }; type State = Cache.State; @@ -71,13 +72,14 @@ export async function fetchBlock( let data: Block | undefined = undefined; try { - const connection = new Connection(url, "finalized"); - const block = await connection.getBlock(Number(key)); + const connection = new Connection(url, "confirmed"); + const block = await connection.getBlock(key); + const child = (await connection.getBlocks(key + 1, key + 100)).shift(); if (block === null) { data = {}; status = FetchStatus.Fetched; } else { - data = { block }; + data = { block, child }; status = FetchStatus.Fetched; } } catch (err) {