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]