REF: prefer bluewallet electrum server; drop bad electrum server from…#8378
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Co-authored-by: Overtorment <[email protected]>
GladosBlueWallet
left a comment
There was a problem hiding this comment.
I ran your electrum obstacle course. Here are the places you might want to add padding before users faceplant.
| let connectionAttempt: number = 0; | ||
| let currentPeerIndex = Math.floor(Math.random() * hardcodedPeers.length); | ||
| let currentPeerIndex = hardcodedPeers.findIndex(peer => peer.host === defaultPeer.host && peer.ssl === defaultPeer.ssl); | ||
| if (currentPeerIndex < 0) currentPeerIndex = 0; |
There was a problem hiding this comment.
This matches only host + ssl. If defaultPeer ever becomes tcp-based (or you have mixed tcp/ssl entries), findIndex goes -1 and you quietly pick index 0. Consider comparing on host + (ssl||tcp) after normalizing, so prefer-default does not degrade into prefer-first.
| let currentPeerIndex = Math.floor(Math.random() * hardcodedPeers.length); | ||
| let currentPeerIndex = hardcodedPeers.findIndex(peer => peer.host === defaultPeer.host && peer.ssl === defaultPeer.ssl); | ||
| if (currentPeerIndex < 0) currentPeerIndex = 0; | ||
| let latestBlock: { height: number; time: number } | { height: undefined; time: undefined } = { height: undefined, time: undefined }; |
There was a problem hiding this comment.
If you want a deterministic fallback, make it explicit (e.g., Math.max(0, idx)) and consider logging once. Silent fallback is how you end up debugging random server selection later.
| @@ -214,7 +214,7 @@ function getCurrentPeer() { | |||
| function getNextPeer() { | |||
| const peer = getCurrentPeer(); | |||
There was a problem hiding this comment.
Naming: getNextPeer returns the current peer and then increments. Fine, but the name invites a future off-by-one reintroduction. Rename to getAndAdvancePeer (or update docs) to keep the next refactor from breaking rotation again.
| currentPeerIndex++; | ||
| if (currentPeerIndex + 1 >= hardcodedPeers.length) currentPeerIndex = 0; | ||
| if (currentPeerIndex >= hardcodedPeers.length) currentPeerIndex = 0; | ||
| return peer; |
There was a problem hiding this comment.
Wrap condition fix is good, but consider guarding hardcodedPeers.length === 0 anyway. Undefined peers have a habit of escaping into logs and crashing the party.
|
Unbelievable. You, [subject name here], must be the pride of [subject hometown here]! |
… the list
Note
Cursor Bugbot is generating a summary for commit 2bfcc75. Configure here.