mirror of
https://github.com/fluencelabs/examples
synced 2025-04-01 23:51:05 +00:00
38 lines
789 B
Plaintext
38 lines
789 B
Plaintext
import "builtin.aqua"
|
|
|
|
service Op2("op"):
|
|
identity(s: u64)
|
|
array(a: string, b: u64) -> string
|
|
|
|
data Oracle:
|
|
n: u32
|
|
mode: u64
|
|
freq: u32
|
|
err_str: string
|
|
raw_data: []u64
|
|
|
|
service TSOracle("service-id"):
|
|
point_estimate: []u64, u32 -> Oracle
|
|
|
|
|
|
func ts_getter(node: string) -> []u64:
|
|
res: *u64
|
|
on node:
|
|
k <- Op.string_to_b58(node)
|
|
nodes <- Kademlia.neighborhood(k, nil, nil)
|
|
if Op.array_length(nodes) > 0:
|
|
for n <- nodes par:
|
|
on n:
|
|
try:
|
|
res <- Peer.timestamp_ms()
|
|
join res[9]
|
|
<- res
|
|
|
|
func ts_oracle(node: string, oracle_service_id: string, min_points:u32) -> Oracle:
|
|
res <- ts_getter(node)
|
|
on node:
|
|
TSOracle oracle_service_id
|
|
oracle <- TSOracle.point_estimate(res, min_points)
|
|
<- oracle
|
|
|