|
|
@ -6,7 +6,7 @@ import ByteBuffer from 'bytebuffer';
|
|
|
|
import { OnionPaths } from '../onions';
|
|
|
|
import { OnionPaths } from '../onions';
|
|
|
|
import { fromHex, toHex } from '../utils/String';
|
|
|
|
import { fromHex, toHex } from '../utils/String';
|
|
|
|
import pRetry from 'p-retry';
|
|
|
|
import pRetry from 'p-retry';
|
|
|
|
import { incrementBadPathCountOrDrop } from '../onions/onionPath';
|
|
|
|
import { ed25519Str, incrementBadPathCountOrDrop } from '../onions/onionPath';
|
|
|
|
import _ from 'lodash';
|
|
|
|
import _ from 'lodash';
|
|
|
|
import { hrefPnServerDev, hrefPnServerProd } from '../../pushnotification/PnServer';
|
|
|
|
import { hrefPnServerDev, hrefPnServerProd } from '../../pushnotification/PnServer';
|
|
|
|
// hold the ed25519 key of a snode against the time it fails. Used to remove a snode only after a few failures (snodeFailureThreshold failures)
|
|
|
|
// hold the ed25519 key of a snode against the time it fails. Used to remove a snode only after a few failures (snodeFailureThreshold failures)
|
|
|
@ -291,6 +291,7 @@ async function processAnyOtherErrorOnPath(
|
|
|
|
// If we have a specific node in fault we can exclude just this node.
|
|
|
|
// If we have a specific node in fault we can exclude just this node.
|
|
|
|
// Otherwise we increment the whole path failure count
|
|
|
|
// Otherwise we increment the whole path failure count
|
|
|
|
if (nodeNotFound) {
|
|
|
|
if (nodeNotFound) {
|
|
|
|
|
|
|
|
window?.log?.warn('node not found error with: ', ed25519Str(nodeNotFound));
|
|
|
|
await exports.incrementBadSnodeCountOrDrop({
|
|
|
|
await exports.incrementBadSnodeCountOrDrop({
|
|
|
|
snodeEd25519: nodeNotFound,
|
|
|
|
snodeEd25519: nodeNotFound,
|
|
|
|
guardNodeEd25519,
|
|
|
|
guardNodeEd25519,
|
|
|
@ -613,15 +614,15 @@ export async function incrementBadSnodeCountOrDrop({
|
|
|
|
const newFailureCount = oldFailureCount + 1;
|
|
|
|
const newFailureCount = oldFailureCount + 1;
|
|
|
|
snodeFailureCount[snodeEd25519] = newFailureCount;
|
|
|
|
snodeFailureCount[snodeEd25519] = newFailureCount;
|
|
|
|
if (newFailureCount >= snodeFailureThreshold) {
|
|
|
|
if (newFailureCount >= snodeFailureThreshold) {
|
|
|
|
window?.log?.warn(`Failure threshold reached for: ${snodeEd25519}; dropping it.`);
|
|
|
|
window?.log?.warn(`Failure threshold reached for: ${ed25519Str(snodeEd25519)}; dropping it.`);
|
|
|
|
|
|
|
|
|
|
|
|
if (associatedWith) {
|
|
|
|
if (associatedWith) {
|
|
|
|
(window?.log?.info || console.warn)(
|
|
|
|
(window?.log?.info || console.warn)(
|
|
|
|
`Dropping ${snodeEd25519} from swarm of ${associatedWith}`
|
|
|
|
`Dropping ${ed25519Str(snodeEd25519)} from swarm of ${ed25519Str(associatedWith)}`
|
|
|
|
);
|
|
|
|
);
|
|
|
|
await dropSnodeFromSwarmIfNeeded(associatedWith, snodeEd25519);
|
|
|
|
await dropSnodeFromSwarmIfNeeded(associatedWith, snodeEd25519);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
window?.log?.info(`Dropping ${snodeEd25519} from snodepool`);
|
|
|
|
window?.log?.info(`Dropping ${ed25519Str(snodeEd25519)} from snodepool`);
|
|
|
|
|
|
|
|
|
|
|
|
await dropSnodeFromSnodePool(snodeEd25519);
|
|
|
|
await dropSnodeFromSnodePool(snodeEd25519);
|
|
|
|
// the snode was ejected from the pool so it won't be used again.
|
|
|
|
// the snode was ejected from the pool so it won't be used again.
|
|
|
@ -642,7 +643,9 @@ export async function incrementBadSnodeCountOrDrop({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
window?.log?.warn(
|
|
|
|
window?.log?.warn(
|
|
|
|
`Couldn't reach snode at: ${snodeEd25519}; setting his failure count to ${newFailureCount}`
|
|
|
|
`Couldn't reach snode at: ${ed25519Str(
|
|
|
|
|
|
|
|
snodeEd25519
|
|
|
|
|
|
|
|
)}; setting his failure count to ${newFailureCount}`
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|