Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hapi): validate if the last schedule time is not undefined #1428

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions hapi/src/services/fio.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,16 +347,21 @@ const syncRewards = async () => {
await updateRewards(producers)

const scheduleTime = await getLastPaidScheduleTime()

Torresmorah marked this conversation as resolved.
Show resolved Hide resolved
scheduleTime.setSeconds(scheduleTime.getSeconds() + 86400)

const nextScheduleUpdate = Math.ceil((scheduleTime.getTime() - (new Date()).getTime()))

if (nextScheduleUpdate > 0) {
console.log(`SYNCING FIO REWARDS - sync completed, next sync on ${scheduleTime.toISOString()}`)
setTimeout(syncRewards, nextScheduleUpdate)
const scheduleTimeMs = scheduleTime?.getTime() || 0

if (scheduleTimeMs > 0) {
scheduleTime.setSeconds(scheduleTime.getSeconds() + 86400)

Torresmorah marked this conversation as resolved.
Show resolved Hide resolved
const nextScheduleUpdate = Math.ceil((scheduleTime.getTime() - (new Date()).getTime()))

Torresmorah marked this conversation as resolved.
Show resolved Hide resolved
if (nextScheduleUpdate > 0) {
console.log(`SYNCING FIO REWARDS - sync completed, next sync on ${scheduleTime.toISOString()}`)
setTimeout(syncRewards, nextScheduleUpdate)
} else {
Torresmorah marked this conversation as resolved.
Show resolved Hide resolved
setTimeout(syncRewards, 5 * 60 * 1000)
}
} else {
setTimeout(syncRewards, 5 * 60 * 1000)
setTimeout(syncRewards, 60 * 1000)
}
}
}
Expand Down
Loading