-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove duplicate results for same asset_ids in get_assets rpc method #227
base: main
Are you sure you want to change the base?
Conversation
das_api/src/api/api_impl.rs
Outdated
@@ -230,9 +241,13 @@ impl ApiContract for DasApi { | |||
|
|||
let options = options.unwrap_or_default(); | |||
|
|||
let assets = get_assets(&self.db_connection, id_bytes, batch_size as u64, &options).await?; | |||
let unique_asset_ids = remove_duplicates_asset_ids(id_bytes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filter dup ids at line no 237 and then convert to Vec<Vec<_>>
das_api/src/api/api_impl.rs
Outdated
@@ -148,6 +149,16 @@ pub fn not_found(asset_id: &String) -> DbErr { | |||
DbErr::RecordNotFound(format!("Asset Proof for {} Not Found", asset_id)) | |||
} | |||
|
|||
pub fn remove_duplicates_asset_ids(id_bytes: Vec<Vec<u8>>) -> Vec<Vec<u8>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use generics here
suggested improvments implemented @Nagaprasadvr |
@@ -218,6 +224,7 @@ impl ApiContract for DasApi { | |||
) -> Result<Vec<Option<Asset>>, DasApiError> { | |||
let GetAssets { ids, options } = payload; | |||
|
|||
let ids = remove_duplicates_ids(ids); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also dont need to use generic now cause now we filtering only ids, which is Vec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Problem
In getAssets rpc method , a user can provide multiple same asset_id to search for, and the api will give that many duplicated results, instead we can return a single result.
Tasks