diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-05-01 20:20:18 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-05-01 20:28:19 +0000 |
| commit | dae4e06a9a1b221986d0ba1a8b875d0a3ca33f8e (patch) | |
| tree | 7de51b385484f30c2d103091234213c4f4a93b24 /src | |
| parent | 59e467b423e0ba66c30c7f1b7d41d47d938615de (diff) | |
fix: filter run_list state candidates by current remote's maintainers
when a repo has multiple nostr:// remotes sharing the same identifier,
relays can return state events authored by maintainers of the other
remote. without filtering, the newest event wins regardless of author,
pointing refs at the wrong commits.
state event candidates in run_list are now filtered to maintainers of
the current remote's repo announcement.
Diffstat (limited to 'src')
| -rw-r--r-- | src/bin/git_remote_nostr/list.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/bin/git_remote_nostr/list.rs b/src/bin/git_remote_nostr/list.rs index 23b3b98..a17090e 100644 --- a/src/bin/git_remote_nostr/list.rs +++ b/src/bin/git_remote_nostr/list.rs | |||
| @@ -58,10 +58,14 @@ pub async fn run_list( | |||
| 58 | // (b) already available locally. | 58 | // (b) already available locally. |
| 59 | // This prevents advertising refs whose git objects haven't been pushed to | 59 | // This prevents advertising refs whose git objects haven't been pushed to |
| 60 | // any server yet, which would cause `git clone` / `git fetch` to fail. | 60 | // any server yet, which would cause `git clone` / `git fetch` to fail. |
| 61 | // | ||
| 62 | // filter by maintainers to avoid state events from other remotes with the | ||
| 63 | // same identifier being selected when they have a newer created_at | ||
| 61 | let mut candidates: Vec<&nostr::Event> = fetch_report | 64 | let mut candidates: Vec<&nostr::Event> = fetch_report |
| 62 | .state_per_relay | 65 | .state_per_relay |
| 63 | .values() | 66 | .values() |
| 64 | .filter_map(|maybe| maybe.as_ref()) | 67 | .filter_map(|maybe| maybe.as_ref()) |
| 68 | .filter(|event| repo_ref.maintainers.contains(&event.pubkey)) | ||
| 65 | .collect(); | 69 | .collect(); |
| 66 | // Sort newest-first (by created_at, then by id for tie-breaking). | 70 | // Sort newest-first (by created_at, then by id for tie-breaking). |
| 67 | candidates.sort_by(|a, b| { | 71 | candidates.sort_by(|a, b| { |