Connect relays individually and sync bootstrap state

This commit is contained in:
2026-09-10 07:44:07 +07:00
parent 3cfdffdf82
commit 18433ec239
2 changed files with 58 additions and 50 deletions
+37 -2
View File
@@ -30,6 +30,17 @@ Each is addressed below with concrete file:line references and a verified replac
## 1. `fetch_events` — one call site, and it should go too
> **Status: done.** `bootstrap_user` now calls `sync_bootstrap_only` (the
> same helper `Backend::sync_bootstrap` already used) against
> `filters::grasp_list(public_key)`, then reads the result back out through
> the existing `user_grasp_list_servers` query helper instead of hand-rolling
> a second `BTreeSet<Event>` → `Vec<Event>` collect. `client.add_relay(url)`
> no longer round-trips through `.as_str()`, and connects with
> `.and_connect()` (see §8) instead of a trailing pool-wide `client.connect()`.
> `grep -rn "fetch_events" crates/` now returns nothing in the whole
> workspace. `cargo check --workspace`, `cargo clippy -p signed_state`, and
> `cargo test -p signed_state` (24 tests, unchanged) all pass.
```
grep -rn "fetch_events" crates/
crates/signed_state/src/backend.rs:1065
@@ -574,6 +585,26 @@ to `RepoListStore`.
## 8. Relay add/connect: stop round-tripping through strings, stop reconnecting the whole pool
> **Status: done.** Every `add_relay` call site now passes the `RelayUrl`
> directly (no `.as_str()`/`ToString` round trip) and chains `.and_connect()`
> instead of a separate, pool-wide `client.connect()`/`client.connect_relay()`
> call: `Backend::bootstrap` (both the `BOOTSTRAP_RELAYS` and `INDEXER_RELAYS`
> loops), `bootstrap_user`, `create_repository`, `publish_local_repo`,
> `connect_repo_relays`, and `stage_event_on_relay`. `Backend::add_relays` is
> deleted entirely — its two callers (`create_repository`, `publish_local_repo`)
> now capture `client` once before the surrounding `cx.spawn` and loop
> `client.add_relay(url).and_connect().await.ok();` directly over the
> `Vec<RelayUrl>` they already had, with no `Vec<String>` conversion at all.
> Verified `.and_connect()` (`client/api/add.rs`) and pool-wide `.connect()`
> semantics (`client/api/connect.rs`) against the pinned nostr-sdk source
> before making the change (see chat history), plus that `pool.sync()`
> requires relays to already be present in the pool
> (`pool/mod.rs:679-693`, `relays.get(&url).ok_or_else(...)`), which is why
> `sync_bootstrap_only`/`bootstrap_user` can safely assume `BOOTSTRAP_RELAYS`
> are already added by `Backend::bootstrap` before any sync runs.
> `cargo check --workspace`, `cargo clippy -p signed_state`, and
> `cargo test -p signed_state` (24 tests) all pass.
Flagged example (`backend.rs:1071-1074`):
```rust
@@ -1257,14 +1288,18 @@ method.
bug in `RepoDetailView`/`NewPullRequestView` along the way.
Done: both halves are complete, see §6 and §14 for details.
3. **Fix the relay add/connect calls** (§8): drop `.as_str()`/`ToString`
3. **Fix the relay add/connect calls** (§8): drop `.as_str()`/`ToString`
round trips, replace `add_relay` + blanket `client.connect()`/
`connect_relay` pairs with `add_relay(url).and_connect()`, and delete
`Backend::add_relays`. Mechanical, no behavior change beyond "connect
only what was just added."
4. **Fix `bootstrap_user`** to sync+query instead of `fetch_events` (§1).
Done: see §8 for the full list of call sites and verification notes.
4.**Fix `bootstrap_user`** to sync+query instead of `fetch_events` (§1).
One function, fully covered by existing tests for
`latest_grasp_list_servers`.
Done: see §1. `fetch_events` no longer appears anywhere in the workspace.
5. **Generalize the 3 `signed_git` URL-list signatures** to `&[impl AsRef<str>]`
(§15), then delete the now-redundant `.map(ToString::to_string).collect()`
at all 7 call sites. Self-contained to `signed_git`'s public API plus a