Skip to content

Commit 689e7fa

Browse files
committed
refactor: Early exit for Sent in status_core
Move Sent status check before hash parsing as an early exit, matching the approach in PR #606. This simplifies the logic since: - Pending and Sent transactions don't have on-chain hashes yet - Only Submitted+ transactions need hash validation - If hash is missing for Submitted+, it's a database inconsistency Remove unused is_unsubmitted_transaction import.
1 parent ee8be74 commit 689e7fa

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

src/domain/transaction/stellar/status.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use tracing::{debug, info, warn};
88

99
use super::{is_final_state, StellarRelayerTransaction};
1010
use crate::constants::{get_stellar_max_stuck_transaction_lifetime, get_stellar_resend_timeout};
11-
use crate::domain::is_unsubmitted_transaction;
1211
use crate::domain::transaction::stellar::prepare::common::send_submit_transaction_job;
1312
use crate::domain::transaction::stellar::utils::extract_return_value_from_meta;
1413
use crate::domain::transaction::stellar::utils::extract_time_bounds;
@@ -99,26 +98,30 @@ where
9998
&self,
10099
tx: TransactionRepoModel,
101100
) -> Result<TransactionRepoModel, TransactionError> {
102-
// Early check for Pending transactions - avoid unnecessary hash parsing
101+
// Early exits for unsubmitted transactions - they don't have on-chain hashes yet
102+
// The submit handler will schedule status checks after submission
103103
if tx.status == TransactionStatus::Pending {
104104
return self.handle_pending_state(tx).await;
105105
}
106106

107+
if tx.status == TransactionStatus::Sent {
108+
return self.handle_sent_state(tx).await;
109+
}
110+
107111
let stellar_hash = match self.parse_and_validate_hash(&tx) {
108112
Ok(hash) => hash,
109113
Err(e) => {
110-
warn!(tx_id = %tx.id, error = ?e, "failed to parse and validate hash");
111-
if !is_unsubmitted_transaction(&tx.status) {
112-
info!(tx_id = %tx.id, status = ?tx.status, "transaction is not unsubmitted, marking as failed due to hash validation error");
113-
return self
114-
.mark_as_failed(tx, format!("Failed to parse and validate hash: {e}"))
115-
.await;
116-
}
117-
// Recover stuck Sent transactions
118-
if tx.status == TransactionStatus::Sent {
119-
return self.handle_sent_state(tx).await;
120-
}
121-
return Ok(tx);
114+
// Transaction should be in Submitted or later state
115+
// If hash is missing, this is a database inconsistency that won't fix itself
116+
warn!(
117+
tx_id = %tx.id,
118+
status = ?tx.status,
119+
error = ?e,
120+
"failed to parse and validate hash for submitted transaction"
121+
);
122+
return self
123+
.mark_as_failed(tx, format!("Failed to parse and validate hash: {e}"))
124+
.await;
122125
}
123126
};
124127

0 commit comments

Comments
 (0)