upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sync/mod.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/sync/mod.rs b/src/sync/mod.rs
index 70f9dd7..479ab33 100644
--- a/src/sync/mod.rs
+++ b/src/sync/mod.rs
@@ -1246,7 +1246,7 @@ impl SyncManager {
1246 1246
1247 // 6. Connect to bootstrap relay if configured 1247 // 6. Connect to bootstrap relay if configured
1248 if let Some(ref bootstrap_url) = self.bootstrap_relay_url.clone() { 1248 if let Some(ref bootstrap_url) = self.bootstrap_relay_url.clone() {
1249 self.register_relay(bootstrap_url.clone()).await; 1249 self.register_relay(bootstrap_url.clone(), true).await;
1250 self.try_connect_relay(bootstrap_url).await; 1250 self.try_connect_relay(bootstrap_url).await;
1251 } 1251 }
1252 1252
@@ -1356,7 +1356,7 @@ impl SyncManager {
1356 ); 1356 );
1357 1357
1358 // Register relay (creates RelayConnection, initializes RelayState, updates metrics) 1358 // Register relay (creates RelayConnection, initializes RelayState, updates metrics)
1359 self.register_relay(action.relay_url.clone()).await; 1359 self.register_relay(action.relay_url.clone(), false).await;
1360 self.try_connect_relay(&action.relay_url).await; 1360 self.try_connect_relay(&action.relay_url).await;
1361 // Connection will trigger handle_connect_or_reconnect which will process items 1361 // Connection will trigger handle_connect_or_reconnect which will process items
1362 return; 1362 return;
@@ -1868,7 +1868,7 @@ impl SyncManager {
1868 /// Also initializes RelayState if it doesn't exist. 1868 /// Also initializes RelayState if it doesn't exist.
1869 /// Does NOT connect - connection happens via try_connect_relay or retry_disconnected_relays. 1869 /// Does NOT connect - connection happens via try_connect_relay or retry_disconnected_relays.
1870 /// The RelayConnection persists forever and is reused on reconnects. 1870 /// The RelayConnection persists forever and is reused on reconnects.
1871 async fn register_relay(&mut self, relay_url: String) { 1871 async fn register_relay(&mut self, relay_url: String, is_bootstrap: bool) {
1872 // Create RelayConnection if not exists 1872 // Create RelayConnection if not exists
1873 if !self.connections.contains_key(&relay_url) { 1873 if !self.connections.contains_key(&relay_url) {
1874 // Get relay owner keys for NIP-42 authentication 1874 // Get relay owner keys for NIP-42 authentication
@@ -1892,7 +1892,7 @@ impl SyncManager {
1892 if !index.contains_key(&relay_url) { 1892 if !index.contains_key(&relay_url) {
1893 let new_state = RelayState { 1893 let new_state = RelayState {
1894 connection_status: ConnectionStatus::Disconnected, 1894 connection_status: ConnectionStatus::Disconnected,
1895 is_bootstrap: false, 1895 is_bootstrap,
1896 last_connected: None, 1896 last_connected: None,
1897 disconnected_at: None, 1897 disconnected_at: None,
1898 repos: HashSet::new(), 1898 repos: HashSet::new(),
@@ -1905,6 +1905,12 @@ impl SyncManager {
1905 index.insert(relay_url.clone(), new_state); 1905 index.insert(relay_url.clone(), new_state);
1906 true 1906 true
1907 } else { 1907 } else {
1908 // If relay already exists and is_bootstrap is true, update the flag
1909 if is_bootstrap {
1910 if let Some(state) = index.get_mut(&relay_url) {
1911 state.is_bootstrap = true;
1912 }
1913 }
1908 false 1914 false
1909 } 1915 }
1910 }; 1916 };