Use cursor and update status-go
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
parent
6e5d54b5aa
commit
05b70b0974
|
@ -1 +1 @@
|
|||
0.17.8-beta
|
||||
0.17.9-beta
|
||||
|
|
|
@ -234,16 +234,22 @@
|
|||
mailserver-removed?
|
||||
(connect-to-mailserver cofx)))))
|
||||
|
||||
(defn request-messages! [web3 {:keys [sym-key-id address]} {:keys [topics to from]}]
|
||||
(def limit 200)
|
||||
|
||||
(defn request-messages! [web3 {:keys [sym-key-id address]} {:keys [topics cursor to from]}]
|
||||
(log/info "mailserver: request-messages for: "
|
||||
" topics " topics
|
||||
" from " from
|
||||
" cursor " cursor
|
||||
" limit " limit
|
||||
" to " to)
|
||||
(.requestMessages (transport.utils/shh web3)
|
||||
(clj->js {:topics topics
|
||||
:mailServerPeer address
|
||||
:symKeyID sym-key-id
|
||||
:timeout request-timeout
|
||||
:limit limit
|
||||
:cursor cursor
|
||||
:from from
|
||||
:to to})
|
||||
(fn [error request-id]
|
||||
|
@ -409,7 +415,7 @@
|
|||
(fx/defn update-mailserver-topics
|
||||
"TODO: add support for cursors
|
||||
if there is a cursor, do not update `last-request`"
|
||||
[{:keys [db now] :as cofx} {:keys [request-id]}]
|
||||
[{:keys [db now] :as cofx} {:keys [request-id cursor]}]
|
||||
(when-let [request (get db :mailserver/current-request)]
|
||||
(let [{:keys [from to topics]} request
|
||||
mailserver-topics (get-updated-mailserver-topics db topics to)]
|
||||
|
@ -420,6 +426,13 @@
|
|||
(fx/merge cofx
|
||||
{:db (dissoc db :mailserver/current-request)}
|
||||
(process-next-messages-request))
|
||||
;; If a cursor is returned, add cursor and fire request again
|
||||
(if (seq cursor)
|
||||
(when-let [mailserver (get-mailserver-when-ready cofx)]
|
||||
|
||||
{:mailserver/request-messages {:web3 (:web3 db)
|
||||
:mailserver mailserver
|
||||
:request (assoc request :cursor cursor)}})
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(dissoc :mailserver/current-request)
|
||||
|
@ -429,7 +442,7 @@
|
|||
{:topic topic
|
||||
:mailserver-topic mailserver-topic}))
|
||||
mailserver-topics)}
|
||||
(process-next-messages-request))))))
|
||||
(process-next-messages-request)))))))
|
||||
|
||||
(fx/defn retry-next-messages-request
|
||||
[{:keys [db] :as cofx}]
|
||||
|
@ -437,6 +450,8 @@
|
|||
{:db (dissoc db :mailserver/request-error)}
|
||||
(process-next-messages-request)))
|
||||
|
||||
;; At some point we should update `last-request`, as eventually we want to move
|
||||
;; on, rather then keep asking for the same data, say after n amounts of attempts
|
||||
(fx/defn handle-request-error
|
||||
[{:keys [db]} error]
|
||||
{:db (-> db
|
||||
|
|
Loading…
Reference in New Issue