update code to match latest aqua

This commit is contained in:
boneyard93501 2022-07-29 11:44:07 -05:00
parent 85a90c9467
commit 7c37fbcedf

View File

@ -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()
--Op.noop()
join res[Op.array_length(nodes) - Op.array_length(dead_peers) -1]
join res[19]
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