diff options
| author | Your Name <you@example.com> | 2026-05-27 17:34:00 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-27 17:34:00 +0530 |
| commit | c21100ad4868cbe03124b61c411394a7ae2d078c (patch) | |
| tree | b8d429eed67481079d91f20be4ddc7cf1ae2868f | |
| parent | f5b83c28c63fa1e9a5ff5e82782967e6bb9cfa96 (diff) | |
Fix discovery: use separate client with only index relays
fetch_events_from requires relays in pool; use dedicated client
with only working relays and fetch_events for reliable queries.
| -rw-r--r-- | src/discovery.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/discovery.rs b/src/discovery.rs index fa2a198..a5d578c 100644 --- a/src/discovery.rs +++ b/src/discovery.rs | |||
| @@ -18,13 +18,14 @@ pub async fn discover_repos_from_relays( | |||
| 18 | client: &nostr_sdk::Client, | 18 | client: &nostr_sdk::Client, |
| 19 | npubs: &[PublicKey], | 19 | npubs: &[PublicKey], |
| 20 | index_relays: &[String], | 20 | index_relays: &[String], |
| 21 | all_relay_urls: &[String], | 21 | _all_relay_urls: &[String], |
| 22 | ) -> Result<Vec<DiscoveredRepo>> { | 22 | ) -> Result<Vec<DiscoveredRepo>> { |
| 23 | for url in all_relay_urls { | 23 | let discovery_client = nostr_sdk::Client::default(); |
| 24 | let _ = client.add_relay(url).await; | 24 | for url in index_relays { |
| 25 | discovery_client.add_relay(url).await?; | ||
| 25 | } | 26 | } |
| 26 | client.connect().await; | 27 | discovery_client.connect().await; |
| 27 | client | 28 | discovery_client |
| 28 | .wait_for_connection(std::time::Duration::from_secs(5)) | 29 | .wait_for_connection(std::time::Duration::from_secs(5)) |
| 29 | .await; | 30 | .await; |
| 30 | 31 | ||
| @@ -36,8 +37,8 @@ pub async fn discover_repos_from_relays( | |||
| 36 | .author(*pk) | 37 | .author(*pk) |
| 37 | .limit(50); | 38 | .limit(50); |
| 38 | 39 | ||
| 39 | let events = client | 40 | let events = discovery_client |
| 40 | .fetch_events_from(index_relays, filter, std::time::Duration::from_secs(30)) | 41 | .fetch_events(filter, std::time::Duration::from_secs(30)) |
| 41 | .await | 42 | .await |
| 42 | .context("failed to fetch events from relays")?; | 43 | .context("failed to fetch events from relays")?; |
| 43 | 44 | ||