buildNewOnionPaths() now uses onionRequestPaths control, include count of paths in log

pull/1085/head
Ryan Tharp 5 years ago
parent 203da4544a
commit cc4664e27f

@ -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() {

Loading…
Cancel
Save