-
Notifications
You must be signed in to change notification settings - Fork 5
Multi relay support #757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi relay support #757
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements dynamic multi-relay support by deriving relay connections from Nostr contacts with an upper limit. The system now connects to trusted and participant contact relays in addition to user-configured relays, automatically refreshing connections when contacts are added.
Key Changes
- Added
max_relaysconfiguration field to limit total relay connections (defaults to 50) - Implemented relay calculation algorithm prioritizing trusted contacts over participants
- Added automatic relay refresh on contact addition/update
- Added
get_all()method to NostrContactStoreApi for retrieving all contacts
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/bcr-ebill-api/src/lib.rs | Added max_relays field to NostrConfig with default implementation |
| crates/bcr-ebill-wasm/src/lib.rs | Hardcoded max_relays to 50 in WASM initialization |
| crates/bcr-ebill-wasm/src/context.rs | Updated NostrClient creation to pass nostr_contact_store |
| crates/bcr-ebill-persistence/src/nostr.rs | Added get_all() method to NostrContactStoreApi trait |
| crates/bcr-ebill-persistence/src/db/nostr_contact_store.rs | Implemented get_all() method for SurrealDB store |
| crates/bcr-ebill-transport/src/lib.rs | Added initial relay refresh on client creation and passed contact store |
| crates/bcr-ebill-transport/src/nostr.rs | Implemented relay calculation, refresh logic, and comprehensive tests |
| crates/bcr-ebill-transport/src/handler/nostr_contact_processor.rs | Added relay refresh trigger on contact upsert |
| crates/bcr-ebill-transport/src/handler/mod.rs | Updated mock to include new get_all() method |
| crates/bcr-ebill-transport/src/test_utils.rs | Updated test config and mocks with new get_all() method |
| crates/bcr-ebill-api/src/tests/mod.rs | Added config tests and updated mocks |
| .gitignore | Added .worktrees/ directory for git worktrees |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||
zupzup
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
codingpeanut157
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comments left on the code
LGTM
User description
📝 Description
Derive relay set from our nostr contacts with upper limit. We only connect to trusted and participant relays for now. Try to have at least one relay per contact (but try to fit all). Update relays on contact add. I need a bunch of relays to actually test all behaviors (especially the max total).
Relates to #613
✅ Checklist
Please ensure the following tasks are completed before requesting a review:
cargo fmt.cargo clippy.🚀 Changes Made
📋 Review Guidelines
Please focus on the following while reviewing:
PR Type
Enhancement
Description
Add dynamic relay management based on Nostr contacts
get_all()method to NostrContactStoreApi for fetching all contactsAdd
max_relaysconfiguration field with default of 50Implement comprehensive relay calculation and update logic
Add extensive test coverage for relay calculation algorithm
Diagram Walkthrough
File Walkthrough
2 files
Add max_relays config field with default valueAdd nostr_max_relays config field to WASM Config3 files
Add get_all() to mock and update test configAdd get_all() to mock NostrContactStore implementationAdd get_all() to mock and update test config6 files
Add get_all() method to NostrContactStoreApi traitImplement get_all() to fetch all contacts from storeAdd relay refresh trigger on contact updatesPass contact store and trigger initial relay refreshImplement relay calculation and refresh logic with testsPass contact store to create_nostr_clients function