Skip to content

Add Monero node ping with latency and auto-select#9336

Merged
omurovch merged 2 commits into
version/0.50from
monero-nodes
Jun 24, 2026
Merged

Add Monero node ping with latency and auto-select#9336
omurovch merged 2 commits into
version/0.50from
monero-nodes

Conversation

@omurovch

@omurovch omurovch commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

#9291

Summary by CodeRabbit

  • New Features

    • Added an auto-select option for Monero nodes, letting the app choose the fastest available node automatically.
    • Node list now shows latency and reachability status, including loading, reachable, and unreachable indicators.
  • Bug Fixes

    • Improved Monero startup behavior so active wallets refresh after node selection changes.
    • Updated network access rules to better support Monero node checks while keeping general cleartext traffic restricted.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 898fa5d5-81ea-4f5a-9272-600a5ad73371

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds Monero node auto-selection at startup: MoneroNodeManager pings all configured nodes, picks the fastest, and persists the result. AdapterFactory defers Monero adapter creation until resolution completes, after which WalletManager.refreshActiveWallets() re-initializes adapters. The network settings UI gains per-node ping badges and an auto-select toggle. A network security config restricts cleartext traffic to an allowlist of Monero node domains.

Changes

Monero Node Auto-Select and Ping UI

Layer / File(s) Summary
Network security config and MoneroKit version bump
gradle/libs.versions.toml, app/src/main/res/xml/network_security_config.xml, app/src/main/AndroidManifest.xml
Bumps moneroKit version hash; introduces network_security_config.xml blocking cleartext globally but allowlisting specific Monero node domains; wires it to the <application> element.
Auto-select persistence in BlockchainSettingsStorage
app/src/main/java/.../core/storage/BlockchainSettingsStorage.kt
Adds keyMoneroAutoSelect constant, moneroAutoSelect() reader (defaults false), and saveMoneroAutoSelect(enabled) writer.
MoneroNodeManager: auto-select, ping, and node list
app/src/main/java/.../core/managers/MoneroNodeManager.kt
Accepts Context, removes two default nodes, adds autoSelectEnabled (storage-backed), @Volatile isResolvingFastestNode, autoSelectFastestNodeOnStartup() with try/finally persist, and splits save()/persist() so only save() emits currentNodeUpdatedFlow.
AdapterFactory gating and WalletManager refresh
app/src/main/java/.../core/factories/AdapterFactory.kt, app/src/main/java/.../core/managers/WalletManager.kt
AdapterFactory.getAdapter returns null for Monero while isResolvingFastestNode is true; WalletManager.refreshActiveWallets() re-emits active wallets to re-initialize adapters after resolution.
App.kt startup orchestration
app/src/main/java/.../core/App.kt
Passes this (Context) to MoneroNodeManager; adds a startup coroutine calling autoSelectFastestNodeOnStartup() then walletManager.refreshActiveWallets(); reorganizes imports.
MoneroNetworkViewModel: PingState types, ping logic, auto-select toggle
app/src/main/java/.../modules/moneronetwork/MoneroNetworkViewModel.kt
Adds PingState sealed interface (Loading/Unreachable/Reachable with Level enum), pingStates map, pingJob, pingNodes() coroutine, selectFastestNode(), and extends ViewItem/ViewState with ping and autoSelectEnabled fields.
MoneroNetworkPage: AutoSelectCell, MoneroNodeRow, PingBadge
app/src/main/java/.../modules/moneronetwork/MoneroNetworkPage.kt, app/src/main/res/values/strings.xml, translation_snapshot.json
Adds AutoSelectCell toggle, MoneroNodeRow with gated click, and PingBadge composable (spinner / unreachable / latency level). Wires refresh menu item and gates node click on auto-select state. Adds four string resources.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant MoneroNodeManager
    participant AdapterFactory
    participant WalletManager

    rect rgba(255, 165, 0, 0.5)
        Note over App,WalletManager: Startup auto-select flow
    end
    App->>MoneroNodeManager: autoSelectFastestNodeOnStartup()
    MoneroNodeManager->>MoneroNodeManager: pingNodes(allConfiguredNodes)
    MoneroNodeManager->>MoneroNodeManager: persist(fastestNode) [in finally]
    MoneroNodeManager-->>MoneroNodeManager: isResolvingFastestNode = false
    App->>WalletManager: refreshActiveWallets()
    WalletManager->>AdapterFactory: notifyActiveWallets() triggers getAdapter()
    AdapterFactory->>MoneroNodeManager: isResolvingFastestNode? false
    AdapterFactory-->>WalletManager: MoneroAdapter.create(currentNode)
Loading
sequenceDiagram
    participant MoneroNetworkViewModel
    participant MoneroNodeManager
    participant MoneroKitPing

    MoneroNetworkViewModel->>MoneroNetworkViewModel: pingNodes() — set all Loading, cancel prior job
    MoneroNetworkViewModel->>MoneroNodeManager: pingNodes(serialized list)
    MoneroNodeManager->>MoneroKitPing: MoneroKit.pingNodes(...)
    MoneroKitPing-->>MoneroNodeManager: NodePingResult[]
    MoneroNodeManager-->>MoneroNetworkViewModel: results
    MoneroNetworkViewModel->>MoneroNetworkViewModel: map to PingState.Reachable/Unreachable
    alt autoSelectEnabled
        MoneroNetworkViewModel->>MoneroNetworkViewModel: selectFastestNode()
        MoneroNetworkViewModel->>MoneroNodeManager: save(fastestNode)
    end
    MoneroNetworkViewModel->>MoneroNetworkViewModel: emit updated UI state
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • abdrasulov
  • rafaelekol
  • esen
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: Monero node pinging, latency display, and auto-select behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch monero-nodes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

omurovch and others added 2 commits June 24, 2026 16:51
- Show per-node response time / Unreachable on the Monero network page
  via MoneroKit.pingNodes, with a Refresh action.
- Add Auto-Select switch that uses the fastest reachable node and
  disables manual selection while enabled.
- Auto-select the fastest node at app startup; defer Monero adapter
  creation until it resolves so the wallet connects once (no reconnect
  churn), without delaying other blockchains.
- Scope cleartext to default node domains in network security config.
- Drop unreachable monerodevs and boldsuck default nodes.
@omurovch omurovch merged commit 7e201bd into version/0.50 Jun 24, 2026
2 checks passed
@omurovch omurovch deleted the monero-nodes branch June 24, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants