Skip to content

Commit

Permalink
Merge pull request #17 from fpco/ignore-code-19
Browse files Browse the repository at this point in the history
Ignore tx in mempool when broadcasting
  • Loading branch information
snoyberg authored Jun 10, 2024
2 parents d92194c + cfb7e91 commit d46a50a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/cosmos/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,21 @@ impl TxBuilder {
}
})?;

if !self.skip_code_check && res.code != 0 {
// Check if the transaction was successfully broadcast. We have three
// ways for this to "succeed":
//
// 1. We've decided to skip checking the code entirely.
// 2. The broadcast succeeded (status 0)
// 3. The broadcast failed with code 19, meaning "already in mempool"
//
// Our assumption with (3) is that we don't care about reporting if
// the tx is already in the pool, we just want to wait for it to be
// included in a block. Note that it's common for code 19 to occur
// when using all-node broadcasting.
if !(self.skip_code_check
|| res.code == 0
|| (res.codespace == "sdk" && res.code == 19))
{
return Err(crate::Error::TransactionFailed {
code: CosmosSdkError::from_code(res.code, &res.codespace),
txhash: res.txhash.clone(),
Expand Down

0 comments on commit d46a50a

Please sign in to comment.