Use more accurate epoch duration calculation in explorer (#11359)

This commit is contained in:
Justin Starry 2020-08-04 22:18:09 +08:00 committed by GitHub
parent 247e361d23
commit ebe14415f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -62,12 +62,16 @@ function StatsCardBody() {
}
const currentBlock = rootSlot.toLocaleString("en-US");
const { avgBlockTime_1min, epochInfo } = dashboardInfo;
const { avgBlockTime_1h, avgBlockTime_1min, epochInfo } = dashboardInfo;
const hourlyBlockTime = Math.round(1000 * avgBlockTime_1h);
const averageBlockTime = Math.round(1000 * avgBlockTime_1min) + "ms";
const { slotIndex, slotsInEpoch } = epochInfo;
const currentEpoch = epochInfo.epoch.toString();
const epochProgress = ((100 * slotIndex) / slotsInEpoch).toFixed(1) + "%";
const epochTimeRemaining = slotsToHumanString(slotsInEpoch - slotIndex);
const epochTimeRemaining = slotsToHumanString(
slotsInEpoch - slotIndex,
hourlyBlockTime
);
const averageTps = Math.round(performanceInfo.avgTPS);
const transactionCount = <AnimatedTransactionCount info={performanceInfo} />;

View File

@ -52,6 +52,9 @@ HUMANIZER.addLanguage("short", {
decimal: ".",
});
export function slotsToHumanString(slots: number): string {
return HUMANIZER.humanize(slots * MS_PER_SLOT);
export function slotsToHumanString(
slots: number,
slotTime = MS_PER_SLOT
): string {
return HUMANIZER.humanize(slots * slotTime);
}