of "cron" in subgraph? I need to create some entity in the start of each day
I tried to add a block handler and check hour === 0:
export function handleBlock(block: ethereum.Block): void {
const currentDayId = block.timestamp.toI32() / 86400
const hour = (block.timestamp.toI32() - currentDayId * 86400) / 3600
if (hour !== 0) {
return
}
...
}
but it makes my subgraph to slow to sync after redeploy. Even during blocks which was generated at 1-23 hours.
Maybe there is some utility contract wich emit events DayStarted?)
Hi Sergey! Thanks for your question. I'll suggest you post it through our Discord channel to get technical support. thegraph.com/discord 👀
There is not a cron function yet, but this was recently discussed on the forums. Block handlers are unfortunately slow since it stops at every block to check logic. These questions are probably best answered in the subgraph developer channel in discord. I have a couple ideas that might be worth trying out.
Could you give me a link to the message there it was discussed? Search on channel does not give me result. Thanks
https://forum.thegraph.com/t/grp-0001-decorator-hooks-cron-jobs-and-initialisation-handlers/3347
Обсуждают сегодня