upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 659de05..31afaf5 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -442,18 +442,27 @@ void ThreadBtfAccept(void* parg)
442 Sleep(5000); 442 Sleep(5000);
443 } 443 }
444 size_t iRelay = 0; 444 size_t iRelay = 0;
445 bool fPicked = false;
445 loop 446 loop
446 { 447 {
447 if (fShutdown) 448 if (fShutdown)
448 return; 449 return;
449 if (vBtfMeetingRelays.empty()) 450 // Curated seeds + relays discovered from Nostr announcements.
451 vector<string> relays = BtfAllRelays();
452 if (relays.empty())
450 { 453 {
451 Sleep(10000); // no meeting relay configured 454 Sleep(10000); // no meeting relay configured
452 continue; 455 continue;
453 } 456 }
457 // Random start spreads nodes across all relays (incl. volunteer ones).
458 if (!fPicked)
459 {
460 iRelay = (size_t)GetRand(relays.size());
461 fPicked = true;
462 }
454 // Stick to the current relay while it works; on failure, fail over to 463 // Stick to the current relay while it works; on failure, fail over to
455 // the next seed so a DDoS'd/blocked relay IP can't keep us offline. 464 // the next one so a DDoS'd/blocked relay IP can't keep us offline.
456 string strMeeting = vBtfMeetingRelays[iRelay % vBtfMeetingRelays.size()]; 465 string strMeeting = relays[iRelay % relays.size()];
457 size_t colon = strMeeting.rfind(':'); 466 size_t colon = strMeeting.rfind(':');
458 if (colon == string::npos) 467 if (colon == string::npos)
459 { 468 {