diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-11 14:12:33 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-11 14:12:33 +0000 |
| commit | fb8928f626e81f78e13e642009de9a86ea100487 (patch) | |
| tree | b5f34c8a07145d03566ad05086c811046f97f46a /src/sync | |
| parent | 0f1ea0290d1b5418ec1d22bfa7c837e767a35d6c (diff) | |
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.
Diffstat (limited to 'src/sync')
| -rw-r--r-- | src/sync/mod.rs | 22 |
1 files changed, 17 insertions, 5 deletions
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 { | |||
| 537 | } | 537 | } |
| 538 | } | 538 | } |
| 539 | 539 | ||
| 540 | // Recompute actions - will discover all repos/events again | 540 | // Re-subscribe to Layer 1 (announcements) without since filter for full discovery |
| 541 | // This is a fresh sync, so we want all announcements | ||
| 542 | let layer1_filter = filters::build_announcement_filter(None); | ||
| 543 | if let Err(e) = connection.subscribe_filter(layer1_filter).await { | ||
| 544 | tracing::error!( | ||
| 545 | relay = %relay_url, | ||
| 546 | error = %e, | ||
| 547 | "Failed to re-subscribe to Layer 1 during daily sync" | ||
| 548 | ); | ||
| 549 | } | ||
| 550 | |||
| 551 | // Recompute actions for Layer 2+3 - will discover all repos/events again | ||
| 541 | self.recompute_actions_for_relay(relay_url).await; | 552 | self.recompute_actions_for_relay(relay_url).await; |
| 542 | 553 | ||
| 543 | if let Some(ref metrics) = self.metrics { | 554 | if let Some(ref metrics) = self.metrics { |
| @@ -887,11 +898,12 @@ impl SyncManager { | |||
| 887 | tracing::info!( | 898 | tracing::info!( |
| 888 | relay = %relay_url, | 899 | relay = %relay_url, |
| 889 | is_bootstrap = is_bootstrap, | 900 | is_bootstrap = is_bootstrap, |
| 890 | "Fresh sync - subscribing to Layer 1 without since filter" | 901 | "Fresh sync - Layer 1 already subscribed, recomputing Layer 2+3" |
| 891 | ); | 902 | ); |
| 892 | // Fresh sync: Layer 1 without since | 903 | // Fresh sync: Layer 1 subscription (without since) was already established |
| 893 | // Layer 1 subscription is handled by the connection establishment | 904 | // during connect_and_subscribe() in handle_add_filters(). That call subscribes |
| 894 | // Just recompute actions for new items | 905 | // to kinds 30617+30618 for the full history. Here we only need to recompute |
| 906 | // Layer 2+3 actions based on the repos we're tracking. | ||
| 895 | self.recompute_actions_for_relay(relay_url).await; | 907 | self.recompute_actions_for_relay(relay_url).await; |
| 896 | } else { | 908 | } else { |
| 897 | // Quick reconnect: use since filter | 909 | // Quick reconnect: use since filter |