From fb8928f626e81f78e13e642009de9a86ea100487 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 11 Dec 2025 14:12:33 +0000 Subject: fix(sync): add Layer 1 re-subscription to daily_sync() - Add Layer 1 (announcements) re-subscription in daily_sync() after unsubscribe_all() to ensure kinds 30617+30618 are re-established - Clarify comments in handle_connect_or_reconnect() explaining that Layer 1 subscription is established during connect_and_subscribe() Addresses implementation gaps from design vs implementation report: - Gap 1: Comments clarified (Layer 1 handled by connect_and_subscribe) - Gap 2: daily_sync() now re-subscribes to Layer 1 without since filter - Gap 3: consolidate() already had Layer 1 re-subscription (no change) All 125 unit tests and integration tests pass. --- src/sync/mod.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/sync') diff --git a/src/sync/mod.rs b/src/sync/mod.rs index c78c0e1..16c8924 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs @@ -537,7 +537,18 @@ impl SyncManager { } } - // Recompute actions - will discover all repos/events again + // Re-subscribe to Layer 1 (announcements) without since filter for full discovery + // This is a fresh sync, so we want all announcements + let layer1_filter = filters::build_announcement_filter(None); + if let Err(e) = connection.subscribe_filter(layer1_filter).await { + tracing::error!( + relay = %relay_url, + error = %e, + "Failed to re-subscribe to Layer 1 during daily sync" + ); + } + + // Recompute actions for Layer 2+3 - will discover all repos/events again self.recompute_actions_for_relay(relay_url).await; if let Some(ref metrics) = self.metrics { @@ -887,11 +898,12 @@ impl SyncManager { tracing::info!( relay = %relay_url, is_bootstrap = is_bootstrap, - "Fresh sync - subscribing to Layer 1 without since filter" + "Fresh sync - Layer 1 already subscribed, recomputing Layer 2+3" ); - // Fresh sync: Layer 1 without since - // Layer 1 subscription is handled by the connection establishment - // Just recompute actions for new items + // Fresh sync: Layer 1 subscription (without since) was already established + // during connect_and_subscribe() in handle_add_filters(). That call subscribes + // to kinds 30617+30618 for the full history. Here we only need to recompute + // Layer 2+3 actions based on the repos we're tracking. self.recompute_actions_for_relay(relay_url).await; } else { // Quick reconnect: use since filter -- cgit v1.2.3