diff options
| author | Your Name <you@example.com> | 2026-05-27 17:29:28 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-27 17:29:28 +0530 |
| commit | f5b83c28c63fa1e9a5ff5e82782967e6bb9cfa96 (patch) | |
| tree | dd64164baf69b8cc7f825c65892cabd0c4a4e876 /src/main.rs | |
| parent | 319f44139bc668a4fa59d4c4361f442b3f87b95c (diff) | |
Fix discovery: use fetch_events_from with index_relays only
The nostr-sdk pool fetch_events returns empty when most relays are dead.
Target only the known-working index relays for discovery queries.
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index c7fa23a..d28fbe2 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -142,6 +142,7 @@ async fn run_daemon(config: config::ResolvedConfig, db: db::MirrorDb) -> Result< | |||
| 142 | let healthy = Arc::new(healthy); | 142 | let healthy = Arc::new(healthy); |
| 143 | 143 | ||
| 144 | let relay_urls = config.relay_urls(); | 144 | let relay_urls = config.relay_urls(); |
| 145 | let index_relays = config.discovery.index_relays.clone(); | ||
| 145 | let nostr_client = build_nostr_client(&relay_urls); | 146 | let nostr_client = build_nostr_client(&relay_urls); |
| 146 | nostr_client.connect().await; | 147 | nostr_client.connect().await; |
| 147 | 148 | ||
| @@ -149,6 +150,7 @@ async fn run_daemon(config: config::ResolvedConfig, db: db::MirrorDb) -> Result< | |||
| 149 | let nostr_mirror = nostr_mirror::NostrMirror::new(nostr_client.clone()); | 150 | let nostr_mirror = nostr_mirror::NostrMirror::new(nostr_client.clone()); |
| 150 | 151 | ||
| 151 | let nip46_client_ref: Option<Arc<nip46::Nip46Client>> = nip46_client.clone(); | 152 | let nip46_client_ref: Option<Arc<nip46::Nip46Client>> = nip46_client.clone(); |
| 153 | let index_relays_ref = Arc::new(index_relays); | ||
| 152 | 154 | ||
| 153 | let mut interval = tokio::time::interval(std::time::Duration::from_secs( | 155 | let mut interval = tokio::time::interval(std::time::Duration::from_secs( |
| 154 | config.discovery.poll_interval_secs, | 156 | config.discovery.poll_interval_secs, |
| @@ -168,6 +170,7 @@ async fn run_daemon(config: config::ResolvedConfig, db: db::MirrorDb) -> Result< | |||
| 168 | &config, | 170 | &config, |
| 169 | &db, | 171 | &db, |
| 170 | &nostr_client, | 172 | &nostr_client, |
| 173 | &index_relays_ref, | ||
| 171 | &mirror, | 174 | &mirror, |
| 172 | &nostr_mirror, | 175 | &nostr_mirror, |
| 173 | &healthy, | 176 | &healthy, |
| @@ -197,6 +200,7 @@ async fn mirror_cycle( | |||
| 197 | config: &Arc<config::ResolvedConfig>, | 200 | config: &Arc<config::ResolvedConfig>, |
| 198 | db: &Arc<db::MirrorDb>, | 201 | db: &Arc<db::MirrorDb>, |
| 199 | nostr_client: &nostr_sdk::Client, | 202 | nostr_client: &nostr_sdk::Client, |
| 203 | index_relays: &Arc<Vec<String>>, | ||
| 200 | mirror: &git_mirror::GitMirror, | 204 | mirror: &git_mirror::GitMirror, |
| 201 | nostr_mirror: &nostr_mirror::NostrMirror, | 205 | nostr_mirror: &nostr_mirror::NostrMirror, |
| 202 | servers: &Arc<Vec<health::GraspServer>>, | 206 | servers: &Arc<Vec<health::GraspServer>>, |
| @@ -205,7 +209,7 @@ async fn mirror_cycle( | |||
| 205 | tracing::info!("starting mirror cycle"); | 209 | tracing::info!("starting mirror cycle"); |
| 206 | 210 | ||
| 207 | let relay_urls = config.relay_urls(); | 211 | let relay_urls = config.relay_urls(); |
| 208 | let repos = discovery::discover_repos_from_relays(nostr_client, &config.npubs, &relay_urls) | 212 | let repos = discovery::discover_repos_from_relays(nostr_client, &config.npubs, index_relays, &relay_urls) |
| 209 | .await?; | 213 | .await?; |
| 210 | 214 | ||
| 211 | tracing::info!(count = repos.len(), "discovered repos"); | 215 | tracing::info!(count = repos.len(), "discovered repos"); |
| @@ -337,6 +341,7 @@ async fn run_mirror_once(config: config::ResolvedConfig, db: db::MirrorDb) -> Re | |||
| 337 | .collect(); | 341 | .collect(); |
| 338 | 342 | ||
| 339 | let relay_urls = config.relay_urls(); | 343 | let relay_urls = config.relay_urls(); |
| 344 | let index_relays = Arc::new(config.discovery.index_relays.clone()); | ||
| 340 | let nostr_client = build_nostr_client(&relay_urls); | 345 | let nostr_client = build_nostr_client(&relay_urls); |
| 341 | nostr_client.connect().await; | 346 | nostr_client.connect().await; |
| 342 | 347 | ||
| @@ -348,6 +353,7 @@ async fn run_mirror_once(config: config::ResolvedConfig, db: db::MirrorDb) -> Re | |||
| 348 | &config, | 353 | &config, |
| 349 | &db, | 354 | &db, |
| 350 | &nostr_client, | 355 | &nostr_client, |
| 356 | &index_relays, | ||
| 351 | &mirror, | 357 | &mirror, |
| 352 | &nostr_mirror, | 358 | &nostr_mirror, |
| 353 | &healthy, | 359 | &healthy, |