upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/sync/mod.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-12-10 14:36:06 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-12-10 14:37:19 +0000
commit8148c27a1350189046bc8e215f29f918dd8747f5 (patch)
tree4630db969a5f5b3e288a806ff8f85cd507820dab /src/sync/mod.rs
parente0eedf25f3218ee54563229257c1ce949bfafd10 (diff)
sync: fix connection registration issue
Diffstat (limited to 'src/sync/mod.rs')
-rw-r--r--src/sync/mod.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/sync/mod.rs b/src/sync/mod.rs
index 7a0a705..b38c4a9 100644
--- a/src/sync/mod.rs
+++ b/src/sync/mod.rs
@@ -1300,6 +1300,16 @@ impl SyncManager {
1300 state.disconnected_at = None; 1300 state.disconnected_at = None;
1301 } 1301 }
1302 1302
1303 // Store connection in HashMap BEFORE sending notification
1304 // This ensures it's available when handle_connect_or_reconnect is called
1305 self.connections.insert(relay_url.clone(), connection);
1306
1307 tracing::info!(
1308 relay = %relay_url,
1309 is_bootstrap = is_bootstrap,
1310 "Spawned relay connection"
1311 );
1312
1303 // Notify SyncManager of successful connection 1313 // Notify SyncManager of successful connection
1304 let _ = connect_tx 1314 let _ = connect_tx
1305 .send(ConnectNotification { 1315 .send(ConnectNotification {
@@ -1307,12 +1317,16 @@ impl SyncManager {
1307 }) 1317 })
1308 .await; 1318 .await;
1309 1319
1320 // Clone the connection for the event loop spawn
1321 // The stored connection is used for subscription management
1322 let connection_for_loop = self.connections.get(&relay_url).unwrap().clone();
1323
1310 // Create event channel 1324 // Create event channel
1311 let (event_tx, mut event_rx) = mpsc::channel::<RelayEvent>(1000); 1325 let (event_tx, mut event_rx) = mpsc::channel::<RelayEvent>(1000);
1312 1326
1313 // Spawn event loop 1327 // Spawn event loop with cloned connection
1314 tokio::spawn(async move { 1328 tokio::spawn(async move {
1315 connection.run_event_loop(event_tx).await; 1329 connection_for_loop.run_event_loop(event_tx).await;
1316 }); 1330 });
1317 1331
1318 // Spawn event processor 1332 // Spawn event processor