fn handle_submissions(
client: Client,
rx: mpsc::UnboundedReceiver<SubmissionParameters>,
tx_submit_data: mpsc::UnboundedSender<SubmissionParameters>,
executor: &Handle,
) {
async move {
let stream = PrioRetry::new(rx, Duration::from_secs(3));
while let Some(submission_params) = stream.next().await {
let tx_submit_data = tx_submit_data.clone();
client
.clone()
.submit_nounce(&submission_params)
.await
.map(|res| {
match res {
Ok(res) => {
if submission_params.deadline != res.deadline {
do_some();
} else {
do_some();
}
}
Err(FetchError::Pool(e)) => {
// Very intuitive, if some pools send an empty message they are
// experiencing too much load expect the submission to be resent later.
if e.message.is_empty() || e.message == "limit exceeded" {
do_some();
let res = tx_submit_data.unbounded_send(submission_params);
if let Err(e) = res {
error!("can't send submission params: {}", e);
}
} else {
do_some();
}
}
Err(FetchError::Http(x)) => {
do_some();
let res = tx_submit_data.unbounded_send(submission_params);
if let Err(e) = res {
error!("can't send submission params: {}", e);
}
}
}
})
.for_each(|_| Ok(()))
.map_err(|e| error!("can't handle submission params: {:?}", e));
}
executor.spawn(stream);
};
}
some errors are listed below
error[E0277]: the trait bound `future::prio_retry::PrioRetry<futures_channel::mpsc::UnboundedReceiver<wallet::client::SubmissionParameters>>: core::future::future::Future` is not satisfied
--> src/requests.rs:136:28
|
136 | executor.spawn(stream);
| ^^^^^^ the trait `core::future::future::Future` is not implemented for `future::prio_retry::PrioRetry<futures_channel::mpsc::UnboundedReceiver<wallet::client::SubmissionParameters>>`
error[E0308]: mismatched types
--> src/requests.rs:95:29
|
77 | match res {
| --- this expression has type `wallet::api::SubmitNonceResponse`
...
95 | Err(FetchError::Pool(e)) => {
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `wallet::api::SubmitNonceResponse`, found enum `std::result::Result`