From 319b9ca7e0a6a3d886956ab8f851408786143364 Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Tue, 6 Dec 2022 09:51:50 +0000 Subject: [PATCH] move result count limiting to after sorting --- libwallet/src/internal/updater.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libwallet/src/internal/updater.rs b/libwallet/src/internal/updater.rs index c750ac91..a9958dec 100644 --- a/libwallet/src/internal/updater.rs +++ b/libwallet/src/internal/updater.rs @@ -104,7 +104,7 @@ where K: Keychain + 'a, { // Apply simple bool, GTE or LTE fields - let mut txs_iter: Box> = Box::new( + let txs_iter: Box> = Box::new( wallet .tx_log_iter() .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 = txs_iter.collect(); // 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 }