diff --git a/js/modules/loki_snode_api.js b/js/modules/loki_snode_api.js index dfb9d94fc..f82d0e293 100644 --- a/js/modules/loki_snode_api.js +++ b/js/modules/loki_snode_api.js @@ -348,19 +348,28 @@ class LokiSnodeAPI { const guards = _.shuffle(this.guardNodes); // Create path for every guard node: - - // Each path needs 2 nodes in addition to the guard node: - const maxPath = Math.floor(Math.min(guards.length, otherNodes.length / 2)); + const needPaths = window.lokiFeatureFlags.onionRequestPaths - 1; + + // Each path needs X (needPaths) nodes in addition to the guard node: + const maxPath = Math.floor( + Math.min( + guards.length, + needPaths ? otherNodes.length / needPaths : otherNodes.length + ) + ); // TODO: might want to keep some of the existing paths this.onionPaths = []; for (let i = 0; i < maxPath; i += 1) { - const path = [guards[i], otherNodes[i * 2], otherNodes[i * 2 + 1]]; + const path = [guards[i]]; + for (let j = 0; j < needPaths; j += 1) { + path.push(otherNodes[i * needPaths + j]); + } this.onionPaths.push({ path, bad: false }); } - log.info('Built onion paths: ', this.onionPaths); + log.info(`Built ${this.onionPaths.length} onion paths`, this.onionPaths); } async getRandomSnodeAddress() {