move result count limiting to after sorting

This commit is contained in:
Yeastplume 2022-12-06 09:51:50 +00:00
parent 2a599027f5
commit 319b9ca7e0

View file

@ -104,7 +104,7 @@ where
K: Keychain + 'a, K: Keychain + 'a,
{ {
// Apply simple bool, GTE or LTE fields // Apply simple bool, GTE or LTE fields
let mut txs_iter: Box<dyn Iterator<Item = TxLogEntry>> = Box::new( let txs_iter: Box<dyn Iterator<Item = TxLogEntry>> = Box::new(
wallet wallet
.tx_log_iter() .tx_log_iter()
.filter(|tx_entry| { .filter(|tx_entry| {
@ -273,11 +273,6 @@ where
}), }),
); );
// Apply limit if requested
if let Some(l) = query_args.limit {
txs_iter = Box::new(txs_iter.take(l as usize));
}
let mut return_txs: Vec<TxLogEntry> = txs_iter.collect(); let mut return_txs: Vec<TxLogEntry> = txs_iter.collect();
// Now apply requested sorting // Now apply requested sorting
@ -321,6 +316,11 @@ where
} }
} }
// Apply limit if requested
if let Some(l) = query_args.limit {
return_txs = return_txs.into_iter().take(l as usize).collect()
}
return_txs return_txs
} }