mirror of
https://github.com/fluencelabs/registry.git
synced 2025-04-24 17:52:14 +00:00
chore: archive registry example (#312)
* Half-update and archive registry example * Rename folder
This commit is contained in:
parent
633d8e6648
commit
01d8cb4052
2
.gitignore
vendored
2
.gitignore
vendored
@ -15,7 +15,7 @@ distro/registry-service/
|
|||||||
*.drawio
|
*.drawio
|
||||||
|
|
||||||
aqua/*.tgz
|
aqua/*.tgz
|
||||||
example/src/generated/**
|
examples/src/generated/**
|
||||||
|
|
||||||
**/__pycache__
|
**/__pycache__
|
||||||
tmp
|
tmp
|
||||||
|
744
aqua/target/typescript/misc.ts
Normal file
744
aqua/target/typescript/misc.ts
Normal file
@ -0,0 +1,744 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is auto-generated. Do not edit manually: changes may be erased.
|
||||||
|
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
|
||||||
|
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
|
||||||
|
* Aqua version: 0.11.9-release-please-1c9388a-1275-1
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
import type { IFluenceClient as IFluenceClient$$, CallParams as CallParams$$ } from '@fluencelabs/js-client.api';
|
||||||
|
import {
|
||||||
|
v5_callFunction as callFunction$$,
|
||||||
|
v5_registerService as registerService$$,
|
||||||
|
} from '@fluencelabs/js-client.api';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Services
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
export const getResourceHelper_script = `
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "resource_id") [] resource_id)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(new $resources
|
||||||
|
(new $successful
|
||||||
|
(new $result
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("op" "string_to_b58") [resource_id] k)
|
||||||
|
(call %init_peer_id% ("kad" "neighborhood") [k [] []] nodes)
|
||||||
|
)
|
||||||
|
(par
|
||||||
|
(fold nodes n-0
|
||||||
|
(par
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(new $-ephemeral-stream-
|
||||||
|
(new #-ephemeral-canon-
|
||||||
|
(canon -relay- $-ephemeral-stream- #-ephemeral-canon-)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(call n-0 ("registry" "get_key_metadata") [resource_id] get_result)
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(match get_result.$.success true
|
||||||
|
(seq
|
||||||
|
(ap get_result.$.key $resources)
|
||||||
|
(ap true $successful)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(new $-ephemeral-stream-
|
||||||
|
(new #-ephemeral-canon-
|
||||||
|
(canon -relay- $-ephemeral-stream- #-ephemeral-canon-)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(new $-ephemeral-stream-
|
||||||
|
(new #-ephemeral-canon-
|
||||||
|
(canon %init_peer_id% $-ephemeral-stream- #-ephemeral-canon-)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call n-0 ("op" "concat_strings") [get_result.$.error " on "] e)
|
||||||
|
(call n-0 ("op" "concat_strings") [e n-0] $error)
|
||||||
|
)
|
||||||
|
(new $-ephemeral-stream-
|
||||||
|
(new #-ephemeral-canon-
|
||||||
|
(canon -relay- $-ephemeral-stream- #-ephemeral-canon-)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(new $-ephemeral-stream-
|
||||||
|
(new #-ephemeral-canon-
|
||||||
|
(canon %init_peer_id% $-ephemeral-stream- #-ephemeral-canon-)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(null)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(new $-ephemeral-stream-
|
||||||
|
(new #-ephemeral-canon-
|
||||||
|
(canon -relay- $-ephemeral-stream- #-ephemeral-canon-)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(new $-ephemeral-stream-
|
||||||
|
(new #-ephemeral-canon-
|
||||||
|
(canon %init_peer_id% $-ephemeral-stream- #-ephemeral-canon-)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(fail %last_error%)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(next n-0)
|
||||||
|
)
|
||||||
|
(never)
|
||||||
|
)
|
||||||
|
(null)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(new $status
|
||||||
|
(new $result-0
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(par
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("math" "sub") [1 1] sub)
|
||||||
|
(new $successful_test
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("math" "add") [sub 1] successful_incr)
|
||||||
|
(fold $successful successful_fold_var
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(ap successful_fold_var $successful_test)
|
||||||
|
(canon %init_peer_id% $successful_test #successful_iter_canon)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(match #successful_iter_canon.length successful_incr
|
||||||
|
(null)
|
||||||
|
)
|
||||||
|
(next successful_fold_var)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(never)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(canon %init_peer_id% $successful_test #successful_result_canon)
|
||||||
|
)
|
||||||
|
(ap #successful_result_canon successful_gate)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("math" "sub") [1 1] sub-0)
|
||||||
|
)
|
||||||
|
(ap "ok" $status)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("peer" "timeout") [6000 "timeout"] $status)
|
||||||
|
)
|
||||||
|
(new $status_test
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("math" "add") [0 1] status_incr)
|
||||||
|
(fold $status status_fold_var
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(ap status_fold_var $status_test)
|
||||||
|
(canon %init_peer_id% $status_test #status_iter_canon)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(match #status_iter_canon.length status_incr
|
||||||
|
(null)
|
||||||
|
)
|
||||||
|
(next status_fold_var)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(never)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(canon %init_peer_id% $status_test #status_result_canon)
|
||||||
|
)
|
||||||
|
(ap #status_result_canon status_gate)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(match status_gate.$.[0] "ok"
|
||||||
|
(ap true $result-0)
|
||||||
|
)
|
||||||
|
(ap false $result-0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(new $result-0_test
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("math" "add") [0 1] result-0_incr)
|
||||||
|
(fold $result-0 result-0_fold_var
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(ap result-0_fold_var $result-0_test)
|
||||||
|
(canon %init_peer_id% $result-0_test #result-0_iter_canon)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(match #result-0_iter_canon.length result-0_incr
|
||||||
|
(null)
|
||||||
|
)
|
||||||
|
(next result-0_fold_var)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(never)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(canon %init_peer_id% $result-0_test #result-0_result_canon)
|
||||||
|
)
|
||||||
|
(ap #result-0_result_canon result-0_gate)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(match result-0_gate.$.[0] false
|
||||||
|
(ap "resource not found: timeout exceeded" $error)
|
||||||
|
)
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(canon %init_peer_id% $resources #resources_canon)
|
||||||
|
(call %init_peer_id% ("registry" "merge_keys") [#resources_canon] merge_result)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(match merge_result.$.success true
|
||||||
|
(ap merge_result.$.key $result)
|
||||||
|
)
|
||||||
|
(ap merge_result.$.error $error)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(canon %init_peer_id% $result #-result-fix-0)
|
||||||
|
)
|
||||||
|
(ap #-result-fix-0 -result-flat-0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 0])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(canon %init_peer_id% $error #error_canon)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("callbackSrv" "response") [-result-flat-0 #error_canon])
|
||||||
|
)
|
||||||
|
`
|
||||||
|
|
||||||
|
export type GetResourceHelperResult = [{ challenge: number[]; challenge_type: string; id: string; label: string; owner_peer_id: string; signature: number[]; timestamp_created: number; } | null, string[]]
|
||||||
|
export function getResourceHelper(
|
||||||
|
resource_id: string,
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<GetResourceHelperResult>;
|
||||||
|
|
||||||
|
export function getResourceHelper(
|
||||||
|
peer: IFluenceClient$$,
|
||||||
|
resource_id: string,
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<GetResourceHelperResult>;
|
||||||
|
|
||||||
|
export function getResourceHelper(...args: any) {
|
||||||
|
|
||||||
|
|
||||||
|
return callFunction$$(
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
"functionName" : "getResourceHelper",
|
||||||
|
"arrow" : {
|
||||||
|
"tag" : "arrow",
|
||||||
|
"domain" : {
|
||||||
|
"tag" : "labeledProduct",
|
||||||
|
"fields" : {
|
||||||
|
"resource_id" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"codomain" : {
|
||||||
|
"tag" : "unlabeledProduct",
|
||||||
|
"items" : [
|
||||||
|
{
|
||||||
|
"tag" : "option",
|
||||||
|
"type" : {
|
||||||
|
"tag" : "struct",
|
||||||
|
"name" : "Key",
|
||||||
|
"fields" : {
|
||||||
|
"challenge" : {
|
||||||
|
"tag" : "array",
|
||||||
|
"type" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "u8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"label" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "string"
|
||||||
|
},
|
||||||
|
"signature" : {
|
||||||
|
"tag" : "array",
|
||||||
|
"type" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "u8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "string"
|
||||||
|
},
|
||||||
|
"owner_peer_id" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "string"
|
||||||
|
},
|
||||||
|
"challenge_type" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "string"
|
||||||
|
},
|
||||||
|
"timestamp_created" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "u64"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag" : "array",
|
||||||
|
"type" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"names" : {
|
||||||
|
"relay" : "-relay-",
|
||||||
|
"getDataSrv" : "getDataSrv",
|
||||||
|
"callbackSrv" : "callbackSrv",
|
||||||
|
"responseSrv" : "callbackSrv",
|
||||||
|
"responseFnName" : "response",
|
||||||
|
"errorHandlingSrv" : "errorHandlingSrv",
|
||||||
|
"errorFnName" : "error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getResourceHelper_script
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const appendErrors_script = `
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "error1") [] error1-iter)
|
||||||
|
)
|
||||||
|
(fold error1-iter error1-item-0
|
||||||
|
(seq
|
||||||
|
(ap error1-item-0 $error1)
|
||||||
|
(next error1-item-0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "error2") [] error2-iter)
|
||||||
|
)
|
||||||
|
(fold error2-iter error2-item-0
|
||||||
|
(seq
|
||||||
|
(ap error2-item-0 $error2)
|
||||||
|
(next error2-item-0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(canon %init_peer_id% $error2 #error2_canon)
|
||||||
|
(fold #error2_canon e-0
|
||||||
|
(seq
|
||||||
|
(ap e-0 $error1-0)
|
||||||
|
(next e-0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 0])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
`
|
||||||
|
|
||||||
|
|
||||||
|
export function appendErrors(
|
||||||
|
error1: string[],
|
||||||
|
error2: string[],
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<void>;
|
||||||
|
|
||||||
|
export function appendErrors(
|
||||||
|
peer: IFluenceClient$$,
|
||||||
|
error1: string[],
|
||||||
|
error2: string[],
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<void>;
|
||||||
|
|
||||||
|
export function appendErrors(...args: any) {
|
||||||
|
|
||||||
|
|
||||||
|
return callFunction$$(
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
"functionName" : "appendErrors",
|
||||||
|
"arrow" : {
|
||||||
|
"tag" : "arrow",
|
||||||
|
"domain" : {
|
||||||
|
"tag" : "labeledProduct",
|
||||||
|
"fields" : {
|
||||||
|
"error1" : {
|
||||||
|
"tag" : "array",
|
||||||
|
"type" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"error2" : {
|
||||||
|
"tag" : "array",
|
||||||
|
"type" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"codomain" : {
|
||||||
|
"tag" : "nil"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"names" : {
|
||||||
|
"relay" : "-relay-",
|
||||||
|
"getDataSrv" : "getDataSrv",
|
||||||
|
"callbackSrv" : "callbackSrv",
|
||||||
|
"responseSrv" : "callbackSrv",
|
||||||
|
"responseFnName" : "response",
|
||||||
|
"errorHandlingSrv" : "errorHandlingSrv",
|
||||||
|
"errorFnName" : "error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
appendErrors_script
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getNeighbors_script = `
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "resource_id") [] resource_id)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("op" "string_to_b58") [resource_id] k)
|
||||||
|
(call %init_peer_id% ("kad" "neighborhood") [k [] []] nodes)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 0])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("callbackSrv" "response") [nodes])
|
||||||
|
)
|
||||||
|
`
|
||||||
|
|
||||||
|
|
||||||
|
export function getNeighbors(
|
||||||
|
resource_id: string,
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<string[]>;
|
||||||
|
|
||||||
|
export function getNeighbors(
|
||||||
|
peer: IFluenceClient$$,
|
||||||
|
resource_id: string,
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<string[]>;
|
||||||
|
|
||||||
|
export function getNeighbors(...args: any) {
|
||||||
|
|
||||||
|
|
||||||
|
return callFunction$$(
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
"functionName" : "getNeighbors",
|
||||||
|
"arrow" : {
|
||||||
|
"tag" : "arrow",
|
||||||
|
"domain" : {
|
||||||
|
"tag" : "labeledProduct",
|
||||||
|
"fields" : {
|
||||||
|
"resource_id" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"codomain" : {
|
||||||
|
"tag" : "unlabeledProduct",
|
||||||
|
"items" : [
|
||||||
|
{
|
||||||
|
"tag" : "array",
|
||||||
|
"type" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"names" : {
|
||||||
|
"relay" : "-relay-",
|
||||||
|
"getDataSrv" : "getDataSrv",
|
||||||
|
"callbackSrv" : "callbackSrv",
|
||||||
|
"responseSrv" : "callbackSrv",
|
||||||
|
"responseFnName" : "response",
|
||||||
|
"errorHandlingSrv" : "errorHandlingSrv",
|
||||||
|
"errorFnName" : "error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getNeighbors_script
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const wait_script = `
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "successful") [] successful-iter)
|
||||||
|
)
|
||||||
|
(fold successful-iter successful-item-0
|
||||||
|
(seq
|
||||||
|
(ap successful-item-0 $successful)
|
||||||
|
(next successful-item-0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "len") [] len)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("getDataSrv" "timeout") [] timeout)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(new $status
|
||||||
|
(new $result
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(par
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("math" "sub") [len 1] sub)
|
||||||
|
(new $successful_test
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("math" "add") [sub 1] successful_incr)
|
||||||
|
(fold $successful successful_fold_var
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(ap successful_fold_var $successful_test)
|
||||||
|
(canon %init_peer_id% $successful_test #successful_iter_canon)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(match #successful_iter_canon.length successful_incr
|
||||||
|
(null)
|
||||||
|
)
|
||||||
|
(next successful_fold_var)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(never)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(canon %init_peer_id% $successful_test #successful_result_canon)
|
||||||
|
)
|
||||||
|
(ap #successful_result_canon successful_gate)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("math" "sub") [len 1] sub-0)
|
||||||
|
)
|
||||||
|
(ap "ok" $status)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("peer" "timeout") [timeout "timeout"] $status)
|
||||||
|
)
|
||||||
|
(new $status_test
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("math" "add") [0 1] status_incr)
|
||||||
|
(fold $status status_fold_var
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(ap status_fold_var $status_test)
|
||||||
|
(canon %init_peer_id% $status_test #status_iter_canon)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(match #status_iter_canon.length status_incr
|
||||||
|
(null)
|
||||||
|
)
|
||||||
|
(next status_fold_var)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(never)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(canon %init_peer_id% $status_test #status_result_canon)
|
||||||
|
)
|
||||||
|
(ap #status_result_canon status_gate)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(match status_gate.$.[0] "ok"
|
||||||
|
(ap true $result)
|
||||||
|
)
|
||||||
|
(ap false $result)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(new $result_test
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("math" "add") [0 1] result_incr)
|
||||||
|
(fold $result result_fold_var
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(ap result_fold_var $result_test)
|
||||||
|
(canon %init_peer_id% $result_test #result_iter_canon)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(match #result_iter_canon.length result_incr
|
||||||
|
(null)
|
||||||
|
)
|
||||||
|
(next result_fold_var)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(never)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(canon %init_peer_id% $result_test #result_result_canon)
|
||||||
|
)
|
||||||
|
(ap #result_result_canon result_gate)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 0])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("callbackSrv" "response") [result_gate.$.[0]])
|
||||||
|
)
|
||||||
|
`
|
||||||
|
|
||||||
|
|
||||||
|
export function wait(
|
||||||
|
successful: boolean[],
|
||||||
|
len: number,
|
||||||
|
timeout: number,
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<boolean>;
|
||||||
|
|
||||||
|
export function wait(
|
||||||
|
peer: IFluenceClient$$,
|
||||||
|
successful: boolean[],
|
||||||
|
len: number,
|
||||||
|
timeout: number,
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<boolean>;
|
||||||
|
|
||||||
|
export function wait(...args: any) {
|
||||||
|
|
||||||
|
|
||||||
|
return callFunction$$(
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
"functionName" : "wait",
|
||||||
|
"arrow" : {
|
||||||
|
"tag" : "arrow",
|
||||||
|
"domain" : {
|
||||||
|
"tag" : "labeledProduct",
|
||||||
|
"fields" : {
|
||||||
|
"successful" : {
|
||||||
|
"tag" : "array",
|
||||||
|
"type" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "bool"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"len" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "i16"
|
||||||
|
},
|
||||||
|
"timeout" : {
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "u16"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"codomain" : {
|
||||||
|
"tag" : "unlabeledProduct",
|
||||||
|
"items" : [
|
||||||
|
{
|
||||||
|
"tag" : "scalar",
|
||||||
|
"name" : "bool"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"names" : {
|
||||||
|
"relay" : "-relay-",
|
||||||
|
"getDataSrv" : "getDataSrv",
|
||||||
|
"callbackSrv" : "callbackSrv",
|
||||||
|
"responseSrv" : "callbackSrv",
|
||||||
|
"responseFnName" : "response",
|
||||||
|
"errorHandlingSrv" : "errorHandlingSrv",
|
||||||
|
"errorFnName" : "error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
wait_script
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* eslint-enable */
|
1341
aqua/target/typescript/registry-api.ts
Normal file
1341
aqua/target/typescript/registry-api.ts
Normal file
File diff suppressed because it is too large
Load Diff
322
aqua/target/typescript/registry-scheduled-scripts.ts
Normal file
322
aqua/target/typescript/registry-scheduled-scripts.ts
Normal file
@ -0,0 +1,322 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is auto-generated. Do not edit manually: changes may be erased.
|
||||||
|
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
|
||||||
|
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
|
||||||
|
* Aqua version: 0.11.9-release-please-1c9388a-1275-1
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
import type { IFluenceClient as IFluenceClient$$, CallParams as CallParams$$ } from '@fluencelabs/js-client.api';
|
||||||
|
import {
|
||||||
|
v5_callFunction as callFunction$$,
|
||||||
|
v5_registerService as registerService$$,
|
||||||
|
} from '@fluencelabs/js-client.api';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Services
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
export const replicate_3600_script = `
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||||
|
(xor
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call -relay- ("peer" "timestamp_sec") [] t)
|
||||||
|
(call -relay- ("registry" "evict_stale") [t] res)
|
||||||
|
)
|
||||||
|
(par
|
||||||
|
(fold res.$.results r-0
|
||||||
|
(par
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call -relay- ("op" "string_to_b58") [r-0.$.key.id] k)
|
||||||
|
(call -relay- ("kad" "neighborhood") [k [] []] nodes)
|
||||||
|
)
|
||||||
|
(par
|
||||||
|
(fold nodes n-0
|
||||||
|
(par
|
||||||
|
(new $records_weights
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call n-0 ("peer" "timestamp_sec") [] tt)
|
||||||
|
(call n-0 ("trust-graph" "get_weight") [r-0.$.key.owner_peer_id tt] key_weight)
|
||||||
|
)
|
||||||
|
(call n-0 ("registry" "republish_key") [r-0.$.key key_weight tt])
|
||||||
|
)
|
||||||
|
(fold r-0.$.records record-0
|
||||||
|
(seq
|
||||||
|
(call n-0 ("trust-graph" "get_weight") [record-0.$.metadata.issued_by tt] $records_weights)
|
||||||
|
(next record-0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(canon n-0 $records_weights #records_weights_canon)
|
||||||
|
)
|
||||||
|
(call n-0 ("registry" "republish_records") [r-0.$.records #records_weights_canon tt])
|
||||||
|
)
|
||||||
|
(fail %last_error%)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(next n-0)
|
||||||
|
)
|
||||||
|
(never)
|
||||||
|
)
|
||||||
|
(null)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(next r-0)
|
||||||
|
)
|
||||||
|
(never)
|
||||||
|
)
|
||||||
|
(null)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(fail %last_error%)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 0])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
`
|
||||||
|
|
||||||
|
|
||||||
|
export function replicate_3600(
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<void>;
|
||||||
|
|
||||||
|
export function replicate_3600(
|
||||||
|
peer: IFluenceClient$$,
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<void>;
|
||||||
|
|
||||||
|
export function replicate_3600(...args: any) {
|
||||||
|
|
||||||
|
|
||||||
|
return callFunction$$(
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
"functionName" : "replicate_3600",
|
||||||
|
"arrow" : {
|
||||||
|
"tag" : "arrow",
|
||||||
|
"domain" : {
|
||||||
|
"tag" : "labeledProduct",
|
||||||
|
"fields" : {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"codomain" : {
|
||||||
|
"tag" : "nil"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"names" : {
|
||||||
|
"relay" : "-relay-",
|
||||||
|
"getDataSrv" : "getDataSrv",
|
||||||
|
"callbackSrv" : "callbackSrv",
|
||||||
|
"responseSrv" : "callbackSrv",
|
||||||
|
"responseFnName" : "response",
|
||||||
|
"errorHandlingSrv" : "errorHandlingSrv",
|
||||||
|
"errorFnName" : "error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
replicate_3600_script
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const clearExpired_86400_script = `
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||||
|
(xor
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(call -relay- ("peer" "timestamp_sec") [] t)
|
||||||
|
(call -relay- ("registry" "clear_expired") [t])
|
||||||
|
)
|
||||||
|
(fail %last_error%)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 0])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
`
|
||||||
|
|
||||||
|
|
||||||
|
export function clearExpired_86400(
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<void>;
|
||||||
|
|
||||||
|
export function clearExpired_86400(
|
||||||
|
peer: IFluenceClient$$,
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<void>;
|
||||||
|
|
||||||
|
export function clearExpired_86400(...args: any) {
|
||||||
|
|
||||||
|
|
||||||
|
return callFunction$$(
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
"functionName" : "clearExpired_86400",
|
||||||
|
"arrow" : {
|
||||||
|
"tag" : "arrow",
|
||||||
|
"domain" : {
|
||||||
|
"tag" : "labeledProduct",
|
||||||
|
"fields" : {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"codomain" : {
|
||||||
|
"tag" : "nil"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"names" : {
|
||||||
|
"relay" : "-relay-",
|
||||||
|
"getDataSrv" : "getDataSrv",
|
||||||
|
"callbackSrv" : "callbackSrv",
|
||||||
|
"responseSrv" : "callbackSrv",
|
||||||
|
"responseFnName" : "response",
|
||||||
|
"errorHandlingSrv" : "errorHandlingSrv",
|
||||||
|
"errorFnName" : "error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
clearExpired_86400_script
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const renew_43200_script = `
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||||
|
(xor
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call -relay- ("peer" "timestamp_sec") [] t)
|
||||||
|
(call -relay- ("registry" "get_stale_local_records") [t] res)
|
||||||
|
)
|
||||||
|
(par
|
||||||
|
(fold res.$.result r-0
|
||||||
|
(par
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(new $signature
|
||||||
|
(seq
|
||||||
|
(xor
|
||||||
|
(mismatch r-0.$.metadata.peer_id %init_peer_id%
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(call r-0.$.metadata.peer_id ("registry" "get_record_bytes") [r-0.$.metadata t] bytes)
|
||||||
|
(call r-0.$.metadata.peer_id ("sig" "sign") [bytes] $signature)
|
||||||
|
)
|
||||||
|
(fail %last_error%)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(call -relay- ("registry" "get_record_bytes") [r-0.$.metadata t] bytess)
|
||||||
|
(xor
|
||||||
|
(call %init_peer_id% ("sig" "sign") [bytess] $signature)
|
||||||
|
(fail %last_error%)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(fail %last_error%)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(new $signature_test
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call -relay- ("math" "add") [0 1] signature_incr)
|
||||||
|
(fold $signature signature_fold_var
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(ap signature_fold_var $signature_test)
|
||||||
|
(canon -relay- $signature_test #signature_iter_canon)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(match #signature_iter_canon.length signature_incr
|
||||||
|
(null)
|
||||||
|
)
|
||||||
|
(next signature_fold_var)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(never)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(canon -relay- $signature_test #signature_result_canon)
|
||||||
|
)
|
||||||
|
(ap #signature_result_canon signature_gate)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call -relay- ("peer" "timestamp_sec") [] t-0)
|
||||||
|
)
|
||||||
|
(call -relay- ("trust-graph" "get_weight") [r-0.$.metadata.issued_by t-0] weight)
|
||||||
|
)
|
||||||
|
(call -relay- ("registry" "put_record") [r-0.$.metadata t signature_gate.$.[0].signature.[0] weight t-0] result)
|
||||||
|
)
|
||||||
|
(next r-0)
|
||||||
|
)
|
||||||
|
(never)
|
||||||
|
)
|
||||||
|
(null)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(fail %last_error%)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 0])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
`
|
||||||
|
|
||||||
|
|
||||||
|
export function renew_43200(
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<void>;
|
||||||
|
|
||||||
|
export function renew_43200(
|
||||||
|
peer: IFluenceClient$$,
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<void>;
|
||||||
|
|
||||||
|
export function renew_43200(...args: any) {
|
||||||
|
|
||||||
|
|
||||||
|
return callFunction$$(
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
"functionName" : "renew_43200",
|
||||||
|
"arrow" : {
|
||||||
|
"tag" : "arrow",
|
||||||
|
"domain" : {
|
||||||
|
"tag" : "labeledProduct",
|
||||||
|
"fields" : {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"codomain" : {
|
||||||
|
"tag" : "nil"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"names" : {
|
||||||
|
"relay" : "-relay-",
|
||||||
|
"getDataSrv" : "getDataSrv",
|
||||||
|
"callbackSrv" : "callbackSrv",
|
||||||
|
"responseSrv" : "callbackSrv",
|
||||||
|
"responseFnName" : "response",
|
||||||
|
"errorHandlingSrv" : "errorHandlingSrv",
|
||||||
|
"errorFnName" : "error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
renew_43200_script
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* eslint-enable */
|
8
example/.gitignore
vendored
8
example/.gitignore
vendored
@ -1,8 +0,0 @@
|
|||||||
.idea
|
|
||||||
.DS_Store
|
|
||||||
.fluence
|
|
||||||
**/node_modules
|
|
||||||
**/target/
|
|
||||||
.repl_history
|
|
||||||
generated
|
|
||||||
.vscode/settings.json
|
|
@ -1,5 +0,0 @@
|
|||||||
# yaml-language-server: $schema=../../../.fluence/schemas/module.yaml.json
|
|
||||||
|
|
||||||
version: 0
|
|
||||||
type: rust
|
|
||||||
name: echo_service
|
|
@ -1,7 +0,0 @@
|
|||||||
# yaml-language-server: $schema=../.fluence/schemas/service.yaml.json
|
|
||||||
|
|
||||||
version: 0
|
|
||||||
name: echo_service
|
|
||||||
modules:
|
|
||||||
facade:
|
|
||||||
get: modules/echo_service
|
|
@ -1,21 +0,0 @@
|
|||||||
# yaml-language-server: $schema=.fluence/schemas/fluence.yaml.json
|
|
||||||
|
|
||||||
version: 2
|
|
||||||
|
|
||||||
services:
|
|
||||||
echo_service:
|
|
||||||
get: ./echo_service
|
|
||||||
deploy:
|
|
||||||
- deployId: default
|
|
||||||
|
|
||||||
dependencies:
|
|
||||||
npm:
|
|
||||||
"@fluencelabs/aqua": 0.9.2
|
|
||||||
"@fluencelabs/registry": 0.6.2
|
|
||||||
"@fluencelabs/aqua-lib": 0.7.0
|
|
||||||
cargo:
|
|
||||||
marine: 0.12.4
|
|
||||||
mrepl: 0.18.6
|
|
||||||
|
|
||||||
relays:
|
|
||||||
- /dns4/stage.fluence.dev/tcp/19002/wss/p2p/12D3KooWMigkP4jkVyufq5JnDJL6nXvyjeaDNpRfEZqQhsG3sYCU
|
|
11841
example/package-lock.json
generated
11841
example/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "echo",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"description": "Fluence Peer with echo service",
|
|
||||||
"scripts": {
|
|
||||||
"compile-aqua": "fluence aqua -i ./src/aqua/export.aqua -o ./src/generated",
|
|
||||||
"start": "npm run compile-aqua && npx ts-node src/echo.ts"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"aqua",
|
|
||||||
"dht",
|
|
||||||
"p2p"
|
|
||||||
],
|
|
||||||
"author": "Fluence Labs",
|
|
||||||
"dependencies": {
|
|
||||||
"@fluencelabs/fluence": "0.28.0",
|
|
||||||
"@fluencelabs/fluence-network-environment": "1.1.2",
|
|
||||||
"@fluencelabs/trust-graph": "3.1.2"
|
|
||||||
},
|
|
||||||
"prettier": {}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
module Main
|
|
||||||
|
|
||||||
export and
|
|
||||||
|
|
||||||
|
|
||||||
func and(l: bool, r: bool) -> bool:
|
|
||||||
res: ?bool
|
|
||||||
if l:
|
|
||||||
res <<- r
|
|
||||||
else:
|
|
||||||
res <<- false
|
|
||||||
<- res!
|
|
||||||
|
|
||||||
func or(l: bool, r: bool) -> bool:
|
|
||||||
res: ?bool
|
|
||||||
if l:
|
|
||||||
res <<- true
|
|
||||||
else:
|
|
||||||
res <<- r
|
|
||||||
<- res!
|
|
||||||
|
|
||||||
func not(u: bool) -> bool:
|
|
||||||
res: ?bool
|
|
||||||
if u:
|
|
||||||
res <<- false
|
|
||||||
else:
|
|
||||||
res <<- true
|
|
||||||
<- res!
|
|
24
examples/archived/1-registry/.fluence/aqua/deals.aqua
Normal file
24
examples/archived/1-registry/.fluence/aqua/deals.aqua
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
aqua Deals declares *
|
||||||
|
|
||||||
|
data Deal:
|
||||||
|
definition: string
|
||||||
|
timestamp: string
|
||||||
|
dealIdOriginal: string
|
||||||
|
dealId: string
|
||||||
|
chainNetwork: string
|
||||||
|
chainNetworkId: u64
|
||||||
|
|
||||||
|
data Deals:
|
||||||
|
dealName: ?Deal
|
||||||
|
|
||||||
|
func get() -> Deals:
|
||||||
|
<- Deals(
|
||||||
|
dealName=?[Deal(
|
||||||
|
definition="bafkreidqtqpmmferdscg4bqrs74cl6ckib3vyhvejhrc4watln5xxcrj2i",
|
||||||
|
timestamp="2023-12-19T20:01:24.334Z",
|
||||||
|
dealIdOriginal="0xEb92A1B5c10AD7BFdcaf23Cb7DDA9ea062CD07E8",
|
||||||
|
dealId="eb92a1b5c10ad7bfdcaf23cb7dda9ea062cd07e8",
|
||||||
|
chainNetwork="local",
|
||||||
|
chainNetworkId=31337
|
||||||
|
)]
|
||||||
|
)
|
4
examples/archived/1-registry/.fluence/aqua/hosts.aqua
Normal file
4
examples/archived/1-registry/.fluence/aqua/hosts.aqua
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
aqua Hosts declares *
|
||||||
|
|
||||||
|
func get() -> ?u8:
|
||||||
|
<- nil
|
2
examples/archived/1-registry/.fluence/aqua/services.aqua
Normal file
2
examples/archived/1-registry/.fluence/aqua/services.aqua
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
service EchoService("echo_service"):
|
||||||
|
echo(msg: string) -> string
|
@ -0,0 +1,20 @@
|
|||||||
|
aquavm_pool_size = 2
|
||||||
|
tcp_port = 7_771
|
||||||
|
websocket_port = 9_991
|
||||||
|
http_port = 18_080
|
||||||
|
|
||||||
|
[system_services]
|
||||||
|
enable = [ "registry", "decider" ]
|
||||||
|
|
||||||
|
[system_services.aqua_ipfs]
|
||||||
|
external_api_multiaddr = "/ip4/127.0.0.1/tcp/5001"
|
||||||
|
local_api_multiaddr = "/dns4/ipfs/tcp/5001"
|
||||||
|
|
||||||
|
[system_services.decider]
|
||||||
|
decider_period_sec = 10
|
||||||
|
worker_ipfs_multiaddr = "/dns4/ipfs/tcp/5001"
|
||||||
|
network_api_endpoint = "http://chain:8545"
|
||||||
|
network_id = 31_337
|
||||||
|
start_block = "earliest"
|
||||||
|
matcher_address = "0x0e1F3B362E22B2Dc82C9E35d6e62998C7E8e2349"
|
||||||
|
wallet_key = "0x3cc23e0227bd17ea5d6ea9d42b5eaa53ad41b1974de4755c79fe236d361a6fd5"
|
@ -0,0 +1,20 @@
|
|||||||
|
aquavm_pool_size = 2
|
||||||
|
tcp_port = 7_772
|
||||||
|
websocket_port = 9_992
|
||||||
|
http_port = 18_081
|
||||||
|
|
||||||
|
[system_services]
|
||||||
|
enable = [ "registry", "decider" ]
|
||||||
|
|
||||||
|
[system_services.aqua_ipfs]
|
||||||
|
external_api_multiaddr = "/ip4/127.0.0.1/tcp/5001"
|
||||||
|
local_api_multiaddr = "/dns4/ipfs/tcp/5001"
|
||||||
|
|
||||||
|
[system_services.decider]
|
||||||
|
decider_period_sec = 10
|
||||||
|
worker_ipfs_multiaddr = "/dns4/ipfs/tcp/5001"
|
||||||
|
network_api_endpoint = "http://chain:8545"
|
||||||
|
network_id = 31_337
|
||||||
|
start_block = "earliest"
|
||||||
|
matcher_address = "0x0e1F3B362E22B2Dc82C9E35d6e62998C7E8e2349"
|
||||||
|
wallet_key = "0x089162470bcfc93192b95bff0a1860d063266875c782af9d882fcca125323b41"
|
@ -0,0 +1,20 @@
|
|||||||
|
aquavm_pool_size = 2
|
||||||
|
tcp_port = 7_773
|
||||||
|
websocket_port = 9_993
|
||||||
|
http_port = 18_082
|
||||||
|
|
||||||
|
[system_services]
|
||||||
|
enable = [ "registry", "decider" ]
|
||||||
|
|
||||||
|
[system_services.aqua_ipfs]
|
||||||
|
external_api_multiaddr = "/ip4/127.0.0.1/tcp/5001"
|
||||||
|
local_api_multiaddr = "/dns4/ipfs/tcp/5001"
|
||||||
|
|
||||||
|
[system_services.decider]
|
||||||
|
decider_period_sec = 10
|
||||||
|
worker_ipfs_multiaddr = "/dns4/ipfs/tcp/5001"
|
||||||
|
network_api_endpoint = "http://chain:8545"
|
||||||
|
network_id = 31_337
|
||||||
|
start_block = "earliest"
|
||||||
|
matcher_address = "0x0e1F3B362E22B2Dc82C9E35d6e62998C7E8e2349"
|
||||||
|
wallet_key = "0xdacd4b197ee7e9efdd5db1921c6c558d88e2c8b69902b8bafc812fb226a6b5e0"
|
102
examples/archived/1-registry/.fluence/docker-compose.yaml
Normal file
102
examples/archived/1-registry/.fluence/docker-compose.yaml
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
# yaml-language-server: $schema=schemas/docker-compose.json
|
||||||
|
|
||||||
|
# Defines a multi-containers based application.
|
||||||
|
|
||||||
|
# Documentation: https://github.com/fluencelabs/cli/tree/main/docs/configs/docker-compose.md
|
||||||
|
|
||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
chain:
|
||||||
|
image: fluencelabs/chain-rpc:0.2.20
|
||||||
|
ports:
|
||||||
|
- 8545:8545
|
||||||
|
ipfs:
|
||||||
|
image: ipfs/go-ipfs
|
||||||
|
ports:
|
||||||
|
- 5001:5001
|
||||||
|
- 4001:4001
|
||||||
|
environment:
|
||||||
|
IPFS_PROFILE: server
|
||||||
|
volumes:
|
||||||
|
- ./ipfs/:/container-init.d/
|
||||||
|
nox-0:
|
||||||
|
image: fluencelabs/nox:0.16.3
|
||||||
|
pull_policy: always
|
||||||
|
ports:
|
||||||
|
- 7771:7771
|
||||||
|
- 9991:9991
|
||||||
|
environment:
|
||||||
|
WASM_LOG: info
|
||||||
|
RUST_LOG: debug,particle_reap=debug,aquamarine=warn,aquamarine::particle_functions=debug,aquamarine::log=debug,aquamarine::aqua_runtime=error,ipfs_effector=off,ipfs_pure=off,system_services=debug,marine_core::module::marine_module=info,tokio_threadpool=info,tokio_reactor=info,mio=info,tokio_io=info,soketto=info,yamux=info,multistream_select=info,libp2p_secio=info,libp2p_websocket::framed=info,libp2p_ping=info,libp2p_core::upgrade::apply=info,libp2p_kad::kbucket=info,cranelift_codegen=info,wasmer_wasi=info,cranelift_codegen=info,wasmer_wasi=info,run-console=trace,wasmtime_cranelift=off,wasmtime_jit=off,libp2p_tcp=off,libp2p_swarm=off,particle_protocol::libp2p_protocol::upgrade=info,libp2p_mplex=off,particle_reap=off,netlink_proto=warn
|
||||||
|
FLUENCE_MAX_SPELL_PARTICLE_TTL: 9s
|
||||||
|
FLUENCE_ROOT_KEY_PAIR__PATH: /run/secrets/nox-0
|
||||||
|
command:
|
||||||
|
- --config=/run/configs/nox-0_Config.toml
|
||||||
|
- --external-maddrs
|
||||||
|
- /dns4/nox-0/tcp/7771
|
||||||
|
- /dns4/nox-0/tcp/9991/ws
|
||||||
|
- --allow-private-ips
|
||||||
|
- --local
|
||||||
|
depends_on:
|
||||||
|
- ipfs
|
||||||
|
volumes:
|
||||||
|
- ./configs/nox-0_Config.toml:/run/configs/nox-0_Config.toml
|
||||||
|
secrets:
|
||||||
|
- nox-0
|
||||||
|
nox-1:
|
||||||
|
image: fluencelabs/nox:0.16.3
|
||||||
|
pull_policy: always
|
||||||
|
ports:
|
||||||
|
- 7772:7772
|
||||||
|
- 9992:9992
|
||||||
|
environment:
|
||||||
|
WASM_LOG: info
|
||||||
|
RUST_LOG: debug,particle_reap=debug,aquamarine=warn,aquamarine::particle_functions=debug,aquamarine::log=debug,aquamarine::aqua_runtime=error,ipfs_effector=off,ipfs_pure=off,system_services=debug,marine_core::module::marine_module=info,tokio_threadpool=info,tokio_reactor=info,mio=info,tokio_io=info,soketto=info,yamux=info,multistream_select=info,libp2p_secio=info,libp2p_websocket::framed=info,libp2p_ping=info,libp2p_core::upgrade::apply=info,libp2p_kad::kbucket=info,cranelift_codegen=info,wasmer_wasi=info,cranelift_codegen=info,wasmer_wasi=info,run-console=trace,wasmtime_cranelift=off,wasmtime_jit=off,libp2p_tcp=off,libp2p_swarm=off,particle_protocol::libp2p_protocol::upgrade=info,libp2p_mplex=off,particle_reap=off,netlink_proto=warn
|
||||||
|
FLUENCE_MAX_SPELL_PARTICLE_TTL: 9s
|
||||||
|
FLUENCE_ROOT_KEY_PAIR__PATH: /run/secrets/nox-1
|
||||||
|
command:
|
||||||
|
- --config=/run/configs/nox-1_Config.toml
|
||||||
|
- --external-maddrs
|
||||||
|
- /dns4/nox-1/tcp/7772
|
||||||
|
- /dns4/nox-1/tcp/9992/ws
|
||||||
|
- --allow-private-ips
|
||||||
|
- --bootstraps=/dns/nox-0/tcp/7771
|
||||||
|
depends_on:
|
||||||
|
- ipfs
|
||||||
|
volumes:
|
||||||
|
- ./configs/nox-1_Config.toml:/run/configs/nox-1_Config.toml
|
||||||
|
secrets:
|
||||||
|
- nox-1
|
||||||
|
nox-2:
|
||||||
|
image: fluencelabs/nox:0.16.3
|
||||||
|
pull_policy: always
|
||||||
|
ports:
|
||||||
|
- 7773:7773
|
||||||
|
- 9993:9993
|
||||||
|
environment:
|
||||||
|
WASM_LOG: info
|
||||||
|
RUST_LOG: debug,particle_reap=debug,aquamarine=warn,aquamarine::particle_functions=debug,aquamarine::log=debug,aquamarine::aqua_runtime=error,ipfs_effector=off,ipfs_pure=off,system_services=debug,marine_core::module::marine_module=info,tokio_threadpool=info,tokio_reactor=info,mio=info,tokio_io=info,soketto=info,yamux=info,multistream_select=info,libp2p_secio=info,libp2p_websocket::framed=info,libp2p_ping=info,libp2p_core::upgrade::apply=info,libp2p_kad::kbucket=info,cranelift_codegen=info,wasmer_wasi=info,cranelift_codegen=info,wasmer_wasi=info,run-console=trace,wasmtime_cranelift=off,wasmtime_jit=off,libp2p_tcp=off,libp2p_swarm=off,particle_protocol::libp2p_protocol::upgrade=info,libp2p_mplex=off,particle_reap=off,netlink_proto=warn
|
||||||
|
FLUENCE_MAX_SPELL_PARTICLE_TTL: 9s
|
||||||
|
FLUENCE_ROOT_KEY_PAIR__PATH: /run/secrets/nox-2
|
||||||
|
command:
|
||||||
|
- --config=/run/configs/nox-2_Config.toml
|
||||||
|
- --external-maddrs
|
||||||
|
- /dns4/nox-2/tcp/7773
|
||||||
|
- /dns4/nox-2/tcp/9993/ws
|
||||||
|
- --allow-private-ips
|
||||||
|
- --bootstraps=/dns/nox-0/tcp/7771
|
||||||
|
depends_on:
|
||||||
|
- ipfs
|
||||||
|
volumes:
|
||||||
|
- ./configs/nox-2_Config.toml:/run/configs/nox-2_Config.toml
|
||||||
|
secrets:
|
||||||
|
- nox-2
|
||||||
|
|
||||||
|
secrets:
|
||||||
|
nox-0:
|
||||||
|
file: secrets/nox-0.txt
|
||||||
|
nox-1:
|
||||||
|
file: secrets/nox-1.txt
|
||||||
|
nox-2:
|
||||||
|
file: secrets/nox-2.txt
|
17
examples/archived/1-registry/.fluence/workers.yaml
Normal file
17
examples/archived/1-registry/.fluence/workers.yaml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# yaml-language-server: $schema=schemas/workers.json
|
||||||
|
|
||||||
|
# A result of app deployment. This file is created automatically after successful deployment using `fluence workers deploy` command
|
||||||
|
|
||||||
|
# Documentation: https://github.com/fluencelabs/cli/tree/main/docs/configs/workers.md
|
||||||
|
|
||||||
|
version: 1
|
||||||
|
|
||||||
|
deals:
|
||||||
|
local:
|
||||||
|
dealName:
|
||||||
|
definition: bafkreidqtqpmmferdscg4bqrs74cl6ckib3vyhvejhrc4watln5xxcrj2i
|
||||||
|
timestamp: 2023-12-19T20:01:24.334Z
|
||||||
|
dealIdOriginal: "0xEb92A1B5c10AD7BFdcaf23Cb7DDA9ea062CD07E8"
|
||||||
|
dealId: eb92a1b5c10ad7bfdcaf23cb7dda9ea062cd07e8
|
||||||
|
chainNetwork: local
|
||||||
|
chainNetworkId: 31337
|
12
examples/archived/1-registry/.gitignore
vendored
Normal file
12
examples/archived/1-registry/.gitignore
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
/.fluence/secrets
|
||||||
|
/.fluence/env.yaml
|
||||||
|
/.fluence/schemas
|
||||||
|
/.fluence/tmp
|
||||||
|
**/node_modules
|
||||||
|
**/target/
|
||||||
|
.repl_history
|
||||||
|
/.vscode/settings.json
|
||||||
|
/src/ts/src/aqua
|
||||||
|
/src/js/src/aqua
|
File diff suppressed because it is too large
Load Diff
2
examples/archived/1-registry/Cargo.toml
Normal file
2
examples/archived/1-registry/Cargo.toml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[workspace]
|
||||||
|
members = [ "src/services/echo_service/modules/echo_service" ]
|
@ -89,9 +89,7 @@ It uses `createResource` function from Resources API to register the Resource wi
|
|||||||
You should see output similar to this:
|
You should see output similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
[
|
5pYpWB3ozi6fi1EjNs9X5kE156aA6iLECxTuVdJgUaLB
|
||||||
"5pYpWB3ozi6fi1EjNs9X5kE156aA6iLECxTuVdJgUaLB"
|
|
||||||
]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
It is `resourceId`, which we will use to register our services, and then we will be able to use the same `resourceId` to discover and call our services
|
It is `resourceId`, which we will use to register our services, and then we will be able to use the same `resourceId` to discover and call our services
|
||||||
@ -105,9 +103,8 @@ This command calls [registerEchoService](src/aqua/main.aqua#L26) aqua function,
|
|||||||
You should see this output:
|
You should see this output:
|
||||||
```
|
```
|
||||||
[
|
[
|
||||||
[
|
true,
|
||||||
true
|
[]
|
||||||
]
|
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
It means the service is registered in Registry and should be accessible by anyone who only has the `resourceId` of this service.
|
It means the service is registered in Registry and should be accessible by anyone who only has the `resourceId` of this service.
|
24
examples/archived/1-registry/fluence.yaml
Normal file
24
examples/archived/1-registry/fluence.yaml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# yaml-language-server: $schema=.fluence/schemas/fluence.json
|
||||||
|
|
||||||
|
# Defines Fluence Project, most importantly - what exactly you want to deploy and how. You can use `fluence init` command to generate a template for new Fluence project
|
||||||
|
|
||||||
|
# Documentation: https://github.com/fluencelabs/cli/tree/main/docs/configs/fluence.md
|
||||||
|
|
||||||
|
version: 5
|
||||||
|
|
||||||
|
aquaInputPath: src/aqua/main.aqua
|
||||||
|
|
||||||
|
deals:
|
||||||
|
dealName:
|
||||||
|
minWorkers: 1
|
||||||
|
targetWorkers: 3
|
||||||
|
services: [ echo_service ]
|
||||||
|
spells: []
|
||||||
|
|
||||||
|
services:
|
||||||
|
echo_service:
|
||||||
|
get: src/services/echo_service
|
||||||
|
|
||||||
|
relaysPath: src/frontend/src
|
||||||
|
|
||||||
|
aquaOutputTSPath: src/frontend/src/compiled-aqua
|
32
examples/archived/1-registry/provider.yaml
Normal file
32
examples/archived/1-registry/provider.yaml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# yaml-language-server: $schema=.fluence/schemas/provider.json
|
||||||
|
|
||||||
|
# Defines config used for provider set up
|
||||||
|
|
||||||
|
# Documentation: https://github.com/fluencelabs/cli/tree/main/docs/configs/provider.md
|
||||||
|
|
||||||
|
version: 0
|
||||||
|
|
||||||
|
env: local
|
||||||
|
|
||||||
|
nox:
|
||||||
|
systemServices:
|
||||||
|
enable:
|
||||||
|
- registry
|
||||||
|
- decider
|
||||||
|
|
||||||
|
computePeers:
|
||||||
|
nox-0:
|
||||||
|
computeUnits: 1
|
||||||
|
nox-1:
|
||||||
|
computeUnits: 1
|
||||||
|
nox-2:
|
||||||
|
computeUnits: 1
|
||||||
|
|
||||||
|
offers:
|
||||||
|
offer-0:
|
||||||
|
maxCollateralPerWorker: 1
|
||||||
|
minPricePerWorkerEpoch: 0.1
|
||||||
|
computePeers:
|
||||||
|
- nox-0
|
||||||
|
- nox-1
|
||||||
|
- nox-2
|
73
examples/archived/1-registry/src/aqua/main.aqua
Normal file
73
examples/archived/1-registry/src/aqua/main.aqua
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import "@fluencelabs/aqua-lib/builtin.aqua"
|
||||||
|
import "@fluencelabs/aqua-lib/subnet.aqua"
|
||||||
|
import createResource, registerService, resolveResource from "@fluencelabs/registry/resources-api.aqua"
|
||||||
|
|
||||||
|
use "deals.aqua"
|
||||||
|
use "hosts.aqua"
|
||||||
|
import "services.aqua"
|
||||||
|
|
||||||
|
service EchoJSService:
|
||||||
|
echo(msg: string) -> string
|
||||||
|
|
||||||
|
func echo(msg: string) -> string:
|
||||||
|
deals <- Deals.get()
|
||||||
|
dealId = deals.dealName!.dealIdOriginal
|
||||||
|
|
||||||
|
on HOST_PEER_ID:
|
||||||
|
subnet <- Subnet.resolve(dealId)
|
||||||
|
|
||||||
|
if subnet.success == false:
|
||||||
|
Console.print(["Failed to resolve subnet: ", subnet.error])
|
||||||
|
|
||||||
|
w = subnet.workers!
|
||||||
|
|
||||||
|
on w.worker_id! via w.host_id:
|
||||||
|
res <- EchoService.echo(msg)
|
||||||
|
<- res
|
||||||
|
|
||||||
|
|
||||||
|
func echoJS(peerId: string, relayId: string, serviceId: string, msg: string) -> string:
|
||||||
|
on peerId via relayId:
|
||||||
|
EchoService serviceId
|
||||||
|
res <- EchoService.echo(msg)
|
||||||
|
<- res
|
||||||
|
|
||||||
|
func createRes(label: string) -> ?string:
|
||||||
|
resourceId, error <- createResource(label)
|
||||||
|
<- error
|
||||||
|
|
||||||
|
func registerResourceService(resourceId: string, serviceId: string) -> bool, *string:
|
||||||
|
on HOST_PEER_ID:
|
||||||
|
-- TODO: change hardcoded local peer to resolve
|
||||||
|
res, message <- registerService(resourceId, "" , "12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR", [serviceId])
|
||||||
|
<- res, message
|
||||||
|
|
||||||
|
|
||||||
|
func echoAll(resourceId: string, msg: string) -> *string:
|
||||||
|
-- 2 is the min number of peers we want to ask
|
||||||
|
records <- resolveResource(resourceId, 2)
|
||||||
|
results: *string
|
||||||
|
for r <- records!:
|
||||||
|
on HOST_PEER_ID:
|
||||||
|
EchoService r.metadata.service_id!
|
||||||
|
results <- EchoService.echo(msg)
|
||||||
|
<- results
|
||||||
|
|
||||||
|
func showSubnets() -> *string:
|
||||||
|
deals <- Deals.get()
|
||||||
|
dealId = deals.dealName!.dealIdOriginal
|
||||||
|
|
||||||
|
on HOST_PEER_ID:
|
||||||
|
results: *string
|
||||||
|
subnet <- Subnet.resolve(dealId)
|
||||||
|
|
||||||
|
if subnet.success == false:
|
||||||
|
Console.print(["Failed to resolve subnet: ", subnet.error])
|
||||||
|
|
||||||
|
for w <- subnet.workers:
|
||||||
|
results <<- w.host_id
|
||||||
|
|
||||||
|
<- results
|
||||||
|
|
||||||
|
|
||||||
|
|
3547
examples/archived/1-registry/src/frontend/package-lock.json
generated
Normal file
3547
examples/archived/1-registry/src/frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
24
examples/archived/1-registry/src/frontend/package.json
Normal file
24
examples/archived/1-registry/src/frontend/package.json
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"type": "module",
|
||||||
|
"private": true,
|
||||||
|
"name": "echo",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "Fluence Peer with echo service",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node --loader ts-node/esm src/echo.ts"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"aqua",
|
||||||
|
"dht",
|
||||||
|
"p2p"
|
||||||
|
],
|
||||||
|
"author": "Fluence Labs",
|
||||||
|
"dependencies": {
|
||||||
|
"@fluencelabs/js-client": "0.5.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@fluencelabs/registry": "^0.9.2",
|
||||||
|
"ts-node": "10.9.2",
|
||||||
|
"typescript": "5.0.2"
|
||||||
|
}
|
||||||
|
}
|
@ -13,32 +13,33 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { Fluence, KeyPair, setLogLevel } from "@fluencelabs/fluence";
|
import { Fluence, KeyPair } from '@fluencelabs/js-client';
|
||||||
import { stage } from "@fluencelabs/fluence-network-environment";
|
import { registerEchoJSService } from './compiled-aqua/main.ts';
|
||||||
import { registerEchoService, registerService } from "./generated/export";
|
|
||||||
import assert from "node:assert";
|
|
||||||
|
|
||||||
// don't store your secret key in the code. This is just for the example
|
// don't store your secret key in the code. This is just for the example
|
||||||
const secretKey = "Iz3HUmNIB78lkNNVmMkDKrju0nCivtkJNyObrFAr774=";
|
const secretKey = "Iz3HUmNIB78lkNNVmMkDKrju0nCivtkJNyObrFAr774=";
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const keypair = await KeyPair.fromEd25519SK(Buffer.from(secretKey, "base64"));
|
const keyPair = await KeyPair.fromEd25519SK(Buffer.from(secretKey, "base64"));
|
||||||
const connectTo = stage[0];
|
|
||||||
assert(connectTo !== undefined);
|
|
||||||
|
|
||||||
// connect to the Fluence network
|
await Fluence.connect({
|
||||||
await Fluence.start({ connectTo, KeyPair: keypair });
|
multiaddr:
|
||||||
setLogLevel("SILENT");
|
"/ip4/127.0.0.1/tcp/9991/ws/p2p/12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR",
|
||||||
|
peerId: "12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR",
|
||||||
|
}, { keyPair: {
|
||||||
|
type: 'Ed25519',
|
||||||
|
source: keyPair.toEd25519PrivateKey()
|
||||||
|
}});
|
||||||
|
|
||||||
|
const peerId = Fluence.getClient().getPeerId();
|
||||||
|
const relayId = Fluence.getClient().getRelayPeerId();
|
||||||
|
|
||||||
const peerId = Fluence.getStatus().peerId;
|
|
||||||
const relayId = Fluence.getStatus().relayPeerId;
|
|
||||||
assert(peerId !== null && relayId !== null);
|
|
||||||
console.log(`📗 created a fluence peer ${peerId} with relay ${relayId}`);
|
console.log(`📗 created a fluence peer ${peerId} with relay ${relayId}`);
|
||||||
|
|
||||||
const serviceId = "echo";
|
const serviceId = "echo";
|
||||||
|
|
||||||
// register local service with serviceId "echo"
|
// register local service with serviceId "echo"
|
||||||
await registerEchoService(serviceId, {
|
registerEchoJSService(serviceId, {
|
||||||
echo(msg) {
|
echo(msg) {
|
||||||
console.log(`Received message: ${msg}`);
|
console.log(`Received message: ${msg}`);
|
||||||
return `${peerId}: ${msg}`;
|
return `${peerId}: ${msg}`;
|
||||||
@ -50,19 +51,19 @@ async function main() {
|
|||||||
// don't register if resource id isn't passed
|
// don't register if resource id isn't passed
|
||||||
if (resourceId === undefined) {
|
if (resourceId === undefined) {
|
||||||
console.log(
|
console.log(
|
||||||
`
|
`
|
||||||
Copy this code to call this service:
|
Copy this code to call this service:
|
||||||
|
|
||||||
fluence run -f 'echoJS("${peerId}", "${relayId}", "${serviceId}", "hi")'`
|
fluence run -f 'echoJS("${peerId}", "${relayId}", "${serviceId}", "hi")'`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const [success, error] = await registerService(
|
// const [success, error] = await registerService(
|
||||||
resourceId,
|
// resourceId,
|
||||||
"echo",
|
// "echo",
|
||||||
peerId,
|
// peerId,
|
||||||
serviceId
|
// serviceId
|
||||||
);
|
// );
|
||||||
console.log(`Registration result: ${success || error}`);
|
// console.log(`Registration result: ${success || error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("\nPress any key to stop fluence js peer");
|
console.log("\nPress any key to stop fluence js peer");
|
||||||
@ -71,7 +72,7 @@ async function main() {
|
|||||||
process.stdin.setRawMode(true);
|
process.stdin.setRawMode(true);
|
||||||
process.stdin.resume();
|
process.stdin.resume();
|
||||||
process.stdin.on("data", async () => {
|
process.stdin.on("data", async () => {
|
||||||
await Fluence.stop();
|
await Fluence.disconnect();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
14
examples/archived/1-registry/src/frontend/src/relays.json
Normal file
14
examples/archived/1-registry/src/frontend/src/relays.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"multiaddr": "/ip4/127.0.0.1/tcp/9991/ws/p2p/12D3KooWJTYHn4U8jJtL1XZvTonAgv2Tn6EEbZSauw56dhr3SNKg",
|
||||||
|
"peerId": "12D3KooWJTYHn4U8jJtL1XZvTonAgv2Tn6EEbZSauw56dhr3SNKg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"multiaddr": "/ip4/127.0.0.1/tcp/9992/ws/p2p/12D3KooWQrMQg2Ksqag5465Tnu8VQH3c4Z4NSosdS854bAsHEcwo",
|
||||||
|
"peerId": "12D3KooWQrMQg2Ksqag5465Tnu8VQH3c4Z4NSosdS854bAsHEcwo"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"multiaddr": "/ip4/127.0.0.1/tcp/9993/ws/p2p/12D3KooWQCYhkDv4jPe7ymEo8AwRNMzLZRmfyrbV53vKpVS7fZA7",
|
||||||
|
"peerId": "12D3KooWQCYhkDv4jPe7ymEo8AwRNMzLZRmfyrbV53vKpVS7fZA7"
|
||||||
|
}
|
||||||
|
]
|
23
examples/archived/1-registry/src/frontend/tsconfig.json
Normal file
23
examples/archived/1-registry/src/frontend/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2020",
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"module": "ESNext",
|
||||||
|
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||||
|
"skipLibCheck": true,
|
||||||
|
|
||||||
|
/* Bundler mode */
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noEmit": true,
|
||||||
|
|
||||||
|
/* Linting */
|
||||||
|
"strict": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"noFallthroughCasesInSwitch": true
|
||||||
|
},
|
||||||
|
"include": ["src"]
|
||||||
|
}
|
@ -8,7 +8,7 @@ name = "echo_service"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
marine-rs-sdk = "=0.10.2"
|
marine-rs-sdk = "0.10.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
marine-rs-sdk-test = "=0.12.0"
|
marine-rs-sdk-test = "=0.12.0"
|
@ -0,0 +1,11 @@
|
|||||||
|
# yaml-language-server: $schema=../../../../../.fluence/schemas/module.json
|
||||||
|
|
||||||
|
# Defines [Marine Module](https://fluence.dev/docs/build/concepts/#modules). You can use `fluence module new` command to generate a template for new module
|
||||||
|
|
||||||
|
# Documentation: https://github.com/fluencelabs/cli/tree/main/docs/configs/module.md
|
||||||
|
|
||||||
|
version: 0
|
||||||
|
|
||||||
|
type: rust
|
||||||
|
|
||||||
|
name: echo_service
|
@ -0,0 +1,13 @@
|
|||||||
|
# yaml-language-server: $schema=../../../.fluence/schemas/service.json
|
||||||
|
|
||||||
|
# Defines a [Marine service](https://fluence.dev/docs/build/concepts/#services), most importantly the modules that the service consists of. You can use `fluence service new` command to generate a template for new service
|
||||||
|
|
||||||
|
# Documentation: https://github.com/fluencelabs/cli/tree/main/docs/configs/service.md
|
||||||
|
|
||||||
|
version: 0
|
||||||
|
|
||||||
|
name: echo_service
|
||||||
|
|
||||||
|
modules:
|
||||||
|
facade:
|
||||||
|
get: modules/echo_service
|
Loading…
x
Reference in New Issue
Block a user