Skip to content

Commit

Permalink
feat(hapi): wait bps synchronization to synchronize fio rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
Torresmorah committed Jul 26, 2024
1 parent 4a0837c commit c70a3f6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions hapi/src/services/fio.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,19 @@ const syncRewards = async () => {
const voteShares = await getVoteShares()
const producers = await getProducersWithRewards(voteShares)

await updateRewards(producers)
if (!producers?.length) {
setTimeout(syncRewards, 120 * 1000)
} else {
await updateRewards(producers)

const scheduleTime = await getLastPaidScheduleTime()
const scheduleTime = await getLastPaidScheduleTime()

scheduleTime.setSeconds(scheduleTime.getSeconds() + 86400)
scheduleTime.setSeconds(scheduleTime.getSeconds() + 86400)

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

setTimeout(syncRewards, nextScheduleUpdate)
setTimeout(syncRewards, nextScheduleUpdate)
}
}

module.exports = {
Expand Down

0 comments on commit c70a3f6

Please sign in to comment.