#pragma once #include #include #include #include namespace molo::replication { enum class VectorOrder { Equal, Before, // this <= other with at least one strict < After, // this >= other with at least one strict > Concurrent, // neither dominates: a real conflict happened }; // Version vector over per-instance oplog sequences, exchanged at sync so // each side fetches only what the other has not seen (S7-7). class VersionVector { public: void update(const std::string& instance, std::uint64_t seq); std::uint64_t get(const std::string& instance) const; void merge(const VersionVector& other); VectorOrder compare(const VersionVector& other) const; std::string encode() const; // JSON object {instance: seq} static bool decode(const std::string& text, VersionVector& out); private: mutable std::mutex mutex_; std::map versions_; }; } // namespace molo::replication