Skip to content

Commit

Permalink
chore: migrate to new cron syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mindrunner committed Nov 19, 2023
1 parent 140efda commit 79ba73c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/lib/refill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { refillPlayer } from './refill-player'
import { optimalRefillStrategy } from './refill-strategy'
import { getDailyBurnRate } from './stock-resources'

export const refill = async (): Promise<void[]> => {
export const refill = async (): Promise<void> => {
const players = await Wallet.findBy({ enabled: true })

await initOrderBook()

return Promise.all(players.map(async (player) => {
await Promise.all(players.map(async (player) => {
if (dayjs().isAfter(player.nextRefill)) {
await refillPlayer(new PublicKey(player.publicKey), optimalRefillStrategy)
}
Expand Down
10 changes: 7 additions & 3 deletions src/main/fleetbot/fleetbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export const start = async (): Promise<void> => {
await checkTransactions()
await refill()
}
resourcesCronJob = new CronJob(config.cron.resourceInterval, stockResources, null, true)
refillCronJob = new CronJob(config.cron.refillInterval, refill, null, true)
transactionCronJob = new CronJob(config.cron.bookkeeperInterval, checkTransactions, null, true)
resourcesCronJob = CronJob.from({ cronTime: config.cron.resourceInterval, onTick: stockResources, start: true })
refillCronJob = CronJob.from({ cronTime: config.cron.refillInterval, onTick: refill, start: true })
transactionCronJob = CronJob.from({
cronTime: config.cron.bookkeeperInterval,
onTick: checkTransactions,
start: true
})
}

0 comments on commit 79ba73c

Please sign in to comment.