                (pick-next-timeout (count remaining-ips))
                remaining-ips)
       (throw (ex-info "No IPs left. Giving up" this)))))
-
-(s/fdef cookie-sent-obsolete
-        :args (s/cat :this ::state/state
-                     :raw-packet ::specs/network-packet
-                     :log-state-atom ::log/state-atom
-                     ;; TODO: Need a better name that isn't as
-                     ;; easily confused with ::state/cookie-response
-                     :cookie-response dfrd/deferrable?
-                     :cookie-waiter ::cookie-waiter
-                     :send-packet-success boolean?)
-        ;; Success returns a deferrable
-        ;; that resolves to a ::state/cookie-response.
-        ;; This is a nice feature of deferred/chain:
-        ;; the outcome is the same either way.
-        :ret (s/or :response dfrd/deferrable?
-                   :recursed ::state/cookie-response))
-(defn cookie-sent-obsolete
-  ;; TODO: Come up with a better name. do-polling-loop
-  ;; needs both this and a callback from the cookie
-  ;; ns that it's named cookie-sent-callback.
-  ;; Need to make them different enough that I won't
-  ;; get them snarled up.
-  [{:keys [::state/timeout
-           :state/server-ips]
-    :as this}
-   raw-packet
-   log-state-atom
-   cookie-response
-   cookie-waiter
-   send-packet-success]
-  (throw (RuntimeException. "never called"))
-  (if send-packet-success
-    ;; Note that this timeout actually can grow to be quite long.
-    ;; In the original, they probably add up to a ballpark of a minute.
-    ;; It's probably acceptable for a single polling thread to block for that
-    ;; long.
-    ;; Or, at least, it probably was back in 2011 when the spec was written,
-    ;; or in 2013 when my copy of the reference implementation was published.
-    ;; Q: Is that still reasonable today?
-    ;; Better Q: Is there a better alternative?
-    (dfrd/timeout! cookie-response timeout ::awaiting-cookie-timed-out)
-    ;; I'd really like to trampoline this. Realistically, we can't, because
-    ;; we're inside a deferred chain.
-    ;; TODO: Prove that, one way or another
-    (trampoline possibly-recurse
-                (assoc this ::log/state @log-state-atom)
-                server-ips cookie-waiter raw-packet)))
 
 (s/fdef cookie-retrieved
         :args (s/cat :this ::state/state


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Specs

;; Keep in mind that this is totally distinct from
;; cookie/wait-for-cookie!
;; It's annoying that the signatures are so similar
;; That distinction no longer seems to be true.
;; Q: Is this actually used anywhere?
(s/def ::cookie-sent-callback-obsolete (s/fspec :args (s/cat :notifier ::specs/deferrable
                                                    :timeout (s/and number?
                                                                    (complement neg?))
                                                    :this ::state/state
                                                    :sent ::specs/network-packet)))

;; TODO: Move this somewhere shared so I can eliminate the duplication
;; with cookie/wait-for-cookie! without introducing awkward ns dependencies.

      (+ timeout (crypto/random-mod timeout)))))

(declare do-polling-loop)

(s/fdef possibly-recurse
        :args (s/cat :this ::state/state
