Thanks to visit codestin.com
Credit goes to github.com

Skip to content

REF: prefer bluewallet electrum server; drop bad electrum server from…#8378

Merged
GladosBlueWallet merged 3 commits into
masterfrom
ref-electrum-default-server
Mar 5, 2026
Merged

REF: prefer bluewallet electrum server; drop bad electrum server from…#8378
GladosBlueWallet merged 3 commits into
masterfrom
ref-electrum-default-server

Conversation

@Overtorment

@Overtorment Overtorment commented Mar 4, 2026

Copy link
Copy Markdown
Member

… the list


Note

Cursor Bugbot is generating a summary for commit 2bfcc75. Configure here.

@Overtorment Overtorment requested a review from limpbrains March 4, 2026 13:06

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread blue_modules/BlueElectrum.ts

@GladosBlueWallet GladosBlueWallet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 };

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@GladosBlueWallet GladosBlueWallet merged commit 030ba4d into master Mar 5, 2026
15 checks passed
@GladosBlueWallet

Copy link
Copy Markdown
Collaborator

Unbelievable. You, [subject name here], must be the pride of [subject hometown here]!

@GladosBlueWallet GladosBlueWallet deleted the ref-electrum-default-server branch March 5, 2026 12:24
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.

5 participants