           (d/catch (fn [ex]
                      (swap! state update-in [:peers peer-id] dissoc :connect-pending)
                      (warn ex "[" (:id @state) "] caught exception in reconnect-to-peer")))))))
+
 (defn- send-peer-packet
   "sends a packet to the appropriate peer socket, will reconnect"
   [state p]

    (d/let-flow
     [handshake (s/take! s)]
     (-> ((condp = (:type handshake)
            :peering-handshake connect-peer-socket
            :table-tennis connect-table-tennis-socket
            :client-handshake connect-client-socket
            (fn [&_]
              (warn "Invalid handshake: " (:type handshake))
              (s/close! s)))

  [state timeout]
  (d/loop [t (current-time)]
    (when-not (empty? (:tx-queue @state))
      (transmit! state))

    (if-not (stream-open? (:rx-stream @state))
      (warn (:id @state) " has a closed stream we should be exiting")
