Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neutrino: increase ping threshold, 200->1000ms #2233

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions components/Modals/AlertModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ModalStore from '../../stores/ModalStore';
import NodeInfoStore from '../../stores/NodeInfoStore';
import SettingsStore from '../../stores/SettingsStore';

import { NEUTRINO_PING_THRESHOLD_MS } from '../../utils/LndMobileUtils';
import { localeString } from '../../utils/LocaleUtils';
import { restartNeeded } from '../../utils/RestartUtils';
import { themeColor } from '../../utils/ThemeUtils';
Expand Down Expand Up @@ -153,9 +154,9 @@ export default class AlertModal extends React.Component<AlertModalProps, {}> {
color: themeColor('text')
}}
>
{localeString(
{`${localeString(
'components.AlertModal.neutrinoExplainer'
)}
)} (>${NEUTRINO_PING_THRESHOLD_MS}ms)`}
</Text>

<Text
Expand Down
2 changes: 1 addition & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@
"components.AlertModal.zombieExplainer": "Zombie channels indicate stale data on your downloaded network graph.",
"components.AlertModal.resetEGS": "Reset express graph sync data",
"components.AlertModal.neutrinoPeers": "Problematic neutrino peers",
"components.AlertModal.neutrinoExplainer": "Neutrino peers with over 200ms ping time can cause performance issues in the app.",
"components.AlertModal.neutrinoExplainer": "Neutrino peers with high ping times can cause performance issues in the app.",
"components.AlertModal.reviewPeers": "Review neutrino peers list",
"views.PendingHTLCs.title": "Pending HTLCs",
"views.PendingHTLCs.noPendingHTLCs": "No pending HTLCs",
Expand Down
10 changes: 8 additions & 2 deletions stores/AlertStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import SettingsStore from './SettingsStore';
import NodeInfoStore from './NodeInfoStore';
import { localeString } from '../utils/LocaleUtils';

import {
NEUTRINO_PING_TIMEOUT_MS,
NEUTRINO_PING_THRESHOLD_MS
} from '../utils/LndMobileUtils';

const ZOMBIE_CHAN_THRESHOLD = 21000;

interface Peer {
Expand Down Expand Up @@ -60,7 +65,7 @@ export default class AlertStore {
await new Promise(async (resolve) => {
try {
const ms = await Ping.start(peer, {
timeout: 1000
timeout: NEUTRINO_PING_TIMEOUT_MS
});
console.log(`# ${peer} - ${ms}`);
results.push({
Expand All @@ -87,7 +92,8 @@ export default class AlertStore {
localeString(
'views.Settings.EmbeddedNode.NeutrinoPeers.timedOut'
) ||
(Number.isInteger(result.ms) && result.ms > 200)
(Number.isInteger(result.ms) &&
result.ms > NEUTRINO_PING_THRESHOLD_MS)
);
});

Expand Down
21 changes: 16 additions & 5 deletions utils/LndMobileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export function checkLndStreamErrorResponse(
return null;
}

export const NEUTRINO_PING_TIMEOUT_MS = 1500;
export const NEUTRINO_PING_THRESHOLD_MS = 1000;

const writeLndConfig = async (
isTestnet?: boolean,
rescan?: boolean,
Expand Down Expand Up @@ -287,7 +290,9 @@ export async function startLnd(
}

export async function chooseNeutrinoPeers(isTestnet?: boolean) {
console.log('Selecting Neutrino peers with ping times <200ms');
console.log(
`Selecting Neutrino peers with ping times <${NEUTRINO_PING_THRESHOLD_MS}ms`
);
let peers = isTestnet
? DEFAULT_NEUTRINO_PEERS_TESTNET
: DEFAULT_NEUTRINO_PEERS_MAINNET;
Expand All @@ -298,7 +303,7 @@ export async function chooseNeutrinoPeers(isTestnet?: boolean) {
await new Promise(async (resolve) => {
try {
const ms = await Ping.start(peer, {
timeout: 1000
timeout: NEUTRINO_PING_TIMEOUT_MS
});
console.log(`# ${peer} - ${ms}`);
results.push({
Expand All @@ -318,7 +323,10 @@ export async function chooseNeutrinoPeers(isTestnet?: boolean) {
}

let filteredResults = results.filter((result: any) => {
return Number.isInteger(result.ms) && result.ms < 200;
return (
Number.isInteger(result.ms) &&
result.ms < NEUTRINO_PING_THRESHOLD_MS
);
});

if (filteredResults.length < 3 && !isTestnet) {
Expand All @@ -328,7 +336,7 @@ export async function chooseNeutrinoPeers(isTestnet?: boolean) {
await new Promise(async (resolve) => {
try {
const ms = await Ping.start(peer, {
timeout: 1000
timeout: NEUTRINO_PING_TIMEOUT_MS
});
console.log(`# ${peer} - ${ms}`);
results.push({
Expand All @@ -349,7 +357,10 @@ export async function chooseNeutrinoPeers(isTestnet?: boolean) {
}

filteredResults = results.filter((result: any) => {
return Number.isInteger(result.ms) && result.ms < 200;
return (
Number.isInteger(result.ms) &&
result.ms < NEUTRINO_PING_THRESHOLD_MS
);
});

const selectedPeers: string[] = [];
Expand Down
20 changes: 13 additions & 7 deletions views/Settings/EmbeddedNode/Peers/NeutrinoPeers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
WarningMessage,
ErrorMessage
} from '../../../../components/SuccessErrorMessage';
import LoadingIndicator from '../../../../components/LoadingIndicator';

import SettingsStore, {
DEFAULT_NEUTRINO_PEERS_MAINNET,
Expand All @@ -26,7 +27,10 @@ import SettingsStore, {
import { localeString } from '../../../../utils/LocaleUtils';
import { restartNeeded } from '../../../../utils/RestartUtils';
import { themeColor } from '../../../../utils/ThemeUtils';
import LoadingIndicator from '../../../../components/LoadingIndicator';
import {
NEUTRINO_PING_THRESHOLD_MS,
NEUTRINO_PING_TIMEOUT_MS
} from '../../../../utils/LndMobileUtils';

import Stopwatch from '../../../../assets/images/SVG/Stopwatch.svg';

Expand Down Expand Up @@ -128,7 +132,7 @@ export default class NeutrinoPeers extends React.Component<
{!pingTimeout &&
!pinging &&
pingHost &&
pingTime <= 100 && (
pingTime <= 200 && (
<SuccessMessage
message={pingTimeMsg}
dismissable
Expand All @@ -137,8 +141,8 @@ export default class NeutrinoPeers extends React.Component<
{!pingTimeout &&
!pinging &&
pingHost &&
pingTime < 200 &&
pingTime > 100 && (
pingTime < NEUTRINO_PING_THRESHOLD_MS &&
pingTime > 200 && (
<WarningMessage
message={pingTimeMsg}
dismissable
Expand All @@ -147,7 +151,7 @@ export default class NeutrinoPeers extends React.Component<
{!pingTimeout &&
!pinging &&
pingHost &&
pingTime >= 200 && (
pingTime >= NEUTRINO_PING_THRESHOLD_MS && (
<ErrorMessage
message={pingTimeMsg}
dismissable
Expand Down Expand Up @@ -275,7 +279,8 @@ export default class NeutrinoPeers extends React.Component<
await Ping.start(
addPeer,
{
timeout: 1000
timeout:
NEUTRINO_PING_TIMEOUT_MS
}
);
this.setState({
Expand Down Expand Up @@ -390,7 +395,8 @@ export default class NeutrinoPeers extends React.Component<
await Ping.start(
item,
{
timeout: 1000
timeout:
NEUTRINO_PING_TIMEOUT_MS
}
);
this.setState(
Expand Down
Loading