mirror of
https://github.com/fluencelabs/examples
synced 2024-12-04 19:20:17 +00:00
fix typo, missing identity func
This commit is contained in:
parent
90a25bedfe
commit
79a8073960
@ -150,7 +150,7 @@ fldist env
|
||||
|
||||
Pick any of the peer ids from the listed peers to deploy your services. Let's say we use peer id `12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi`:
|
||||
|
||||
```test
|
||||
```text
|
||||
fldist --node-id 12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi new_service --ms artifacts/curl_adapter.wasm:configs/curl_adapter_cfg.json artifacts/price_getter_service.wasm:configs/price_getter_service_cfg.json --name price-getter-service-0
|
||||
```
|
||||
|
||||
|
@ -8,42 +8,48 @@
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "coin") [] coin)
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "coin") [] coin)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "currency") [] currency)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "currency") [] currency)
|
||||
(call %init_peer_id% ("getDataSrv" "getter_topo") [] getter_topo)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "getter_topo") [] getter_topo)
|
||||
(call %init_peer_id% ("getDataSrv" "mean_topo") [] mean_topo)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "mean_topo") [] mean_topo)
|
||||
)
|
||||
(fold getter_topo topo
|
||||
(par
|
||||
(seq
|
||||
(fold getter_topo topo
|
||||
(par
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call topo.$.node! ("op" "string_to_b58") [topo.$.node!] k)
|
||||
(call topo.$.node! ("peer" "timestamp_ms") [] ts_ms)
|
||||
)
|
||||
(call topo.$.node! (topo.$.service_id! "price_getter") [coin currency ts_ms] res)
|
||||
)
|
||||
(call topo.$.node! ("op" "identity") [res.$.result!] $prices)
|
||||
)
|
||||
(seq
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call topo.$.node! ("op" "string_to_b58") [topo.$.node!] k)
|
||||
(call topo.$.node! ("peer" "timestamp_ms") [] ts_ms)
|
||||
)
|
||||
(call topo.$.node! (topo.$.service_id! "price_getter") [coin currency ts_ms] res)
|
||||
)
|
||||
(call topo.$.node! ("op" "identity") [res.$.result!] $prices)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
)
|
||||
)
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(call %init_peer_id% ("op" "noop") [])
|
||||
)
|
||||
(call mean_topo.$.node! ("op" "noop") [])
|
||||
(next topo)
|
||||
)
|
||||
(next topo)
|
||||
)
|
||||
)
|
||||
(call %init_peer_id% ("op" "identity") [$prices.$.[2]!])
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
|
@ -57,6 +57,7 @@ func get_price_par(coin: string, currency: string, getter_topo: []NodeServicePai
|
||||
ts_ms <- Peer.timestamp_ms()
|
||||
res <- PriceGetterService.price_getter(coin, currency, ts_ms)
|
||||
prices <- F64Op.identity(res.result)
|
||||
F64Op.identity(prices!2)
|
||||
|
||||
on mean_topo.node:
|
||||
MeanService mean_topo.service_id
|
||||
|
@ -94,7 +94,7 @@ function get_price_par(client, coin, currency, getter_topo, mean_topo, config) {
|
||||
promise = new Promise(function (resolve, reject) {
|
||||
var r = new api_unstable_1.RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript("\n(xor\n (seq\n (seq\n (seq\n (seq\n (seq\n (seq\n (seq\n (seq\n (seq\n (call %init_peer_id% (\"getDataSrv\" \"-relay-\") [] -relay-)\n (call %init_peer_id% (\"getDataSrv\" \"coin\") [] coin)\n )\n (call %init_peer_id% (\"getDataSrv\" \"currency\") [] currency)\n )\n (call %init_peer_id% (\"getDataSrv\" \"getter_topo\") [] getter_topo)\n )\n (call %init_peer_id% (\"getDataSrv\" \"mean_topo\") [] mean_topo)\n )\n (fold getter_topo topo\n (par\n (seq\n (seq\n (call -relay- (\"op\" \"noop\") [])\n (xor\n (seq\n (seq\n (seq\n (call topo.$.node! (\"op\" \"string_to_b58\") [topo.$.node!] k)\n (call topo.$.node! (\"peer\" \"timestamp_ms\") [] ts_ms)\n )\n (call topo.$.node! (topo.$.service_id! \"price_getter\") [coin currency ts_ms] res)\n )\n (call topo.$.node! (\"op\" \"identity\") [res.$.result!] $prices)\n )\n (seq\n (call -relay- (\"op\" \"noop\") [])\n (call %init_peer_id% (\"errorHandlingSrv\" \"error\") [%last_error% 1])\n )\n )\n )\n (call mean_topo.$.node! (\"op\" \"noop\") [])\n )\n (next topo)\n )\n )\n )\n (call -relay- (\"op\" \"noop\") [])\n )\n (xor\n (seq\n (call -relay- (\"op\" \"noop\") [])\n (call mean_topo.$.node! (mean_topo.$.service_id! \"mean\") [$prices] result)\n )\n (seq\n (call -relay- (\"op\" \"noop\") [])\n (call %init_peer_id% (\"errorHandlingSrv\" \"error\") [%last_error% 2])\n )\n )\n )\n (call -relay- (\"op\" \"noop\") [])\n )\n (xor\n (call %init_peer_id% (\"callbackSrv\" \"response\") [result])\n (call %init_peer_id% (\"errorHandlingSrv\" \"error\") [%last_error% 3])\n )\n )\n (call %init_peer_id% (\"errorHandlingSrv\" \"error\") [%last_error% 4])\n)\n\n ")
|
||||
.withRawScript("\n(xor\n (seq\n (seq\n (seq\n (seq\n (seq\n (seq\n (seq\n (seq\n (seq\n (seq\n (call %init_peer_id% (\"getDataSrv\" \"-relay-\") [] -relay-)\n (call %init_peer_id% (\"getDataSrv\" \"coin\") [] coin)\n )\n (call %init_peer_id% (\"getDataSrv\" \"currency\") [] currency)\n )\n (call %init_peer_id% (\"getDataSrv\" \"getter_topo\") [] getter_topo)\n )\n (call %init_peer_id% (\"getDataSrv\" \"mean_topo\") [] mean_topo)\n )\n (fold getter_topo topo\n (par\n (seq\n (seq\n (seq\n (call -relay- (\"op\" \"noop\") [])\n (xor\n (seq\n (seq\n (seq\n (call topo.$.node! (\"op\" \"string_to_b58\") [topo.$.node!] k)\n (call topo.$.node! (\"peer\" \"timestamp_ms\") [] ts_ms)\n )\n (call topo.$.node! (topo.$.service_id! \"price_getter\") [coin currency ts_ms] res)\n )\n (call topo.$.node! (\"op\" \"identity\") [res.$.result!] $prices)\n )\n (seq\n (call -relay- (\"op\" \"noop\") [])\n (call %init_peer_id% (\"errorHandlingSrv\" \"error\") [%last_error% 1])\n )\n )\n )\n (call -relay- (\"op\" \"noop\") [])\n )\n (call %init_peer_id% (\"op\" \"noop\") [])\n )\n (next topo)\n )\n )\n )\n (call %init_peer_id% (\"op\" \"identity\") [$prices.$.[2]!])\n )\n (call -relay- (\"op\" \"noop\") [])\n )\n (xor\n (seq\n (call -relay- (\"op\" \"noop\") [])\n (call mean_topo.$.node! (mean_topo.$.service_id! \"mean\") [$prices] result)\n )\n (seq\n (call -relay- (\"op\" \"noop\") [])\n (call %init_peer_id% (\"errorHandlingSrv\" \"error\") [%last_error% 2])\n )\n )\n )\n (call -relay- (\"op\" \"noop\") [])\n )\n (xor\n (call %init_peer_id% (\"callbackSrv\" \"response\") [result])\n (call %init_peer_id% (\"errorHandlingSrv\" \"error\") [%last_error% 3])\n )\n )\n (call %init_peer_id% (\"errorHandlingSrv\" \"error\") [%last_error% 4])\n)\n\n ")
|
||||
.configHandler(function (h) {
|
||||
h.on('getDataSrv', '-relay-', function () {
|
||||
return client.relayPeerId;
|
||||
|
@ -64,7 +64,7 @@ function main() {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
console.log("hello");
|
||||
console.log("hello crypto investors");
|
||||
return [4 /*yield*/, fluence_1.createClient(fluence_network_environment_1.krasnodar[2])];
|
||||
case 1:
|
||||
fluence = _a.sent();
|
||||
|
@ -135,42 +135,48 @@ export async function get_price_par(client: FluenceClient, coin: string, currenc
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "coin") [] coin)
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "coin") [] coin)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "currency") [] currency)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "currency") [] currency)
|
||||
(call %init_peer_id% ("getDataSrv" "getter_topo") [] getter_topo)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "getter_topo") [] getter_topo)
|
||||
(call %init_peer_id% ("getDataSrv" "mean_topo") [] mean_topo)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "mean_topo") [] mean_topo)
|
||||
)
|
||||
(fold getter_topo topo
|
||||
(par
|
||||
(seq
|
||||
(fold getter_topo topo
|
||||
(par
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call topo.$.node! ("op" "string_to_b58") [topo.$.node!] k)
|
||||
(call topo.$.node! ("peer" "timestamp_ms") [] ts_ms)
|
||||
)
|
||||
(call topo.$.node! (topo.$.service_id! "price_getter") [coin currency ts_ms] res)
|
||||
)
|
||||
(call topo.$.node! ("op" "identity") [res.$.result!] $prices)
|
||||
)
|
||||
(seq
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call topo.$.node! ("op" "string_to_b58") [topo.$.node!] k)
|
||||
(call topo.$.node! ("peer" "timestamp_ms") [] ts_ms)
|
||||
)
|
||||
(call topo.$.node! (topo.$.service_id! "price_getter") [coin currency ts_ms] res)
|
||||
)
|
||||
(call topo.$.node! ("op" "identity") [res.$.result!] $prices)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
)
|
||||
)
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(call %init_peer_id% ("op" "noop") [])
|
||||
)
|
||||
(call mean_topo.$.node! ("op" "noop") [])
|
||||
(next topo)
|
||||
)
|
||||
(next topo)
|
||||
)
|
||||
)
|
||||
(call %init_peer_id% ("op" "identity") [$prices.$.[2]!])
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
|
@ -31,7 +31,7 @@ getter_topo = Array({ "node": "12D3KooWCMr9mU894i8JXAFqpgoFtx6qnV1LFPSfVc3Y34N4h
|
||||
mean_topo = { "node": "12D3KooWCMr9mU894i8JXAFqpgoFtx6qnV1LFPSfVc3Y34N4h4LS", "service_id": "dd47389f-25d9-4870-a2a9-909359e73580" };
|
||||
|
||||
async function main() {
|
||||
console.log("hello");
|
||||
console.log("hello crypto investors");
|
||||
// setLogLevel('DEBUG');
|
||||
const fluence = await createClient(krasnodar[2]);
|
||||
console.log("created a fluence client %s with relay %s", fluence.selfPeerId, fluence.relayPeerId);
|
||||
|
Loading…
Reference in New Issue
Block a user