From 7c37fbcedff48142c1e96909e6d3b7086bf2de63 Mon Sep 17 00:00:00 2001 From: boneyard93501 <4523011+boneyard93501@users.noreply.github.com> Date: Fri, 29 Jul 2022 11:44:07 -0500 Subject: [PATCH] update code to match latest aqua --- .../5-oracle-service/aqua/ts_oracle.aqua | 39 ++++++------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/quickstart/5-oracle-service/aqua/ts_oracle.aqua b/quickstart/5-oracle-service/aqua/ts_oracle.aqua index f8dfe83..9171894 100644 --- a/quickstart/5-oracle-service/aqua/ts_oracle.aqua +++ b/quickstart/5-oracle-service/aqua/ts_oracle.aqua @@ -1,8 +1,5 @@ -alias PeerId : string -alias Base58String : string -alias Hash : string +import "@fluencelabs/aqua-lib/builtin.aqua" --- const N_KNEIGHBORS = 19 data Contact: peer_id: string @@ -11,11 +8,6 @@ data Contact: data Info: external_addresses: []string -service Op("op"): - noop() - string_to_b58(s: string) -> Base58String - concat_strings(a: string, b: string) -> string - service MyOp("op"): identity(u: u64) identity_string(s:string) @@ -23,18 +15,6 @@ service MyOp("op"): service MyOpBool("op"): identity(b: bool) -service Kademlia("kad"): - neighborhood(key: Base58String, already_hashed: ?bool, count: ?u32) -> []PeerId - merge(target: Base58String, left: []string, right: []string, count: ?u32) -> []string - -service Peer("peer"): - is_connected(peer: PeerId) -> bool - connect(id: PeerId, multiaddrs: ?[]string) -> bool - get_contact(peer: PeerId) -> Contact - identify() -> Info - timestamp_ms() -> u64 - timestamp_sec() -> u64 - timeout(duration_ms: u64, message: string) -> string data Consensus: n: u32 @@ -51,7 +31,7 @@ data Oracle: service TSOracle("service-id"): ts_frequency(timestamps: []u64, tolerance: u32, threshold: f64, err_value:u64) -> Consensus -func ts_oracle_with_consensus(tolerance: u32, threshold: f64, err_value:u64, node:string, oracle_service_id:string)-> Consensus, []string: +func ts_oracle_with_consensus(tolerance: u32, threshold: f64, err_value:u64, node:string, oracle_service_id:string)-> Consensus, []string, u32: rtt = 1000 -- in ms res: *u64 msg = "timeout" @@ -68,12 +48,15 @@ func ts_oracle_with_consensus(tolerance: u32, threshold: f64, err_value:u64, nod if status! != "success": res <<- err_value dead_peers <<- n - Op.noop() - - join res[19] + --Op.noop() + + join res[Op.array_length(nodes) - Op.array_length(dead_peers) -1] + TSOracle oracle_service_id consensus <- TSOracle.ts_frequency(res, tolerance, threshold, err_value) - <- consensus, dead_peers + + <- consensus, dead_peers, Op.array_length(nodes) - Op.array_length(dead_peers) + func ts_oracle_with_bool(tolerance: u32, threshold: f64, err_value:u64, node:string, oracle_service_id:string)-> []bool, []string: res: *bool @@ -85,6 +68,6 @@ func ts_oracle_with_bool(tolerance: u32, threshold: f64, err_value:u64, node:str for n <- nodes par: res <- Peer.connect(n, nil) peers <<- n - Op.noop() - join res[19] + + join res[Op.array_length(nodes) - 1] <- res, peers \ No newline at end of file