Skip to content

refactor: simplify PeerManager.add_peer - #9582

Merged
koenvanderveen merged 1 commit into
devfrom
koen/add-peer-return-early
Oct 26, 2026
Merged

koenvanderveen merged 1 commit into
devfrom
koen/add-peer-return-early

Conversation

@koenvanderveen

Copy link
Copy Markdown
Collaborator

Summary

  • Split add_peer into _return_early, _print_add_peer_start and _print_add_peer_done.
  • The cached peer is only used for the early return and is_accepting; add_peer now builds a fresh Peer and no longer changes the cached one.
  • PeerStore.set_peer and set_peers share _keep_known, which carries over info, state_at_start and the encryption bundle.
  • add_peer always reads the peer's encryption bundle (returns None until the peer publishes one). Costs one extra Drive read when sending a request.

Notes

  • Code holding an old Peer reference no longer sees the update after add_peer.
  • set_peers now keeps an old bundle when a reload brings none.

🤖 Generated with Claude Code

- Split the early return and the verbose prints into helpers.
- Build a fresh Peer instead of changing the cached one; PeerStore.set_peer
  now carries over info, state_at_start and the bundle like set_peers.
- Always read the peer's encryption bundle (None until published).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@koenvanderveen
koenvanderveen merged commit a48f18c into dev Oct 26, 2026
30 of 32 checks passed
@koenvanderveen
koenvanderveen deleted the koen/add-peer-return-early branch October 26, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant