 
 
 ;; start listening for incoming websocket connections
+#_(do (use '[geschichte.repo])
+    (def schema {:type ::schema :version 1})
+    (def repo {:meta
+               {:causal-order
+                {#uuid "b189b9f4-0901-4a39-a1c9-a0266254fbd3" #{},
+                 :root #uuid "b189b9f4-0901-4a39-a1c9-a0266254fbd3"},
+                :last-update #inst "2013-12-04T23:03:45.465-00:00",
+                :head "master",
+                :public true,
+                :branches {"master" #{#uuid "b189b9f4-0901-4a39-a1c9-a0266254fbd3"}},
+                :schema {:version 1, :type "http://github.com/ghubber/geschichte"},
+                :pull-requests {},
+                :id #uuid "22aa0537-6e66-43e4-bda2-2b4211e0e4ec",
+                :description "test repo"},
+               :value
+               {:geschichte.meta/meta
+                {:ts #inst "2013-12-04T23:03:45.465-00:00",
+                 :author "user@mail.com",
+                 :schema {:version 1, :type :geschichte.synch/schema},
+                 :branch "master",
+                 :id #uuid "b189b9f4-0901-4a39-a1c9-a0266254fbd3"},
+                :value 42}})
+    (def meta (:meta repo))
+    (def repo-up (commit meta "user@mail.com" schema "master"
+                         (first ((:branches meta) (:head meta))) {:value 43})))
+
 #_(def peer-a (create-peer "127.0.0.1"
                            9090
                            {}
-                           {"user@mail.com" {1 {1 42}}}))
+                           #_{"user@mail.com" {1 {1 42}}}
+                           {"user@mail.com" {(:id meta) meta}}))
 #_(-start peer-a)
 ;; subscribe to remote peer(s) as well
 #_(def peer-b (create-peer "127.0.0.1"
                            9091
-                           {"user@mail.com" {1 #{"127.0.0.1:9090"}} }
-                           {"user@mail.com" {1 {1 42}}}))
+                           {"user@mail.com" {(:id meta) #{"127.0.0.1:9090"}} }
+                           #_{"user@mail.com" {1 {1 42}}}
+                           {"user@mail.com" {(:id meta) meta}}))
 #_(-start peer-b)
 
 ;; publish and then check for update of meta in subscriptions of other peer
 
-#_(-publish peer-b "user@mail.com" 1 {1 42 2 43})
+#_(-publish peer-b "user@mail.com" (:id meta) (:meta repo-up))
 #_(-publish peer-a "user@mail.com" 1 {1 42 2 43 3 44})
 #_(-publish peer-b "user@mail.com" 1 {4 45})
 



;; dumb in memory peer for testing TODO move to tests

(declare network)
(defrecord Peer [state]

(ns ^:shared geschichte.synch
    "Synching related pub-sub protocols."
    (:use [geschichte.meta :refer [update]]
          [geschichte.protocols])
    (:require [clojure.set :as set]
              [geschichte.platform :refer [put! take-all! client-connect!
                                           start-server!]]))


(defn dispatch
