mirror of
https://github.com/fluencelabs/registry.git
synced 2025-04-25 02:02:14 +00:00
26 lines
690 B
Plaintext
26 lines
690 B
Plaintext
module AquaDHT.Scheduled declares *
|
|
|
|
export clearExpired_86400, replicate_3600
|
|
|
|
import "dht.aqua"
|
|
import "@fluencelabs/aqua-lib/builtin.aqua"
|
|
|
|
-- clears expired records
|
|
func clearExpired_86400():
|
|
on HOST_PEER_ID:
|
|
t <- Peer.timestamp_sec()
|
|
AquaDHT.clear_expired(t)
|
|
|
|
-- get all old records and replicate it by keys
|
|
func replicate_3600():
|
|
on HOST_PEER_ID:
|
|
t <- Peer.timestamp_sec()
|
|
res <- AquaDHT.evict_stale(t)
|
|
for r <- res.results par:
|
|
k <- Op.string_to_b58(r.key.key)
|
|
nodes <- Kademlia.neighborhood(k, nil, nil)
|
|
for n <- nodes par:
|
|
on n:
|
|
AquaDHT.republish_key(r.key, t)
|
|
AquaDHT.republish_values(r.key.key, r.records, t)
|