Skip to content

specialfor/CRDT

Repository files navigation

📝 CRDT

Swift version badge Platforms badge

Swift implementation of state based CRDT (CvRDT)

❓ What is CRDT?

Conflict-free Replicated Data types or CRDT for short are data types which support semilattice properties and able to resolve conflicts connected with concurrent changes automatically. They were designed as a solution for data synchonization problem in distibuted systems, that's why they are highly connected with version vector.

More info in CRDT whitepaper (or in medium article if you don't want to read a lot) and Version vector (wiki)

💼 Portfolio of implemented CvRDT

Current implementation contains next data structures:

  • counters: GCounter, PNCounter
  • registers: LWWRegister, MVRegister
  • sets: GSet, 2PSet (called as TPSet), ORSet (same as AWSet)
  • maps: ORMap (same as AWMap)
  • flags: EWFlag

Also it contains next logical timestamps which are used by GCounter and MVRegister:

  • VersionVector (it is highly possible that it will be deprecated in future, because it is not match dynamic distibuted systems which we have in iOS development)
  • VectorStamp

🔧 Install

Only SPM is supported:

dependencies: [
        .package(url: "https://github.com/specialfor/CRDT", .branch("develop"))
]

📲 Usage

Feel free to look into tests folder. You can also find an example of usage based on client-server app here

🤔 Future plans

  • Improve existed implementation:
    • Start using VectorStamp instead of VersionVector inside GCounter
    • Rethink timestamp usage in LWWRegister
  • Add more CvRDTs:
    • POCounter
    • PNSet
    • LWWSet
    • RWSet
    • Log
    • RWMap
    • DWFlag
    • DAG
    • RGA
    • WOOT
    • Treedoc
    • Lagoot
  • Implement gargbage collector
  • Introduce delta CRDT
  • Create CmRDT analogues

About

Swift implementation of state based CRDT (CvRDT)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages