Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add retries to mobilecoind when it submits transactions #3308

Merged
merged 6 commits into from
Apr 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions mobilecoind/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ use rand::Rng;
use std::{
cmp::{max, Reverse},
collections::BTreeMap,
iter::empty,
str::FromStr,
sync::{
atomic::{AtomicUsize, Ordering},
Arc,
},
time::Duration,
};

/// Default number of blocks used for calculating transaction tombstone block
Expand Down Expand Up @@ -826,12 +826,22 @@ impl<T: BlockchainConnection + UserTxConnection + 'static, FPR: FogPubkeyResolve
let idx = self.submit_node_offset.fetch_add(1, Ordering::SeqCst);
let responder_id = &responder_ids[idx % responder_ids.len()];

// The rationale for these retries is:
// * Quite often, the attested connetion was closed and we need to retry once to
// re-attest, and this attestation is successful. So that takes 50 ms.
// * After that, we back off to 500 ms, because there are rate limits of about
// 100 / min in place in production.
let retry_iterator = [50, 500, 500, 750, 1000]
.iter()
.cloned()
.map(Duration::from_millis);

// Try and submit.
let block_height = self
.peer_manager
.conn(responder_id)
.ok_or(Error::NodeNotFound)?
.propose_tx(&tx_proposal.tx, empty())
.propose_tx(&tx_proposal.tx, retry_iterator)
.map_err(Error::from)?;

log::info!(
Expand Down