fix(spell): update spell api (#315)

This commit is contained in:
folex 2023-12-21 16:19:52 -03:00 committed by GitHub
parent 01d8cb4052
commit 3092907e5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -13,6 +13,6 @@ dependencies:
marine: 0.14.1
mrepl: 0.21.3
npm:
'@fluencelabs/aqua-lib': 0.8.1
'@fluencelabs/spell': 0.5.33
'@fluencelabs/aqua-lib': 0.9.0
'@fluencelabs/spell': 0.6.0
'@fluencelabs/trust-graph': 3.1.2

View File

@ -56,16 +56,15 @@ func spell(config: SpellConfig):
check_and_run = (key: string, now:u32, interval: u32, job: u32 -> ()):
last_run <- Spell.get_u32(key)
need_to_run = !last_run.success || ((now - last_run.num) >= interval)
need_to_run = !last_run.success || ((now - last_run.value) >= interval)
if need_to_run == true:
log(Op.concat_strings(Op.concat_strings("Running ", key), "job"))
job(now)
Spell.set_u32(key, now)
on HOST_PEER_ID:
now <- PeerTimeTrunc.timestamp_sec()
check_and_run("clear_expired", now, config.expired_interval, clear_expired)
check_and_run("renew", now, config.renew_interval, renew)
check_and_run("replicate", now, config.replicate_interval, replicate)