Skip to content
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

Discover and subscribe to documents based on short code #17

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

sandreae
Copy link
Member

@sandreae sandreae commented Dec 27, 2024

This PR implements the logic required for discovering documents by their short code and then subscribing to them. To do this we introduce a new "document discovery" overlay network which allows peers to resolve a short code to the full document topic (which can then be used for subscribing to document events).

  • introduce AardvarkTopic which has one variant for document discovery, and one for document message gossip and sync
  • introduce 6 character ShortCode based on the TextDocument hash
  • change TextDocument to contain the public key of the author who created it and a timestamp
  • introduce Node struct which wraps all networking and persistence objects and exposes new API for
    • creating a new document
    • discovering documents based on short code
    • announcing documents on discovery gossip overlay (to enable discovery)
    • subscribe to a document, handling application messages
    • unsubscribe to a document

TODO

  • pass short code from app/UI to backend
  • handle receiving a new TextDocument in the app/UI
  • allow canceling announcement tasks
  • more backend tests

@sandreae sandreae changed the title Networking logic for discovering and subscribing to documents Discover and subscribe to documents based on short code Dec 27, 2024
while let Some(message) = rx.recv().await {
match message {
ToApp::NewDocument(text_document) => {
// @TODO: get the short code for this document into the share UI
Copy link
Member Author

@sandreae sandreae Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to load a new document into the UI here. This event occurs when the app starts, and also after a preceding request from the frontend to subscribe to a document based on it's short code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another approach (maybe nicer) for this messaging channel would be to still only have one message variant, but always include the document id as well as the message bytes. Then when a change in document id is detected we interpret this as a change of document.

Doesn't change anything about how the frontend would react, just how this change is communicated to the front end.

@@ -67,6 +67,8 @@ mod imp {
let window = self.obj().clone();
let dialog = self.open_document_dialog.clone();
self.open_document_button.connect_clicked(move |_| {
// @TODO: Send `FromApp::Subscribe` message to network containing the share code
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to send the short code to the backend here.

@adzialocha adzialocha linked an issue Jan 17, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Share very short codes to join other documents
1 participant