diff --git a/aqua-examples/decentralized-blockchain-gateway/gateway/aqua/rpc.aqua b/aqua-examples/decentralized-blockchain-gateway/gateway/aqua/rpc.aqua index f648d69..2d59869 100644 --- a/aqua-examples/decentralized-blockchain-gateway/gateway/aqua/rpc.aqua +++ b/aqua-examples/decentralized-blockchain-gateway/gateway/aqua/rpc.aqua @@ -2,8 +2,6 @@ import "@fluencelabs/aqua-lib/builtin.aqua" export randomLoadBalancingEth, roundRobinEth, Counter, Logger - - data EthResult: value: string success: bool diff --git a/aqua-examples/decentralized-blockchain-gateway/gateway/config.json b/aqua-examples/decentralized-blockchain-gateway/gateway/config.json index fea4593..4377e1b 100644 --- a/aqua-examples/decentralized-blockchain-gateway/gateway/config.json +++ b/aqua-examples/decentralized-blockchain-gateway/gateway/config.json @@ -6,5 +6,7 @@ "mode": "round-robin", "relay": "/dns4/kras-02.fluence.dev/tcp/19001/wss/p2p/12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf", "serviceId": "25bf2293-7503-4a01-af00-d1b7d089ca37", - "port": 3000 + "port": 3000, + "counterServiceId": null, + "counterPeerId": null } \ No newline at end of file diff --git a/aqua-examples/decentralized-blockchain-gateway/gateway/src/config.js b/aqua-examples/decentralized-blockchain-gateway/gateway/src/config.js index 88df10b..f25e963 100644 --- a/aqua-examples/decentralized-blockchain-gateway/gateway/src/config.js +++ b/aqua-examples/decentralized-blockchain-gateway/gateway/src/config.js @@ -1,7 +1,8 @@ import fs from 'fs'; -export const configHelp = "Config structure: { port, relay, serviceId, providers, mode}\n" + - "Where mode can be: 'random' (default) or 'round-robin'" +export const configHelp = "Config structure: { port, relay, serviceId, providers, mode, counterServiceId?, counterPeerId?}\n" + + "Where 'mode' can be: 'random' (default) or 'round-robin',\n" + + "'counterServiceId' and 'counterPeerId' will use local service if undefined" export function readConfig(path) { const rawdata = fs.readFileSync(path); diff --git a/aqua-examples/decentralized-blockchain-gateway/gateway/src/index.js b/aqua-examples/decentralized-blockchain-gateway/gateway/src/index.js index a116e2e..8359f27 100644 --- a/aqua-examples/decentralized-blockchain-gateway/gateway/src/index.js +++ b/aqua-examples/decentralized-blockchain-gateway/gateway/src/index.js @@ -56,6 +56,9 @@ registerCounter(fluence, "counter", { } }) +const counterServiceId = config.counterServiceId || 'counter' +const counterPeerId = config.counterPeerId || fluence.getStatus().peerId + async function methodHandler(req, method) { console.log(`Receiving request '${method}'`); let result; @@ -63,7 +66,7 @@ async function methodHandler(req, method) { result = await randomLoadBalancingEth(fluence, config.providers, method, req.map((s) => JSON.stringify(s)), config.serviceId); } else if (config.mode === "round-robin") { console.log("peerId: " + fluence.getStatus().peerId) - result = await roundRobinEth(fluence, config.providers, method, req.map((s) => JSON.stringify(s)), config.serviceId, "counter", fluence.getStatus().peerId, + result = await roundRobinEth(fluence, config.providers, method, req.map((s) => JSON.stringify(s)), config.serviceId, counterServiceId, counterPeerId, config.serviceId); }