Skip to content

Empty structures initialised with vector clock #2

@frankiesardo

Description

@frankiesardo

Using sets as an example: the current result of an empty convergent set is

(def set1 (with-node :node1 (convergent-set)))
;; => #schism/set[#{} {} {}]

Whereas if a set is initialised with some state is

(def set2 (with-node :node2 (convergent-set :a)))
;; => => #schism/set[#{:a} {:node2 #inst"..."} {:a [:node2 #inst"..."]}]

I found this caused problems when you try to merge the second into the empty set

(with-node :node1 (converge set1 set2))
;; => Execution error (NullPointerException) at schism.impl.core/to-millis.

Because the first set is missing a vector clock.

Should convergent data structures be initialised with a vector clock in all cases? Changing the initialisation with

-(defn new-set
-  ([] (Set. (hash-set)
-            (hash-map)
-            (hash-map)))
+ (defn new-set
+   ([] (vc/update-clock now nil
+                     (Set. (hash-set)
+                           (hash-map)
+                           (hash-map)))) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions