Skip to content

Commit

Permalink
Freshness test: look at latest block time, not latest update
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Jun 28, 2023
1 parent 895acc0 commit 495c762
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .changelog/611.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Freshness test: look at latest block time, not latest update
4 changes: 2 additions & 2 deletions src/app/components/OfflineBanner/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const useRuntimeFreshness = (scope: SearchScope): FreshnessInfo => {
throw new AppError(AppErrors.UnsupportedLayer)
}
const query = useGetRuntimeStatus(scope.network, scope.layer)
const timeDistance = useFormattedTimestampString(query?.data?.data.latest_update)
const timeDistance = useFormattedTimestampString(query?.data?.data.latest_block_time)
if (query.isLoading) {
return {
outOfDate: undefined,
Expand All @@ -51,7 +51,7 @@ export const useRuntimeFreshness = (scope: SearchScope): FreshnessInfo => {
outOfDate: true,
}
}
const timeSinceLastUpdate = query.dataUpdatedAt - new Date(data.latest_update).getTime()
const timeSinceLastUpdate = query.dataUpdatedAt - new Date(data.latest_block_time).getTime()
const { outOfDateThreshold } = paraTimesConfig[scope.layer]
return {
outOfDate: timeSinceLastUpdate > outOfDateThreshold,
Expand Down

0 comments on commit 495c762

Please sign in to comment.