fix(swift-example-app): point regtest+docker SPV at dashmate seed port#3589
Conversation
`CoreContentView.startSync` previously always read `localCorePeers`
from `UserDefaults` whenever `useLocalhostCore` was set. Both flags
are shared across networks, but the OptionsView UI populates them
through two mutually-exclusive toggles ("Use Docker Setup" on regtest,
"Use Custom SPV Peers" elsewhere) that never sync state. Result:
- Enable Custom SPV Peers on testnet → seeds `localCorePeers =
"127.0.0.1:19999"`.
- Switch to regtest + Use Docker Setup → flips `useLocalhostCore = true`
but doesn't touch `localCorePeers`.
- SPV asks dashmate's regtest cluster to handshake on `19999` (testnet's
port) and silently spins on connection refused.
Replaced the inline lookup with a `spvPeerOverride()` helper that
selects the peer list based on `(currentNetwork, useDockerSetup)`:
- regtest + docker → `["127.0.0.1:20301"]` (dashmate's `local_seed`
P2P port for the typical 3-node preset: base 20001 from
`getLocalConfigFactory.js` + `i*100` per setup task with seed at
`i = nodeCount`). Ignores `localCorePeers` entirely so a stale
testnet/mainnet value can't bleed in.
- non-regtest + `useLocalhostCore` → parses `localCorePeers` as before
for the user's custom-peer flow.
- otherwise → empty list, FFI uses the network's built-in seed nodes.
`startSync` derives `restrictToConfiguredPeers` from whether the
override returned anything, so the call site no longer juggles two
flags.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Review GateCommit:
|
|
✅ DashSDKFFI.xcframework built for this PR.
SwiftPM (host the zip at a stable URL, then use): .binaryTarget(
name: "DashSDKFFI",
url: "https://your.cdn.example/DashSDKFFI.xcframework.zip",
checksum: "e1f796da4fdda0a2f814f455979201f26e47f64b909cbb8e3c757d9bbfa0e78d"
)Xcode manual integration:
|
Issue being fixed or feature implemented
When the user enables "Use Docker Setup" on regtest, SPV silently fails to connect:
```
INFO dash_spv::network::manager: Reconnecting to exclusive peer: 127.0.0.1:19999
INFO dash_spv::network::peer: Peer 127.0.0.1:19999 closed connection (EOF)
ERROR dash_spv::network::handshake: Error receiving message during handshake: Peer disconnected
WARN dash_spv::network::manager: Handshake failed with 127.0.0.1:19999: Peer disconnected
```
`19999` is testnet's standard P2P port. dashmate's local cluster doesn't run on it — its seed lives at `127.0.0.1:20301` for the default 3-node local preset.
The bug is bleed-through between two mutually-exclusive UI surfaces that share the same `UserDefaults` keys:
What was done?
Replaced the inline `UserDefaults` lookup in `startSync` with a `spvPeerOverride()` helper that selects the peer list based on `(currentNetwork, useDockerSetup)`:
`startSync` derives `restrictToConfiguredPeers` from whether the override returned anything, so the call site no longer juggles two flags.
How Has This Been Tested?
Breaking Changes
None. The non-regtest custom-peers flow reads `localCorePeers` exactly as before. The regtest+docker flow now uses a hard-coded peer; users with a non-default dashmate `nodeCount` (where the seed lands at a different port) will need either a non-default-aware override or to run the typical 3-node preset. Future PR could surface a "Docker Seed Port" override field in OptionsView for that edge case — not blocking the bug fix.
Checklist:
🤖 Generated with Claude Code