explorer: Display confirmed block's child slot (#20322)

This commit is contained in:
Justin Starry 2021-09-29 15:50:27 -04:00 committed by GitHub
parent 5c35ab619d
commit 58f8713292
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -98,6 +98,14 @@ export function BlockOverviewCard({
<span>{block.previousBlockhash}</span>
</td>
</tr>
{confirmedBlock.data.child && (
<tr>
<td className="w-100">Child Slot</td>
<td className="text-lg-right text-monospace">
<Slot slot={confirmedBlock.data.child} link />
</td>
</tr>
)}
<tr>
<td className="w-100">Processed Transactions</td>
<td className="text-lg-right text-monospace">

View File

@ -17,6 +17,7 @@ export enum ActionType {
type Block = {
block?: BlockResponse;
child?: number;
};
type State = Cache.State<Block>;
@ -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) {