From d9ebb7af02fbc277bb5d4ab1510871bcf1358ec9 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Sat, 15 Jun 2024 23:39:19 -0400 Subject: [PATCH 1/2] Settings: Neutrino: add optimize peers button --- locales/en.json | 1 + .../EmbeddedNode/Peers/NeutrinoPeers.tsx | 54 ++++++++++++++----- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/locales/en.json b/locales/en.json index 5551cd6e1..fee1c92b4 100644 --- a/locales/en.json +++ b/locales/en.json @@ -822,6 +822,7 @@ "views.Settings.EmbeddedNode.NeutrinoPeers.allowingOtherPeers": "Allowing connections to other peers.", "views.Settings.EmbeddedNode.NeutrinoPeers.notAllowingOtherPeers": "Not allowing connections to other peers.", "views.Settings.EmbeddedNode.NeutrinoPeers.timedOut": "Ping timed out", + "views.Settings.EmbeddedNode.NeutrinoPeers.optimize": "Optimize peers selection", "views.Settings.EmbeddedNode.ZeroConfPeers.title": "Zero conf Peers", "views.Settings.EmbeddedNode.ZeroConfPeers.subtitle": "Set the peers you would like to accept zero conf lightning channels from, other than the LSP.", "views.Settings.EmbeddedNode.ExpressGraphSync.title": "Express Graph Sync", diff --git a/views/Settings/EmbeddedNode/Peers/NeutrinoPeers.tsx b/views/Settings/EmbeddedNode/Peers/NeutrinoPeers.tsx index f35fb5cb4..5c8b40b57 100644 --- a/views/Settings/EmbeddedNode/Peers/NeutrinoPeers.tsx +++ b/views/Settings/EmbeddedNode/Peers/NeutrinoPeers.tsx @@ -24,6 +24,7 @@ import SettingsStore, { DEFAULT_NEUTRINO_PEERS_TESTNET } from '../../../../stores/SettingsStore'; +import { chooseNeutrinoPeers } from '../../../../utils/LndMobileUtils'; import { localeString } from '../../../../utils/LocaleUtils'; import { restartNeeded } from '../../../../utils/RestartUtils'; import { themeColor } from '../../../../utils/ThemeUtils'; @@ -46,7 +47,7 @@ interface NeutrinoPeersState { pingTime: number; pingTimeout: boolean; pingHost: string; - pinging: boolean; + loading: boolean; } @inject('SettingsStore') @@ -62,7 +63,7 @@ export default class NeutrinoPeers extends React.Component< pingTime: 0, pingTimeout: false, pingHost: '', - pinging: false + loading: false }; remove = (arrOriginal, elementToRemove) => { @@ -95,7 +96,7 @@ export default class NeutrinoPeers extends React.Component< pingTime, pingTimeout, pingHost, - pinging + loading } = this.state; const { updateSettings, embeddedLndNetwork }: any = SettingsStore; @@ -128,9 +129,9 @@ export default class NeutrinoPeers extends React.Component< navigation={navigation} /> - {pinging && } + {loading && } {!pingTimeout && - !pinging && + !loading && pingHost && pingTime <= 200 && ( )} {!pingTimeout && - !pinging && + !loading && pingHost && pingTime < NEUTRINO_PING_THRESHOLD_MS && pingTime > 200 && ( @@ -149,7 +150,7 @@ export default class NeutrinoPeers extends React.Component< /> )} {!pingTimeout && - !pinging && + !loading && pingHost && pingTime >= NEUTRINO_PING_THRESHOLD_MS && ( )} - {!pinging && pingHost && !!pingTimeout && ( + {!loading && pingHost && !!pingTimeout && ( + {embeddedLndNetwork === 'Mainnet' && ( + +