+ (insert-before-markers "X-Hashcash: " pay))))))
+
+(defun hashcash-cancel-async (&optional buffer)
+ "Delete any hashcash processes associated with BUFFER.
+BUFFER defaults to the current buffer."
+ (interactive)
+ (unless buffer (setq buffer (current-buffer)))
+ (let (entry)
+ (while (setq entry (rassq buffer hashcash-process-alist))
+ (delete-process (car entry))
+ (setq hashcash-process-alist
+ (delq entry hashcash-process-alist)))))
+
+(defun hashcash-wait-async (&optional buffer)
+ "Wait for asynchronous hashcash processes in BUFFER to finish.
+BUFFER defaults to the current buffer."
+ (interactive)
+ (unless buffer (setq buffer (current-buffer)))
+ (let (entry)
+ (while (setq entry (rassq buffer hashcash-process-alist))
+ (accept-process-output (car entry)))))
+
+(defun hashcash-processes-running-p (buffer)
+ "Return non-nil if hashcash processes in BUFFER are still running."
+ (rassq buffer hashcash-process-alist))
+
+(defun hashcash-wait-or-cancel ()
+ "Ask user whether to wait for hashcash processes to finish."
+ (interactive)
+ (when (hashcash-processes-running-p (current-buffer))
+ (if (y-or-n-p
+ "Hashcash process(es) still running; wait for them to finish? ")
+ (hashcash-wait-async)
+ (hashcash-cancel-async))))