try-finally everywhere

This commit is contained in:
Pavel Murygin 2022-03-17 18:08:12 +03:00
parent 1e698b85ca
commit ee9f98478e
3 changed files with 113 additions and 108 deletions

View File

@ -29,6 +29,7 @@ export async function main(environment: Node[]) {
let serviceHost = environment[2];
let providerClient = new FluencePeer();
try {
await providerClient.start({ connectTo: providerHost });
console.log('📘 uploading .wasm to node %s', providerHost.multiaddr);
let path = globSource('../service/artifacts/process_files.wasm');
@ -85,10 +86,11 @@ export async function main(environment: Node[]) {
let result = await remove_service(serviceHost.peerId, service_id);
console.log('📗 ProcessFiles service removed', result);
} finally {
await Fluence.stop();
await providerClient.stop();
}
}
function fromOption<T>(opt: T | T[] | null): T | null {
if (Array.isArray(opt)) {

View File

@ -89,6 +89,7 @@ export async function main() {
// console.log("hello");
// setLogLevel('DEBUG');
try {
await Fluence.start({ connectTo: krasnodar[2] });
console.log(
'created a fluence client %s with relay %s',
@ -123,6 +124,7 @@ export async function main() {
par_result = await echo_greeting_par_improved(echo_service, greeting_services);
console.log('par improved signature result : ', par_result);
} finally {
await Fluence.stop();
}
}

View File

@ -54,7 +54,7 @@ export async function main() {
// Uncomment to enable debug logs:
// setLogLevel('DEBUG');
try {
// create the Fluence client for the Krasnodar testnet
await Fluence.start({ connectTo: krasnodar[5] });
console.log(
@ -77,6 +77,7 @@ export async function main() {
// func get_price_par(coin: string, currency: string, getter_topo: []NodeServicePair, mean_topo: NodeServicePair) -> Result:
const network_result_par = await get_price_par('ethereum', 'usd', getter_topo, mean_topo[0]);
console.log('par result: ', network_result_par);
} finally {
await Fluence.stop();
}
}