Fix MAX_SAFE_INTEGER on timeout

pull/1091/head
Vincent 5 years ago
parent 2fde4d7e80
commit cd5a2f75de

@ -780,20 +780,18 @@ class LokiSnodeAPI {
const output = await window.blake2b(input);
const nameHash = dcodeIO.ByteBuffer.wrap(output).toString('base64');
// Return value of null represents a timeout
const timeoutResponse = { timedOut: true };
const maxTimeoutVal = 2**31 - 1;
const timeoutPromise = (cb, interval) => () =>
new Promise(resolve => setTimeout(() => cb(resolve), interval));
new Promise(resolve => setTimeout(() => cb(resolve), interval || maxTimeoutVal));
const onTimeout = timeoutPromise(
resolve => resolve(timeoutResponse),
timeout || Number.MAX_SAFE_INTEGER
resolve => resolve(timeoutResponse), timeout
);
// Get nodes capable of doing LNS
let lnsNodes = await this.getNodesMinVersion(
const lnsNodes = await this.getNodesMinVersion(
window.CONSTANTS.LNS_CAPABLE_NODES_VERSION
);
lnsNodes = _.shuffle(lnsNodes);
// Enough nodes?
if (lnsNodes.length < numRequiredConfirms) {

Loading…
Cancel
Save