mirror of
https://github.com/fluencelabs/examples
synced 2025-06-15 11:01:20 +00:00
refactoring quorum a little bit
This commit is contained in:
@ -15,11 +15,13 @@ data EVMResult:
|
|||||||
stdout: string
|
stdout: string
|
||||||
stderr: string
|
stderr: string
|
||||||
|
|
||||||
service MyOp("op"):
|
service I64ToF64("op"):
|
||||||
array_length(providers: []ProviderInfo) -> i64
|
|
||||||
identity(x: i64) -> f64
|
identity(x: i64) -> f64
|
||||||
|
|
||||||
service MyOp2("op"):
|
service ProviderInfoOp("op"):
|
||||||
|
array_length(providers: []ProviderInfo) -> i64
|
||||||
|
|
||||||
|
service FuncAddrOp("op"):
|
||||||
array_length(providers: []FunctionAddress) -> i64
|
array_length(providers: []FunctionAddress) -> i64
|
||||||
|
|
||||||
service MultiProviderQuery("service-id"):
|
service MultiProviderQuery("service-id"):
|
||||||
@ -31,46 +33,6 @@ service Utilities("service_id"):
|
|||||||
service Console("run-console"):
|
service Console("run-console"):
|
||||||
print(msg: string)
|
print(msg: string)
|
||||||
|
|
||||||
|
|
||||||
func get_block_heights(providers: []ProviderInfo, addrs: []FunctionAddress) -> []EVMResult:
|
|
||||||
result: *EVMResult
|
|
||||||
|
|
||||||
n <- MyOp.array_length(providers)
|
|
||||||
m <- MyOp2.array_length(addrs)
|
|
||||||
|
|
||||||
if n > 0:
|
|
||||||
for addr <- addrs par:
|
|
||||||
on addr.peer_id:
|
|
||||||
MultiProviderQuery addr.service_id
|
|
||||||
for provider <- providers:
|
|
||||||
result <- MultiProviderQuery.get_block_number(provider)
|
|
||||||
join result[n*m-1]
|
|
||||||
<- result
|
|
||||||
|
|
||||||
|
|
||||||
func get_block_height(providers: []ProviderInfo, addr: FunctionAddress) ->[]EVMResult:
|
|
||||||
result: *EVMResult
|
|
||||||
n <- MyOp.array_length(providers)
|
|
||||||
|
|
||||||
if n > 0:
|
|
||||||
on addr.peer_id:
|
|
||||||
MultiProviderQuery addr.service_id
|
|
||||||
for provider <- providers:
|
|
||||||
result <- MultiProviderQuery.get_block_number(provider)
|
|
||||||
join result[n]
|
|
||||||
<- result
|
|
||||||
|
|
||||||
|
|
||||||
func provider_test(providers: []ProviderInfo) -> []string:
|
|
||||||
result: *string
|
|
||||||
n <- MyOp.array_length(providers)
|
|
||||||
|
|
||||||
if n > 0:
|
|
||||||
for provider <- providers:
|
|
||||||
result <<- provider.name
|
|
||||||
join result[n-1]
|
|
||||||
<- result
|
|
||||||
|
|
||||||
alias QuorumService: FunctionAddress
|
alias QuorumService: FunctionAddress
|
||||||
|
|
||||||
data Quorum:
|
data Quorum:
|
||||||
@ -83,13 +45,53 @@ service SimpleQuorum("service-id"):
|
|||||||
point_estimate(data: []EVMResult, min_points: u32) -> Quorum
|
point_estimate(data: []EVMResult, min_points: u32) -> Quorum
|
||||||
is_quorum(x:u64, y:u64, threshold:f64) -> bool
|
is_quorum(x:u64, y:u64, threshold:f64) -> bool
|
||||||
|
|
||||||
|
|
||||||
|
func get_block_heights(providers: []ProviderInfo, addrs: []FunctionAddress) -> []EVMResult:
|
||||||
|
result: *EVMResult
|
||||||
|
|
||||||
|
n <- ProviderInfoOp.array_length(providers)
|
||||||
|
m <- FuncAddrOp.array_length(addrs)
|
||||||
|
|
||||||
|
if n > 0:
|
||||||
|
for addr <- addrs par:
|
||||||
|
on addr.peer_id:
|
||||||
|
MultiProviderQuery addr.service_id
|
||||||
|
for provider <- providers:
|
||||||
|
result <- MultiProviderQuery.get_block_number(provider)
|
||||||
|
join result[n*m-1]
|
||||||
|
<- result
|
||||||
|
|
||||||
|
|
||||||
|
func get_block_height(providers: []ProviderInfo, addr: FunctionAddress) ->[]EVMResult:
|
||||||
|
result: *EVMResult
|
||||||
|
n <- ProviderInfoOp.array_length(providers)
|
||||||
|
|
||||||
|
if n > 0:
|
||||||
|
on addr.peer_id:
|
||||||
|
MultiProviderQuery addr.service_id
|
||||||
|
for provider <- providers:
|
||||||
|
result <- MultiProviderQuery.get_block_number(provider)
|
||||||
|
join result[n]
|
||||||
|
<- result
|
||||||
|
|
||||||
|
|
||||||
|
func provider_test(providers: []ProviderInfo) -> []string:
|
||||||
|
result: *string
|
||||||
|
n <- ProviderInfoOp.array_length(providers)
|
||||||
|
|
||||||
|
if n > 0:
|
||||||
|
for provider <- providers:
|
||||||
|
result <<- provider.name
|
||||||
|
join result[n-1]
|
||||||
|
<- result
|
||||||
|
|
||||||
func get_block_height_raw_quorum(providers: []ProviderInfo, addrs: []FunctionAddress, q_addr: QuorumService) -> Quorum:
|
func get_block_height_raw_quorum(providers: []ProviderInfo, addrs: []FunctionAddress, q_addr: QuorumService) -> Quorum:
|
||||||
result: *EVMResult
|
result: *EVMResult
|
||||||
result2: *string
|
result2: *string
|
||||||
quorum: *Quorum
|
quorum: *Quorum
|
||||||
|
|
||||||
n <- MyOp.array_length(providers)
|
n <- ProviderInfoOp.array_length(providers)
|
||||||
n2 <- MyOp2.array_length(addrs)
|
n2 <- FuncAddrOp.array_length(addrs)
|
||||||
|
|
||||||
if n > 0:
|
if n > 0:
|
||||||
for addr <- addrs par:
|
for addr <- addrs par:
|
||||||
@ -123,8 +125,8 @@ func get_block_height_quorum(providers: []ProviderInfo, addrs: []FunctionAddress
|
|||||||
is_quorum: *bool
|
is_quorum: *bool
|
||||||
min_points = 3 -- minimum points we want in order to calculate an oracle
|
min_points = 3 -- minimum points we want in order to calculate an oracle
|
||||||
|
|
||||||
n <- MyOp.array_length(providers)
|
n <- ProviderInfoOp.array_length(providers)
|
||||||
n2 <- MyOp2.array_length(addrs)
|
n2 <- FuncAddrOp.array_length(addrs)
|
||||||
|
|
||||||
if n > 0:
|
if n > 0:
|
||||||
for addr <- addrs par:
|
for addr <- addrs par:
|
||||||
@ -148,8 +150,8 @@ func get_block_height_quorum_with_mapper(providers: []ProviderInfo, addrs: []Fun
|
|||||||
|
|
||||||
min_points = 3 -- minimum points we want in order to calculate an oracle
|
min_points = 3 -- minimum points we want in order to calculate an oracle
|
||||||
|
|
||||||
n <- MyOp.array_length(providers)
|
n <- ProviderInfoOp.array_length(providers)
|
||||||
n2 <- MyOp2.array_length(addrs)
|
n2 <- FuncAddrOp.array_length(addrs)
|
||||||
|
|
||||||
if n > 0:
|
if n > 0:
|
||||||
for addr <- addrs par:
|
for addr <- addrs par:
|
||||||
@ -206,8 +208,8 @@ func get_block_height_quorum_with_cid(providers: []ProviderInfo, services_cid: I
|
|||||||
q_addrs <- IpfsCli.params_from_cid(quorum_cid.multiaddr, quorum_cid.cid)
|
q_addrs <- IpfsCli.params_from_cid(quorum_cid.multiaddr, quorum_cid.cid)
|
||||||
u_addrs <- IpfsCli.params_from_cid(utility_cid.multiaddr, utility_cid.cid)
|
u_addrs <- IpfsCli.params_from_cid(utility_cid.multiaddr, utility_cid.cid)
|
||||||
|
|
||||||
n <- MyOp.array_length(providers)
|
n <- ProviderInfoOp.array_length(providers)
|
||||||
m <- MyOp2.array_length(addrs)
|
m <- FuncAddrOp.array_length(addrs)
|
||||||
|
|
||||||
if n > 0:
|
if n > 0:
|
||||||
for addr <- addrs par:
|
for addr <- addrs par:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@fluencelabs/aqua-eth-gateway",
|
"name": "@fluencelabs/aqua-eth-gateway",
|
||||||
"version": "0.0.10",
|
"version": "0.0.11",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
Reference in New Issue
Block a user