From 0d0f32765e220a64fa2512b14b91c4b99a3be85c Mon Sep 17 00:00:00 2001 From: canonbrother Date: Tue, 10 Dec 2024 13:12:55 +0800 Subject: [PATCH] fix get_latest_aggregation --- lib/ain-ocean/src/api/address.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/ain-ocean/src/api/address.rs b/lib/ain-ocean/src/api/address.rs index be6ee17749..47f67b0436 100644 --- a/lib/ain-ocean/src/api/address.rs +++ b/lib/ain-ocean/src/api/address.rs @@ -174,19 +174,11 @@ fn get_latest_aggregation( .script_aggregation .by_id .list(Some((hid, [0xffu8; 4])), SortOrder::Descending)? - .take(1) - .take_while(|item| match item { - Ok(((v, _), _)) => v == &hid, - _ => true, - }) - .map(|item| { - let (_, v) = item?; - let res = v.into(); - Ok(res) - }) - .collect::>>()?; + .next() + .transpose()? + .map(|(_, v)| v.into()); - Ok(latest.first().cloned()) + Ok(latest) } #[ocean_endpoint]