Skip to content

Commit

Permalink
sql order by mined_timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
mmrrnn committed Jan 9, 2025
1 parent 528d39e commit 0f07f57
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ use minotari_wallet::{
output_manager_service::{handle::OutputManagerHandle, UtxoSelectionCriteria},
transaction_service::{
handle::TransactionServiceHandle,
storage::models::{self, CompletedTransaction, WalletTransaction},
storage::models::{self, WalletTransaction},
},
WalletSqlite,
};
Expand Down Expand Up @@ -771,10 +771,7 @@ impl wallet_server::Wallet for WalletGrpcServer {

let (mut sender, receiver) = mpsc::channel(transactions.len());
task::spawn(async move {
let mut txns: Vec<&CompletedTransaction> = transactions.values().collect();
txns.sort_by(|a, b| b.timestamp.cmp(&a.timestamp));

for (i, txn) in txns.iter().enumerate() {
for (i, (_, txn)) in transactions.iter().enumerate() {
let response = GetCompletedTransactionsResponse {
transaction: Some(TransactionInfo {
tx_id: txn.tx_id.into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,9 @@ impl CompletedTransactionSql {
query.filter(completed_transactions::cancelled.is_null())
};

Ok(query.load::<CompletedTransactionSql>(conn)?)
Ok(query
.order_by(completed_transactions::mined_timestamp.desc())
.load::<CompletedTransactionSql>(conn)?)
}

pub fn index_by_status_and_cancelled(
Expand Down

0 comments on commit 0f07f57

Please sign in to comment.