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

tx_signer: fix retry-on-error behavior #181

Merged
merged 1 commit into from
Oct 19, 2020
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: 13 additions & 1 deletion src/tx_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,26 @@ impl TxSigner {
let seq = self.seq_file.sequence();
let sign_msg = SignMsg::new(&tx_req, &self.tx_builder, seq)?;

// If no transaction broadcasted successfully before, retry with a
// higher sequence number to see if we're out-of-sync
// TODO(tarcieri): handle these errors by querying sequence number via RPC
let retry_on_failure = !self.last_tx.is_response();

if let Err(e) = self.broadcast_tx(sign_msg, seq).await {
error!("[{}] {} - {}", &self.chain_id, self.source.uri(), e);

// If the last transaction errored, speculatively try the next
// sequence number, as the previous transaction may have been
// successfully broadcast but we never got a response.
if !self.last_tx.is_response() {
if retry_on_failure {
let seq = seq.checked_add(1).unwrap();
warn!(
"[{}] {} - retrying transaction at sequence {}",
&self.chain_id,
self.source.uri(),
seq
);

let sign_msg = SignMsg::new(&tx_req, &self.tx_builder, seq)?;
self.broadcast_tx(sign_msg, seq).await?
}
Expand Down