        (async/into #{})))
 
 
+;; TODO multiple subscriptions, subscription propagation; incremental subscription?
 (defn subscribe [peer sub-ch bus-out out]
   (go-loop [{:keys [metas] :as s} (<! sub-ch)]
            (when s

        (fetch peer fetch-ch out)

        (async/sub p :connect conn-ch)
        (connect peer conn-ch)

        (async/sub p nil (debug/chan log [ip :unsupported]) false))))

;; subscribe to remote peer(s) as well
#_(def peer-b  (server-peer "127.0.0.1"
                                   9091
                                   mem-store))

#_(do (def peer-a (atom nil))
      (def peer (atom nil))
      (def stage-log (atom nil)))

#_(do (stop peer-a)
      (reset! peer-a @(server-peer "127.0.0.1"
                                9090
                                (new-store)))
      (reset! peer @(client-peer "CLIENT" (new-store)))
      (reset! stage-log {}))




(defn connect [peer conn-ch out]
  (go-loop [{:keys [ip4 port] :as c} (<! conn-ch)]
           (when c
             (let [[bus-in bus-out] (:chans (:volatile @peer))
