Skip to content

Commit

Permalink
use sql for handle_pending_outbound & cleanup questions
Browse files Browse the repository at this point in the history
  • Loading branch information
mmrrnn committed Jan 16, 2025
1 parent fa1d769 commit bec825e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1088,15 +1088,17 @@ async fn handle_pending_outbound(
transaction_service: &mut TransactionServiceHandle,
sender: &mut Sender<Result<TransactionEventResponse, Status>>,
) {
match transaction_service.get_pending_outbound_transactions().await {
Ok(txs) => {
if let Some(tx) = txs.iter().find(|tx| tx.tx_id == tx_id) {
use models::WalletTransaction::PendingOutbound;
match transaction_service.get_any_transaction(tx_id).await {
Ok(tx) => match tx {
Some(PendingOutbound(tx)) => {
let transaction_event =
convert_to_transaction_event(event.to_string(), TransactionWrapper::Outbound(Box::new(tx.clone())));
send_transaction_event(transaction_event, sender).await;
} else {
},
_ => {
error!(target: LOG_TARGET, "Not found in pending outbound set tx_id: {}", tx_id);
}
},
},
Err(e) => error!(target: LOG_TARGET, "Transaction service error: {}", e),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,6 @@ impl AppStateInner {
.map(|t| CompletedTransaction::from(t.clone()))
.collect::<Vec<CompletedTransaction>>(),
);
// Question(C): We sort txs by mined_timestamp in sql, here is by timestamp
pending_transactions.sort_by(|a: &CompletedTransaction, b: &CompletedTransaction| {
b.timestamp.partial_cmp(&a.timestamp).unwrap()
});
Expand All @@ -755,7 +754,6 @@ impl AppStateInner {
.get_cancelled_completed_transactions()
.await?,
);
// Question(C): We sort txs by mined_timestamp in sql, here is by timestamp
completed_transactions.sort_by(|a, b| {
b.timestamp
.partial_cmp(&a.timestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,6 @@ impl InboundTransactionSql {
) -> Result<Vec<InboundTransactionSql>, TransactionStorageError> {
Ok(inbound_transactions::table
.filter(inbound_transactions::cancelled.eq(i32::from(cancelled)))
// QUESTION(A): Should we order by timestamp or last_send_timestamp?
.order_by(inbound_transactions::timestamp.desc())
.load::<InboundTransactionSql>(conn)?)
}
Expand Down Expand Up @@ -1439,7 +1438,6 @@ impl OutboundTransactionSql {
) -> Result<Vec<OutboundTransactionSql>, TransactionStorageError> {
Ok(outbound_transactions::table
.filter(outbound_transactions::cancelled.eq(i32::from(cancelled)))
// QUESTION(A): Should we order by timestamp or last_send_timestamp?
.order_by(outbound_transactions::timestamp.desc())
.load::<OutboundTransactionSql>(conn)?)
}
Expand Down

0 comments on commit bec825e

Please sign in to comment.