From 4bb2e83cb3d9eab00b314e499d80bd2e44865384 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Thu, 19 Mar 2020 15:04:36 -0700 Subject: [PATCH] lint --- js/modules/loki_message_api.js | 10 +++++--- js/modules/loki_snode_api.js | 45 +++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/js/modules/loki_message_api.js b/js/modules/loki_message_api.js index a94f8a605..3035fc7a9 100644 --- a/js/modules/loki_message_api.js +++ b/js/modules/loki_message_api.js @@ -152,7 +152,9 @@ class LokiMessageAPI { 'Ran out of swarm nodes to query' ); } - log.info(`loki_message:::sendMessage - Successfully stored message to ${pubKey}`); + log.info( + `loki_message:::sendMessage - Successfully stored message to ${pubKey}` + ); } async refreshSendingSwarm(pubKey, timestamp) { @@ -340,9 +342,9 @@ class LokiMessageAPI { nodeData ); log.warn( - `loki_message:::_openRetrieveConnection - too many successive failures, removing ${nodeData.ip}:${ - nodeData.port - } from our swarm pool. We have ${ + `loki_message:::_openRetrieveConnection - too many successive failures, removing ${ + nodeData.ip + }:${nodeData.port} from our swarm pool. We have ${ Object.keys(this.ourSwarmNodes).length } usable swarm nodes left (${ remainingSwarmSnodes.length diff --git a/js/modules/loki_snode_api.js b/js/modules/loki_snode_api.js index 1b78cd6a3..061ecf2de 100644 --- a/js/modules/loki_snode_api.js +++ b/js/modules/loki_snode_api.js @@ -34,15 +34,12 @@ class LokiSnodeAPI { ]; } - - async refreshRandomPool( - seedNodes = [...window.seedNodeList] - ) { + async refreshRandomPool(seedNodes = [...window.seedNodeList]) { // if currently not in progress if (this.refreshRandomPoolPromise === false) { // set lock this.refreshRandomPoolPromise = new Promise(async (resolve, reject) => { - let timeoutTimer = null + let timeoutTimer = null; // private retry container const trySeedNode = async (consecutiveErrors = 0) => { const params = { @@ -61,7 +58,9 @@ class LokiSnodeAPI { )[0]; let snodes = []; try { - log.info('loki_snodes:::refreshRandomPoolPromise - Refreshing random snode pool'); + log.info( + 'loki_snodes:::refreshRandomPoolPromise - Refreshing random snode pool' + ); const response = await lokiRpc( `http://${seedNode.ip}`, seedNode.port, @@ -108,36 +107,44 @@ class LokiSnodeAPI { trySeedNode(consecutiveErrors + 1); }, consecutiveErrors * consecutiveErrors * 5000); } else { - log.error('loki_snodes:::refreshRandomPoolPromise - Giving up trying to contact seed node'); + log.error( + 'loki_snodes:::refreshRandomPoolPromise - Giving up trying to contact seed node' + ); if (snodes.length === 0) { this.refreshRandomPoolPromise = null; // clear lock if (timeoutTimer !== null) { clearTimeout(timeoutTimer); timeoutTimer = null; } - reject() + reject(); } } } - } + }; const delay = (SEED_NODE_RETRIES + 1) * (SEED_NODE_RETRIES + 1) * 5000; timeoutTimer = setTimeout(() => { - log.warn('loki_snodes:::refreshRandomPoolPromise - TIMEDOUT after', delay, 's'); + log.warn( + 'loki_snodes:::refreshRandomPoolPromise - TIMEDOUT after', + delay, + 's' + ); reject(); }, delay); - trySeedNode() + trySeedNode(); }); } try { await this.refreshRandomPoolPromise; - } catch(e) { + } catch (e) { // we will throw for each time initialiseRandomPool has been called in parallel - log.error('loki_snodes:::refreshRandomPoolPromise - error', e.code, e.message); - throw new window.textsecure.SeedNodeError( - 'Failed to contact seed node' + log.error( + 'loki_snodes:::refreshRandomPoolPromise - error', + e.code, + e.message ); + throw new window.textsecure.SeedNodeError('Failed to contact seed node'); } - log.info('loki_snodes:::refreshRandomPoolPromise - RESOLVED') + log.info('loki_snodes:::refreshRandomPoolPromise - RESOLVED'); } // unreachableNode.url is like 9hrje1bymy7hu6nmtjme9idyu3rm8gr3mkstakjyuw1997t7w4ny.snode @@ -223,7 +230,11 @@ class LokiSnodeAPI { try { newSwarmNodes = await this.getSwarmNodes(pubKey); } catch (e) { - log.error('loki_snodes:::getFreshSwarmNodes - error', e.code, e.message); + log.error( + 'loki_snodes:::getFreshSwarmNodes - error', + e.code, + e.message + ); // TODO: Handle these errors sensibly newSwarmNodes = []; }