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

Full State Snapshots #4

Open
mattyg opened this issue Aug 8, 2023 · 0 comments
Open

Full State Snapshots #4

mattyg opened this issue Aug 8, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@mattyg
Copy link
Collaborator

mattyg commented Aug 8, 2023

Store full state snapshots in DHT to reduce the workload for a new peer to get up-to-date.

struct Snapshot {
  data: Vec<u8>,
  hashes: Vec<ActionHash> // hashes of all update statevectors included
}
  • On regular interval

    • Check if my agent pub key is closest to assigned key based on my timestamp (to reduce redundant snapshots)
      • get all agents associated with document, order ascending
      • get timestamp
      • calculate timestamp % number of agents
      • pick the agent at that index
      • if the agent is me, continue
    • get last snapshot + all updates since last snapshot, merge into single statevector
    • publish statevector as snapshot, specify hash of all updates included within it
  • When new agent joins

    • fetch latest snapshot
    • fetch all statevectors not included in latest snapshot
    • merge latest snapsho with statevectors
    • apply to ydoc
@mattyg mattyg added the enhancement New feature or request label Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant