Skip to content

Commit

Permalink
[indexer] properly set key for cache in indexer reader
Browse files Browse the repository at this point in the history
  • Loading branch information
emmazzz committed May 11, 2024
1 parent 695ca9e commit 625f30e
Showing 1 changed file with 6 additions and 20 deletions.
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

0 comments on commit 625f30e

Please sign in to comment.