 #_(clojure.pprint/pprint @stage-log)
 #_(let [in (debug/chan stage-log [:stage :in])
       out (debug/chan stage-log [:stage :out])]
-  (go (<! (wire peer [in out]))
+  (go (<! (wire peer [in (async/pub out :type)]))
       (>! out {:type :meta-sub :metas {"john" #{1}}})
 ;      (<! in)
       (<! (timeout 1000))

  (def peer (client-peer "CLIENT" (new-store)))
  (require '[clojure.core.incubator :refer [dissoc-in]])
  (dissoc-in @peer [:volatile :log])

  (go (let [stage (repo/new-repository "me@mail.com"
                                       {:type "s" :version 1}
                                       "Testing."
                                       false
                                       {:some 42})
            stage (<! (wire-stage peer stage))
            printfn (partial println "STAGE:")
            in  (first (:chans stage))
            _ (go-loop [m (<! in)]
                       (println "STAGE-IN:" m)
                       (recur (<! in)))
            _ (>! (second (:chans stage)) {:type :connect
                                           :ip4 "127.0.0.1"
                                           :port 9090})
            _ (<! (timeout 1000))
            new-stage (<! (sync! stage))]
        (-> new-stage

                                (async/into [])
                                <!
                                (zipmap ids))]
               (>! out {:type :fetched
                        :user user :repo repo
                        :values fetched})
               (recur (<! fetch-ch))))))


(defn wire [peer [out p]]
  (go (let [{:keys [store chans log]} (:volatile @peer)
            ip (:ip @peer)
            [bus-in bus-out] chans
            pub-ch (debug/chan log [ip :pub])
            conn-ch (debug/chan log [ip :conn])
            sub-ch (debug/chan log [ip :sub])
