diff --git a/backend/pkg/api/data_access/vdb_summary.go b/backend/pkg/api/data_access/vdb_summary.go index a2b20d483..94deef34f 100644 --- a/backend/pkg/api/data_access/vdb_summary.go +++ b/backend/pkg/api/data_access/vdb_summary.go @@ -768,9 +768,9 @@ func (d *DataAccessService) GetValidatorDashboardGroupSummary(ctx context.Contex ret.Luck.Proposal.Percent = (float64(totalProposals)) / totalBlockChance * 100 // calculate the average time it takes for the set of validators to propose a single block on average - ret.Luck.Proposal.Average = time.Duration((luckHours / totalBlockChance) * float64(time.Hour)) + ret.Luck.Proposal.AverageIntervalSeconds = uint64(time.Duration((luckHours / totalBlockChance) * float64(time.Hour)).Seconds()) - ret.Luck.Proposal.Expected = lastBlockTs.Add(ret.Luck.Proposal.Average) + ret.Luck.Proposal.ExpectedTimestamp = uint64(lastBlockTs.Unix()) + ret.Luck.Proposal.AverageIntervalSeconds } else { ret.Luck.Proposal.Percent = 0 } @@ -784,9 +784,9 @@ func (d *DataAccessService) GetValidatorDashboardGroupSummary(ctx context.Contex ret.Luck.Sync.Percent = syncCommittees / totalSyncExpected * 100 // calculate the average time it takes for the set of validators to be elected into a sync committee on average - ret.Luck.Sync.Average = time.Duration((luckHours / totalSyncExpected) * float64(time.Hour)) + ret.Luck.Sync.AverageIntervalSeconds = uint64(time.Duration((luckHours / totalSyncExpected) * float64(time.Hour)).Seconds()) - ret.Luck.Sync.Expected = lastSyncTs.Add(ret.Luck.Sync.Average) + ret.Luck.Sync.ExpectedTimestamp = uint64(lastSyncTs.Unix()) + ret.Luck.Sync.AverageIntervalSeconds } if totalInclusionDelayDivisor > 0 { diff --git a/backend/pkg/api/types/common.go b/backend/pkg/api/types/common.go index 24e2b9522..047cadac6 100644 --- a/backend/pkg/api/types/common.go +++ b/backend/pkg/api/types/common.go @@ -1,8 +1,6 @@ package types import ( - "time" - "github.com/shopspring/decimal" ) @@ -41,9 +39,9 @@ type Address struct { } type LuckItem struct { - Percent float64 `json:"percent"` - Expected time.Time `json:"expected" swaggertype:"string" format:"date-time"` - Average time.Duration `json:"average" swaggertype:"primitive,integer"` + Percent float64 `json:"percent"` + ExpectedTimestamp uint64 `json:"expected_timestamp"` + AverageIntervalSeconds uint64 `json:"average_interval_seconds"` } type Luck struct { diff --git a/frontend/components/dashboard/table/SummaryValue.vue b/frontend/components/dashboard/table/SummaryValue.vue index f0cb7ba28..d5d012a69 100644 --- a/frontend/components/dashboard/table/SummaryValue.vue +++ b/frontend/components/dashboard/table/SummaryValue.vue @@ -341,8 +341,8 @@ const openValidatorModal = () => { {{ $t("common.average") }}: {{ $t("common.every_x", { - duration: formatNanoSecondDuration( - data.luck.proposal.average, + duration: formatTimeDuration( + data.luck.proposal.average_interval_seconds, $t, ), }) @@ -362,7 +362,7 @@ const openValidatorModal = () => { {{ $t("common.average") }}: {{ $t("common.every_x", { - duration: formatNanoSecondDuration(data.luck.sync.average, $t), + duration: formatTimeDuration(data.luck.sync.average_interval_seconds, $t), }) }} diff --git a/frontend/types/api/common.ts b/frontend/types/api/common.ts index 4f1d50872..992f10f01 100644 --- a/frontend/types/api/common.ts +++ b/frontend/types/api/common.ts @@ -33,8 +33,8 @@ export interface Address { } export interface LuckItem { percent: number /* float64 */; - expected: string /* time.Time */; - average: any /* time.Duration */; + expected_timestamp: number /* uint64 */; + average_interval_seconds: number /* uint64 */; } export interface Luck { proposal: LuckItem; diff --git a/frontend/utils/format.ts b/frontend/utils/format.ts index 510495481..0cc794877 100644 --- a/frontend/utils/format.ts +++ b/frontend/utils/format.ts @@ -331,17 +331,6 @@ export function formatTimeDuration( return t(translationId, { amount }, amount === 1 ? 1 : 2) } -export function formatNanoSecondDuration( - nano: number | undefined, - t: ComposerTranslation, -): string | undefined { - if (nano === undefined) { - return undefined - } - const seconds = Math.floor(nano / 1000000000) - return formatTimeDuration(seconds, t) -} - export function formatFiat( value: number, currency: string,