Synchronization with gaia


What are good options to synchronize app data on the client with the gaia hub?

I see use cases

  • for progressive web apps that store data offline in localStorage
  • for native apps that use the device storage first and then schedule synchronization
  • for collections that work for well established data sets like address book, calendar,… that have already a sync protocol like webdav/carddav/caldav

Should some version meta data be added to the files (like for webdav)? Maybe only in the header. This would also help to identify encrypted files vs unencrypted files.

Should gaia support rsync protocol?

Should each developer solve the problem individually by adding version numbers in the data (on the client)?


Maybe the use cases are too technical.

Synchronization is not needed if the account (user app bucket) is used in a sequential manner on different devices and apps. However,

  • one account could be used by different people,
  • the user might be not aware of having data stored offline (e.g. phone’s battery is dead)

Are there more scenarios?


These are good questions, @friedger

The way we handle synchronization currently is that a user’s Gaia hub is capable of serializing requests as they come in, and this is really all that it will do (i.e., it implements last-writer-wins). Synchronization between multiple devices can be (and in some sense, must be) handled by the client. A library could be used to support this synchronization, but for the moment, I don’t know if such a library exists. As far as supporting it in Blockstack’s libraries (like blockstack.js), I think that approach would be a mistake, as this seems like something a community or otherwise supported library could implement on top of the simple interface currently provided.


Other apps are known to implement CRDTs on top of blockstack.js in order to accommodate potentially-concurrent writes from multiple devices.


Yep, Graphite uses Yjs for this and I believe Blockusign uses Automerge.


@friedger I’m late to this, but it’s a great question and something I’ve been considering for a while now. Stealthy’s use case can be significantly aided by both synchronization and use of async local storage. At a minimum we to employ dist. computing 101 techniques (time stamp, basic merge etc.).

I appreciate @aaron’s answer b/c it gives me the freedom as a dev to implement what I want without being encumbered or forced into a strategy that isn’t performant to my use case.

For Stealthy, there are two main considerations:

  1. backing up operations in a local session when connectivity to GAIA is poor
  2. synchronizing across multiple sessions

Ultimately we’ll likely roll a lightweight js class that makes sense for us and may employ existing solutions for some of the problems, with a more distant view towards sharing it with the community in its own package.