Skip to content
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

[indexer] properly set key for cache in indexer reader #17649

Merged
merged 1 commit into from
May 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions crates/sui-indexer/src/indexer_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1502,17 +1502,10 @@ impl<U: R2D2Connection> IndexerReader<U> {
.package_obj_type_cache
.lock()
.unwrap()
.cache_get_or_set_with(
r#"{ format!("{}{}", package_id, obj_type) }"#.to_string(),
|| {
get_single_obj_id_from_package_publish(
self,
package_id,
coin_metadata_type.clone(),
)
.cache_get_or_set_with(format!("{}{}", package_id, coin_metadata_type), || {
get_single_obj_id_from_package_publish(self, package_id, coin_metadata_type.clone())
.unwrap()
},
);
});
if let Some(id) = coin_metadata_obj_id {
let metadata_object = self.get_object(&id, None)?;
Ok(metadata_object.and_then(|v| SuiCoinMetadata::try_from(v).ok()))
Expand All @@ -1537,17 +1530,10 @@ impl<U: R2D2Connection> IndexerReader<U> {
.package_obj_type_cache
.lock()
.unwrap()
.cache_get_or_set_with(
r#"{ format!("{}{}", package_id, treasury_cap_type) }"#.to_string(),
|| {
get_single_obj_id_from_package_publish(
self,
package_id,
treasury_cap_type.clone(),
)
.cache_get_or_set_with(format!("{}{}", package_id, treasury_cap_type), || {
get_single_obj_id_from_package_publish(self, package_id, treasury_cap_type.clone())
.unwrap()
},
)
})
.ok_or(IndexerError::GenericError(format!(
"Cannot find treasury cap for type {}",
treasury_cap_type
Expand Down
Loading