From 63a1c4a6dddd80ed3a3a0a1f5d2b5924e73cd417 Mon Sep 17 00:00:00 2001 From: Kyrylo Stepanov Date: Fri, 22 Nov 2024 13:39:18 +0200 Subject: [PATCH] Change naming for non fungible tokens in methods --- grpc/src/asseturls.rs | 3 +- .../src/api/backfilling_state_consistency.rs | 8 +- .../api/synchronization_state_consistency.rs | 10 +-- nft_ingester/src/bin/ingester/main.rs | 2 +- nft_ingester/src/bin/synchronizer/main.rs | 4 +- nft_ingester/src/index_syncronizer.rs | 84 ++++++++----------- nft_ingester/tests/api_tests.rs | 16 ++-- nft_ingester/tests/dump_tests.rs | 3 +- postgre-client/src/asset_index_client.rs | 8 +- postgre-client/src/load_client.rs | 10 +-- postgre-client/src/storage_traits.rs | 4 +- postgre-client/src/temp_index_client.rs | 4 +- .../tests/asset_filter_client_test.rs | 6 +- .../tests/asset_index_client_test.rs | 8 +- rocks-db/src/batch_client.rs | 6 +- rocks-db/src/dump_client.rs | 4 +- rocks-db/src/storage_traits.rs | 18 ++-- .../tests/batch_client_integration_tests.rs | 28 +++---- tests/setup/src/lib.rs | 2 +- 19 files changed, 105 insertions(+), 123 deletions(-) diff --git a/grpc/src/asseturls.rs b/grpc/src/asseturls.rs index 02d0c76ae..c855a394a 100644 --- a/grpc/src/asseturls.rs +++ b/grpc/src/asseturls.rs @@ -90,8 +90,7 @@ impl DownloadError { /// Generated client implementations. pub mod asset_url_service_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; - use tonic::codegen::*; + use tonic::codegen::{http::Uri, *}; #[derive(Debug, Clone)] pub struct AssetUrlServiceClient { inner: tonic::client::Grpc, diff --git a/nft_ingester/src/api/backfilling_state_consistency.rs b/nft_ingester/src/api/backfilling_state_consistency.rs index d8325cdd1..1262118c4 100644 --- a/nft_ingester/src/api/backfilling_state_consistency.rs +++ b/nft_ingester/src/api/backfilling_state_consistency.rs @@ -12,14 +12,14 @@ use tracing::info; pub struct BackfillingStateConsistencyChecker { overwhelm_fungible_backfill_gap: Arc, - overwhelm_non_backfill_gap: Arc, + overwhelm_nft_backfill_gap: Arc, } impl BackfillingStateConsistencyChecker { pub(crate) fn new() -> Self { Self { overwhelm_fungible_backfill_gap: Arc::new(AtomicBool::new(false)), - overwhelm_non_backfill_gap: Arc::new(AtomicBool::new(false)), + overwhelm_nft_backfill_gap: Arc::new(AtomicBool::new(false)), } } @@ -34,7 +34,7 @@ impl BackfillingStateConsistencyChecker { let rocks_db = rocks_db.clone(); let mut rx = rx.resubscribe(); let overwhelm_backfill_gap = match asset_type { - AssetType::NonFungible => self.overwhelm_non_backfill_gap.clone(), + AssetType::NonFungible => self.overwhelm_nft_backfill_gap.clone(), AssetType::Fungible => self.overwhelm_fungible_backfill_gap.clone(), }; tasks.lock().await.spawn(async move { @@ -60,7 +60,7 @@ impl BackfillingStateConsistencyChecker { impl ConsistencyChecker for BackfillingStateConsistencyChecker { fn should_cancel_request(&self, _call: &Call) -> bool { - self.overwhelm_non_backfill_gap.load(Ordering::Relaxed) + self.overwhelm_nft_backfill_gap.load(Ordering::Relaxed) && self.overwhelm_fungible_backfill_gap.load(Ordering::Relaxed) } } diff --git a/nft_ingester/src/api/synchronization_state_consistency.rs b/nft_ingester/src/api/synchronization_state_consistency.rs index dda6b0f28..57e542e6b 100644 --- a/nft_ingester/src/api/synchronization_state_consistency.rs +++ b/nft_ingester/src/api/synchronization_state_consistency.rs @@ -30,14 +30,14 @@ const INDEX_STORAGE_DEPENDS_METHODS: &[&str] = &[ ]; pub struct SynchronizationStateConsistencyChecker { - overwhelm_non_fungible_seq_gap: Arc, + overwhelm_nft_seq_gap: Arc, overwhelm_fungible_seq_gap: Arc, } impl SynchronizationStateConsistencyChecker { pub(crate) fn new() -> Self { Self { - overwhelm_non_fungible_seq_gap: Arc::new(AtomicBool::new(false)), + overwhelm_nft_seq_gap: Arc::new(AtomicBool::new(false)), overwhelm_fungible_seq_gap: Arc::new(AtomicBool::new(false)), } } @@ -52,7 +52,7 @@ impl SynchronizationStateConsistencyChecker { ) { for asset_type in ASSET_TYPES { let overwhelm_seq_gap = match asset_type { - AssetType::NonFungible => self.overwhelm_non_fungible_seq_gap.clone(), + AssetType::NonFungible => self.overwhelm_nft_seq_gap.clone(), AssetType::Fungible => self.overwhelm_fungible_seq_gap.clone(), }; let pg_client = pg_client.clone(); @@ -68,7 +68,7 @@ impl SynchronizationStateConsistencyChecker { }; let last_known_updated_asset = match asset_type { - AssetType::NonFungible => rocks_db.last_known_non_fungible_asset_updated_key(), + AssetType::NonFungible => rocks_db.last_known_nft_asset_updated_key(), AssetType::Fungible => rocks_db.last_known_fungible_asset_updated_key(), }; let Ok(Some(primary_update_key)) = last_known_updated_asset else { @@ -98,7 +98,7 @@ impl SynchronizationStateConsistencyChecker { impl ConsistencyChecker for SynchronizationStateConsistencyChecker { fn should_cancel_request(&self, call: &Call) -> bool { - if !&self.overwhelm_non_fungible_seq_gap.load(Ordering::Relaxed) + if !&self.overwhelm_nft_seq_gap.load(Ordering::Relaxed) || !&self.overwhelm_fungible_seq_gap.load(Ordering::Relaxed) { return false; diff --git a/nft_ingester/src/bin/ingester/main.rs b/nft_ingester/src/bin/ingester/main.rs index 86ef62517..389977403 100644 --- a/nft_ingester/src/bin/ingester/main.rs +++ b/nft_ingester/src/bin/ingester/main.rs @@ -614,7 +614,7 @@ pub async fn main() -> Result<(), IngesterError> { match asset_type { AssetType::NonFungible => { synchronizer - .non_fungible_run(&rx, config.dump_sync_threshold, Duration::from_secs(5)) + .nft_run(&rx, config.dump_sync_threshold, Duration::from_secs(5)) .await } AssetType::Fungible => { diff --git a/nft_ingester/src/bin/synchronizer/main.rs b/nft_ingester/src/bin/synchronizer/main.rs index 9e7fd7232..9ff1efab9 100644 --- a/nft_ingester/src/bin/synchronizer/main.rs +++ b/nft_ingester/src/bin/synchronizer/main.rs @@ -158,7 +158,7 @@ pub async fn main() -> Result<(), IngesterError> { let synchronizer = synchronizer_clone.clone(); while shutdown_rx.is_empty() { let result = synchronizer - .synchronize_non_fungible_asset_indexes(&shutdown_rx, config.dump_sync_threshold) + .synchronize_nft_asset_indexes(&shutdown_rx, config.dump_sync_threshold) .await; match result { @@ -182,7 +182,7 @@ pub async fn main() -> Result<(), IngesterError> { let synchronizer = synchronizer.clone(); while shutdown_rx.is_empty() { let result = synchronizer - .synchronize_non_fungible_asset_indexes(&shutdown_rx, config.dump_sync_threshold) + .synchronize_fungible_asset_indexes(&shutdown_rx, config.dump_sync_threshold) .await; match result { diff --git a/nft_ingester/src/index_syncronizer.rs b/nft_ingester/src/index_syncronizer.rs index 8f12fd848..d2d46bc5c 100644 --- a/nft_ingester/src/index_syncronizer.rs +++ b/nft_ingester/src/index_syncronizer.rs @@ -72,7 +72,7 @@ where } } - pub async fn non_fungible_run( + pub async fn nft_run( &self, rx: &tokio::sync::broadcast::Receiver<()>, run_full_sync_threshold: i64, @@ -80,7 +80,7 @@ where ) { while rx.is_empty() { if let Err(e) = self - .synchronize_non_fungible_asset_indexes(rx, run_full_sync_threshold) + .synchronize_nft_asset_indexes(rx, run_full_sync_threshold) .await { tracing::error!("Non fungible synchronization failed: {:?}", e); @@ -129,9 +129,7 @@ where }; // Fetch the last known key from the primary storage let last_key = match asset_type { - AssetType::NonFungible => self - .primary_storage - .last_known_non_fungible_asset_updated_key()?, + AssetType::NonFungible => self.primary_storage.last_known_nft_asset_updated_key()?, AssetType::Fungible => self .primary_storage .last_known_fungible_asset_updated_key()?, @@ -169,7 +167,7 @@ where })) } - pub async fn synchronize_non_fungible_asset_indexes( + pub async fn synchronize_nft_asset_indexes( &self, rx: &tokio::sync::broadcast::Receiver<()>, run_full_sync_threshold: i64, @@ -180,20 +178,12 @@ where match state { SyncStatus::FullSyncRequired(state) => { tracing::info!("Should run dump synchronizer as the difference between last indexed and last known sequence is greater than the threshold. Last indexed: {:?}, Last known: {}", state.last_indexed_key.clone().map(|k|k.seq), state.last_known_key.seq); - self.regular_non_fungible_syncronize( - rx, - state.last_indexed_key, - state.last_known_key, - ) - .await + self.regular_nft_syncronize(rx, state.last_indexed_key, state.last_known_key) + .await } SyncStatus::RegularSyncRequired(state) => { - self.regular_non_fungible_syncronize( - rx, - state.last_indexed_key, - state.last_known_key, - ) - .await + self.regular_nft_syncronize(rx, state.last_indexed_key, state.last_known_key) + .await } SyncStatus::NoSyncRequired => Ok(()), } @@ -228,9 +218,7 @@ where asset_type: AssetType, ) -> Result<(), IngesterError> { let last_known_key = match asset_type { - AssetType::NonFungible => self - .primary_storage - .last_known_non_fungible_asset_updated_key()?, + AssetType::NonFungible => self.primary_storage.last_known_nft_asset_updated_key()?, AssetType::Fungible => self .primary_storage .last_known_fungible_asset_updated_key()?, @@ -268,7 +256,7 @@ where match asset_type { AssetType::NonFungible => { temp_syncronizer - .non_fungible_run(&local_rx, -1, tokio::time::Duration::from_millis(100)) + .nft_run(&local_rx, -1, tokio::time::Duration::from_millis(100)) .await } AssetType::Fungible => { @@ -407,7 +395,7 @@ where Ok(()) } - async fn regular_non_fungible_syncronize( + async fn regular_nft_syncronize( &self, rx: &tokio::sync::broadcast::Receiver<()>, last_indexed_key: Option, @@ -425,7 +413,7 @@ where break; } let (updated_keys, last_included_key) = - self.primary_storage.fetch_non_fungible_asset_updated_keys( + self.primary_storage.fetch_nft_asset_updated_keys( starting_key.clone(), Some(last_key.clone()), self.dump_synchronizer_batch_size, @@ -450,7 +438,7 @@ where let index_storage = self.index_storage.clone(); let metrics = self.metrics.clone(); tasks.spawn(async move { - Self::syncronize_non_fungible_batch( + Self::syncronize_nft_batch( primary_storage.clone(), index_storage.clone(), updated_keys_refs.as_slice(), @@ -498,14 +486,14 @@ where Ok(()) } - pub async fn syncronize_non_fungible_batch( + pub async fn syncronize_nft_batch( primary_storage: Arc, index_storage: Arc, updated_keys_refs: &[Pubkey], metrics: Arc, ) -> Result<(), IngesterError> { let asset_indexes = primary_storage - .get_non_fungible_asset_indexes(updated_keys_refs, None) + .get_nft_asset_indexes(updated_keys_refs, None) .await?; if asset_indexes.is_empty() { @@ -514,7 +502,7 @@ where } index_storage - .update_non_fungible_asset_indexes_batch( + .update_nft_asset_indexes_batch( asset_indexes .values() .cloned() @@ -658,7 +646,7 @@ mod tests { AssetType::NonFungible => { tokio::spawn(async move { synchronizer - .synchronize_non_fungible_asset_indexes(&rx, 0) + .synchronize_nft_asset_indexes(&rx, 0) .await .unwrap(); }); @@ -689,7 +677,7 @@ mod tests { let index_clone = index_key.clone(); primary_storage .mock_update_index_storage - .expect_last_known_non_fungible_asset_updated_key() + .expect_last_known_nft_asset_updated_key() .once() .return_once(move || Ok(Some(index_clone))); @@ -697,7 +685,7 @@ mod tests { let index_clone = index_key.clone(); primary_storage .mock_update_index_storage - .expect_fetch_non_fungible_asset_updated_keys() + .expect_fetch_nft_asset_updated_keys() .once() .return_once(move |_, _, _, _| Ok((updated_keys.clone(), Some(index_clone)))); @@ -706,12 +694,12 @@ mod tests { let expected_indexes: Vec = map_of_asset_indexes.values().cloned().collect(); primary_storage .mock_asset_index_reader - .expect_get_non_fungible_asset_indexes() + .expect_get_nft_asset_indexes() .once() .return_once(move |_, _| Ok(map_of_asset_indexes)); index_storage - .expect_update_non_fungible_asset_indexes_batch() + .expect_update_nft_asset_indexes_batch() .with(mockall::predicate::eq(expected_indexes.clone())) .once() .return_once(|_| Ok(())); @@ -751,7 +739,7 @@ mod tests { AssetType::NonFungible => { tokio::spawn(async move { synchronizer - .synchronize_non_fungible_asset_indexes(&rx, 0) + .synchronize_nft_asset_indexes(&rx, 0) .await .unwrap(); }); @@ -783,7 +771,7 @@ mod tests { let index_clone = index_key.clone(); primary_storage .mock_update_index_storage - .expect_last_known_non_fungible_asset_updated_key() + .expect_last_known_nft_asset_updated_key() .once() .return_once(move || Ok(Some(index_clone))); @@ -791,7 +779,7 @@ mod tests { let index_clone = index_key.clone(); primary_storage .mock_update_index_storage - .expect_fetch_non_fungible_asset_updated_keys() + .expect_fetch_nft_asset_updated_keys() .times(2) .returning(move |_, _, _, _| { static mut CALL_COUNT: usize = 0; @@ -810,12 +798,12 @@ mod tests { let expected_indexes: Vec = map_of_asset_indexes.values().cloned().collect(); primary_storage .mock_asset_index_reader - .expect_get_non_fungible_asset_indexes() + .expect_get_nft_asset_indexes() .once() .return_once(move |_, _| Ok(map_of_asset_indexes)); index_storage - .expect_update_non_fungible_asset_indexes_batch() + .expect_update_nft_asset_indexes_batch() .with(mockall::predicate::eq(expected_indexes.clone())) .once() .return_once(|_| Ok(())); @@ -856,7 +844,7 @@ mod tests { AssetType::NonFungible => { tokio::spawn(async move { synchronizer - .synchronize_non_fungible_asset_indexes(&rx, 0) + .synchronize_nft_asset_indexes(&rx, 0) .await .unwrap(); }); @@ -901,7 +889,7 @@ mod tests { let index_key_second_batch_clone = index_key_second_batch.clone(); primary_storage .mock_update_index_storage - .expect_last_known_non_fungible_asset_updated_key() + .expect_last_known_nft_asset_updated_key() .once() .return_once(move || Ok(Some(index_key_second_batch_clone))); @@ -911,7 +899,7 @@ mod tests { let index_key_second_batch_clone = index_key_second_batch.clone(); primary_storage .mock_update_index_storage - .expect_fetch_non_fungible_asset_updated_keys() + .expect_fetch_nft_asset_updated_keys() .times(2) .returning(move |_, _, _, _| { call_count += 1; @@ -939,7 +927,7 @@ mod tests { let mut call_count2 = 0; primary_storage .mock_asset_index_reader - .expect_get_non_fungible_asset_indexes() + .expect_get_nft_asset_indexes() .times(2) .returning(move |_, _| { call_count2 += 1; @@ -951,7 +939,7 @@ mod tests { }); index_storage - .expect_update_non_fungible_asset_indexes_batch() + .expect_update_nft_asset_indexes_batch() .with(mockall::predicate::eq(expected_indexes_first_batch.clone())) .once() .return_once(|_| Ok(())); @@ -965,7 +953,7 @@ mod tests { .return_once(|_, _| Ok(())); index_storage - .expect_update_non_fungible_asset_indexes_batch() + .expect_update_nft_asset_indexes_batch() .with(mockall::predicate::eq( expected_indexes_second_batch.clone(), )) @@ -1008,7 +996,7 @@ mod tests { AssetType::NonFungible => { tokio::spawn(async move { synchronizer - .synchronize_non_fungible_asset_indexes(&rx, 0) + .synchronize_nft_asset_indexes(&rx, 0) .await .unwrap(); }); @@ -1030,7 +1018,7 @@ mod tests { let index_key_clone = index_key.clone(); primary_storage .mock_update_index_storage - .expect_last_known_non_fungible_asset_updated_key() + .expect_last_known_nft_asset_updated_key() .once() .return_once(move || Ok(Some(index_key_clone))); @@ -1051,7 +1039,7 @@ mod tests { // Expect no calls to fetch_asset_updated_keys since databases are synced primary_storage .mock_update_index_storage - .expect_fetch_non_fungible_asset_updated_keys() + .expect_fetch_nft_asset_updated_keys() .never(); let synchronizer = Synchronizer::new( @@ -1082,7 +1070,7 @@ mod tests { AssetType::NonFungible => { tokio::spawn(async move { synchronizer - .synchronize_non_fungible_asset_indexes(&rx, 0) + .synchronize_nft_asset_indexes(&rx, 0) .await .unwrap(); }); diff --git a/nft_ingester/tests/api_tests.rs b/nft_ingester/tests/api_tests.rs index ae88eca47..4a91bd79a 100644 --- a/nft_ingester/tests/api_tests.rs +++ b/nft_ingester/tests/api_tests.rs @@ -3156,11 +3156,9 @@ mod tests { }); } AssetType::NonFungible => { - tasks.spawn(async move { - synchronizer - .synchronize_non_fungible_asset_indexes(&rx, 0) - .await - }); + tasks.spawn( + async move { synchronizer.synchronize_nft_asset_indexes(&rx, 0).await }, + ); } } } @@ -3637,11 +3635,9 @@ mod tests { }); } AssetType::NonFungible => { - tasks.spawn(async move { - synchronizer - .synchronize_non_fungible_asset_indexes(&rx, 0) - .await - }); + tasks.spawn( + async move { synchronizer.synchronize_nft_asset_indexes(&rx, 0).await }, + ); } } } diff --git a/nft_ingester/tests/dump_tests.rs b/nft_ingester/tests/dump_tests.rs index 8849eb136..f8d5f9d9d 100644 --- a/nft_ingester/tests/dump_tests.rs +++ b/nft_ingester/tests/dump_tests.rs @@ -45,9 +45,8 @@ mod tests { amount: 1000, write_version: 10, }; - // TODO: is it really fungible? token_accounts_processor - .transform_and_save_fungible_token_account(&mut batch_storage, key, &token_account) + .transform_and_save_token_account(&mut batch_storage, key, &token_account) .unwrap(); } batch_storage.flush().unwrap(); diff --git a/postgre-client/src/asset_index_client.rs b/postgre-client/src/asset_index_client.rs index 7e876e53c..a728b5346 100644 --- a/postgre-client/src/asset_index_client.rs +++ b/postgre-client/src/asset_index_client.rs @@ -65,7 +65,7 @@ impl PgClient { Ok(()) } - pub(crate) async fn upsert_batched_non_fungible( + pub(crate) async fn upsert_batched_nft( &self, transaction: &mut Transaction<'_, Postgres>, table_names: TableNames, @@ -277,7 +277,7 @@ impl AssetIndexStorage for PgClient { .await } - async fn update_non_fungible_asset_indexes_batch( + async fn update_nft_asset_indexes_batch( &self, asset_indexes: &[AssetIndex], ) -> Result<(), IndexDbError> { @@ -293,7 +293,7 @@ impl AssetIndexStorage for PgClient { // Perform transactional operations let result = self - .upsert_batched_non_fungible(&mut transaction, table_names, updated_components) + .upsert_batched_nft(&mut transaction, table_names, updated_components) .await; match result { @@ -406,7 +406,7 @@ impl AssetIndexStorage for PgClient { ))); }; - self.copy_non_fungibles( + self.copy_nfts( metadata_path, creators_path, assets_path, diff --git a/postgre-client/src/load_client.rs b/postgre-client/src/load_client.rs index 38184656b..db05d3571 100644 --- a/postgre-client/src/load_client.rs +++ b/postgre-client/src/load_client.rs @@ -100,7 +100,7 @@ impl PgClient { Ok(()) } - pub async fn drop_non_fungible_indexes( + pub async fn drop_nft_indexes( &self, transaction: &mut Transaction<'_, Postgres>, ) -> Result<(), IndexDbError> { @@ -190,7 +190,7 @@ impl PgClient { Ok(()) } - pub async fn recreate_non_fungible_indexes( + pub async fn recreate_nft_indexes( &self, transaction: &mut Transaction<'_, Postgres>, ) -> Result<(), IndexDbError> { @@ -279,7 +279,7 @@ impl PgClient { Ok(()) } - pub(crate) async fn copy_non_fungibles( + pub(crate) async fn copy_nfts( &self, matadata_copy_path: String, asset_creators_copy_path: String, @@ -287,7 +287,7 @@ impl PgClient { assets_authorities_copy_path: String, transaction: &mut Transaction<'_, Postgres>, ) -> Result<(), IndexDbError> { - self.drop_non_fungible_indexes(transaction).await?; + self.drop_nft_indexes(transaction).await?; self.drop_constraints(transaction).await?; for table in ["assets_v3", "asset_creators_v3", "assets_authorities"] { self.truncate_table(transaction, table).await?; @@ -323,7 +323,7 @@ impl PgClient { ] { self.copy_table_from(transaction, path, table, columns).await?; } - self.recreate_non_fungible_indexes(transaction).await?; + self.recreate_nft_indexes(transaction).await?; self.recreate_constraints(transaction).await?; Ok(()) } diff --git a/postgre-client/src/storage_traits.rs b/postgre-client/src/storage_traits.rs index 6d433ac4b..c8827cd07 100644 --- a/postgre-client/src/storage_traits.rs +++ b/postgre-client/src/storage_traits.rs @@ -13,7 +13,7 @@ pub trait AssetIndexStorage { &self, asset_type: AssetType, ) -> Result>, IndexDbError>; - async fn update_non_fungible_asset_indexes_batch( + async fn update_nft_asset_indexes_batch( &self, asset_indexes: &[AssetIndex], ) -> Result<(), IndexDbError>; @@ -39,7 +39,7 @@ mock!( #[async_trait] impl AssetIndexStorage for AssetIndexStorageMock { async fn fetch_last_synced_id(&self, asset_type: AssetType) -> Result>, IndexDbError>; - async fn update_non_fungible_asset_indexes_batch( + async fn update_nft_asset_indexes_batch( &self, asset_indexes: &[AssetIndex], ) -> Result<(), IndexDbError>; diff --git a/postgre-client/src/temp_index_client.rs b/postgre-client/src/temp_index_client.rs index 68247bb5e..376e8d7e1 100644 --- a/postgre-client/src/temp_index_client.rs +++ b/postgre-client/src/temp_index_client.rs @@ -255,7 +255,7 @@ impl AssetIndexStorage for TempClient { .await } - async fn update_non_fungible_asset_indexes_batch( + async fn update_nft_asset_indexes_batch( &self, asset_indexes: &[AssetIndex], ) -> Result<(), IndexDbError> { @@ -269,7 +269,7 @@ impl AssetIndexStorage for TempClient { authorities_table: format!("{}assets_authorities", TEMP_INDEXING_TABLE_PREFIX), }; self.pg_client - .upsert_batched_non_fungible(&mut transaction, table_names, updated_components) + .upsert_batched_nft(&mut transaction, table_names, updated_components) .await?; self.pg_client.commit_transaction(transaction).await } diff --git a/postgre-client/tests/asset_filter_client_test.rs b/postgre-client/tests/asset_filter_client_test.rs index 8f46701a2..ae09d9e98 100644 --- a/postgre-client/tests/asset_filter_client_test.rs +++ b/postgre-client/tests/asset_filter_client_test.rs @@ -77,7 +77,7 @@ mod tests { // Insert assets and last key using update_asset_indexes_batch asset_filter_storage - .update_non_fungible_asset_indexes_batch(asset_indexes.as_slice()) + .update_nft_asset_indexes_batch(asset_indexes.as_slice()) .await .unwrap(); asset_filter_storage @@ -281,7 +281,7 @@ mod tests { // Insert assets and last key using update_asset_indexes_batch asset_filter_storage - .update_non_fungible_asset_indexes_batch(asset_indexes.as_slice()) + .update_nft_asset_indexes_batch(asset_indexes.as_slice()) .await .unwrap(); asset_filter_storage @@ -293,7 +293,7 @@ mod tests { // Insert assets and last key using update_asset_indexes_batch asset_filter_storage - .update_non_fungible_asset_indexes_batch(asset_indexes.as_slice()) + .update_nft_asset_indexes_batch(asset_indexes.as_slice()) .await .unwrap(); asset_filter_storage diff --git a/postgre-client/tests/asset_index_client_test.rs b/postgre-client/tests/asset_index_client_test.rs index 91d49d7c8..f14e00b54 100644 --- a/postgre-client/tests/asset_index_client_test.rs +++ b/postgre-client/tests/asset_index_client_test.rs @@ -32,7 +32,7 @@ mod tests { let last_known_key = generate_random_vec(8 + 8 + 32); // Insert assets and last key using update_asset_indexes_batch asset_index_storage - .update_non_fungible_asset_indexes_batch(asset_indexes.as_slice()) + .update_nft_asset_indexes_batch(asset_indexes.as_slice()) .await .unwrap(); @@ -65,7 +65,7 @@ mod tests { }) .collect::>(); asset_index_storage - .update_non_fungible_asset_indexes_batch(updated_asset_indexes.as_slice()) + .update_nft_asset_indexes_batch(updated_asset_indexes.as_slice()) .await .unwrap(); asset_index_storage @@ -114,7 +114,7 @@ mod tests { // Insert assets and last key using update_asset_indexes_batch asset_index_storage - .update_non_fungible_asset_indexes_batch(asset_indexes.as_slice()) + .update_nft_asset_indexes_batch(asset_indexes.as_slice()) .await .unwrap(); asset_index_storage @@ -142,7 +142,7 @@ mod tests { .collect::>(); asset_index_storage - .update_non_fungible_asset_indexes_batch(updated_asset_indexes.as_slice()) + .update_nft_asset_indexes_batch(updated_asset_indexes.as_slice()) .await .unwrap(); asset_index_storage diff --git a/rocks-db/src/batch_client.rs b/rocks-db/src/batch_client.rs index f9666e371..305f16e40 100644 --- a/rocks-db/src/batch_client.rs +++ b/rocks-db/src/batch_client.rs @@ -45,7 +45,7 @@ impl AssetUpdateIndexStorage for Storage { } } - fn last_known_non_fungible_asset_updated_key(&self) -> Result> { + fn last_known_nft_asset_updated_key(&self) -> Result> { _ = self.db.try_catch_up_with_primary(); let start_time = chrono::Utc::now(); let mut iter = self.assets_update_idx.iter_end(); @@ -124,7 +124,7 @@ impl AssetUpdateIndexStorage for Storage { Ok((unique_pubkeys, last_key)) } - fn fetch_non_fungible_asset_updated_keys( + fn fetch_nft_asset_updated_keys( &self, from: Option, up_to: Option, @@ -218,7 +218,7 @@ impl AssetIndexReader for Storage { Ok(fungible_assets_indexes) } - async fn get_non_fungible_asset_indexes<'a>( + async fn get_nft_asset_indexes<'a>( &self, keys: &[Pubkey], collection_authorities: Option<&'a HashMap>, diff --git a/rocks-db/src/dump_client.rs b/rocks-db/src/dump_client.rs index 638131265..ea1c464fb 100644 --- a/rocks-db/src/dump_client.rs +++ b/rocks-db/src/dump_client.rs @@ -232,7 +232,7 @@ impl Storage { if batch.len() >= batch_size { let start = chrono::Utc::now(); let indexes = self - .get_non_fungible_asset_indexes(batch.as_ref(), Some(&collections)) + .get_nft_asset_indexes(batch.as_ref(), Some(&collections)) .await .map_err(|e| e.to_string())?; self.red_metrics.observe_request( @@ -259,7 +259,7 @@ impl Storage { if !batch.is_empty() { let start = chrono::Utc::now(); let indexes = self - .get_non_fungible_asset_indexes(batch.as_ref(), Some(&collections)) + .get_nft_asset_indexes(batch.as_ref(), Some(&collections)) .await .map_err(|e| e.to_string())?; self.red_metrics.observe_request( diff --git a/rocks-db/src/storage_traits.rs b/rocks-db/src/storage_traits.rs index 7a77406c1..0fd80fab2 100644 --- a/rocks-db/src/storage_traits.rs +++ b/rocks-db/src/storage_traits.rs @@ -23,11 +23,11 @@ impl AssetUpdatedKey { #[automock] pub trait AssetUpdateIndexStorage { - fn last_known_non_fungible_asset_updated_key(&self) -> Result>; + fn last_known_nft_asset_updated_key(&self) -> Result>; fn last_known_fungible_asset_updated_key(&self) -> Result>; #[allow(clippy::type_complexity)] - fn fetch_non_fungible_asset_updated_keys( + fn fetch_nft_asset_updated_keys( &self, from: Option, up_to: Option, @@ -52,7 +52,7 @@ pub trait AssetIndexReader { keys: &[Pubkey], ) -> Result>; - async fn get_non_fungible_asset_indexes<'a>( + async fn get_nft_asset_indexes<'a>( &self, keys: &[Pubkey], collection_authorities: Option<&'a HashMap>, @@ -91,9 +91,9 @@ impl MockAssetIndexStorage { } impl AssetUpdateIndexStorage for MockAssetIndexStorage { - fn last_known_non_fungible_asset_updated_key(&self) -> Result> { + fn last_known_nft_asset_updated_key(&self) -> Result> { self.mock_update_index_storage - .last_known_non_fungible_asset_updated_key() + .last_known_nft_asset_updated_key() } fn last_known_fungible_asset_updated_key(&self) -> Result> { @@ -101,7 +101,7 @@ impl AssetUpdateIndexStorage for MockAssetIndexStorage { .last_known_fungible_asset_updated_key() } - fn fetch_non_fungible_asset_updated_keys( + fn fetch_nft_asset_updated_keys( &self, from: Option, up_to: Option, @@ -109,7 +109,7 @@ impl AssetUpdateIndexStorage for MockAssetIndexStorage { skip_keys: Option>, ) -> Result<(HashSet, Option)> { self.mock_update_index_storage - .fetch_non_fungible_asset_updated_keys(from, up_to, limit, skip_keys) + .fetch_nft_asset_updated_keys(from, up_to, limit, skip_keys) } fn fetch_fungible_asset_updated_keys( @@ -135,13 +135,13 @@ impl AssetIndexReader for MockAssetIndexStorage { .await } - async fn get_non_fungible_asset_indexes<'a>( + async fn get_nft_asset_indexes<'a>( &self, keys: &[Pubkey], collection_authorities: Option<&'a HashMap>, ) -> Result> { self.mock_asset_index_reader - .get_non_fungible_asset_indexes(keys, collection_authorities) + .get_nft_asset_indexes(keys, collection_authorities) .await } } diff --git a/rocks-db/tests/batch_client_integration_tests.rs b/rocks-db/tests/batch_client_integration_tests.rs index a037b18b3..d8fdf4203 100644 --- a/rocks-db/tests/batch_client_integration_tests.rs +++ b/rocks-db/tests/batch_client_integration_tests.rs @@ -34,7 +34,7 @@ mod tests { // Call fetch_asset_updated_keys on an empty database let (keys, last_key) = storage - .fetch_non_fungible_asset_updated_keys(None, None, 10, None) + .fetch_nft_asset_updated_keys(None, None, 10, None) .expect("Failed to fetch asset updated keys"); // Assertions assert!(keys.is_empty(), "Expected no keys from an empty database"); @@ -79,7 +79,7 @@ mod tests { .storage; // Verify fetch_asset_updated_keys with None as last key let (keys, last_key) = storage - .fetch_non_fungible_asset_updated_keys(None, None, 10, None) + .fetch_nft_asset_updated_keys(None, None, 10, None) .unwrap(); assert_eq!(keys.len(), 1, "Expected a single key"); assert_eq!( @@ -90,7 +90,7 @@ mod tests { assert!(last_key.is_some(), "Expected a last key"); // Verify fetch_asset_updated_keys with the last key from previous call let (new_keys, new_last_key) = storage - .fetch_non_fungible_asset_updated_keys(last_key.clone(), None, 10, None) + .fetch_nft_asset_updated_keys(last_key.clone(), None, 10, None) .unwrap(); assert!( new_keys.is_empty(), @@ -109,7 +109,7 @@ mod tests { .storage; // Verify fetch_asset_updated_keys with None as last key let (keys, last_key) = storage - .fetch_non_fungible_asset_updated_keys(None, None, 1, None) + .fetch_nft_asset_updated_keys(None, None, 1, None) .unwrap(); assert_eq!(keys.len(), 1, "Expected a single key"); assert_eq!( @@ -120,7 +120,7 @@ mod tests { assert!(last_key.is_some(), "Expected a last key"); // Verify fetch_asset_updated_keys with the last key from previous call let (new_keys, new_last_key) = storage - .fetch_non_fungible_asset_updated_keys(last_key.clone(), None, 1, Some(keys)) + .fetch_nft_asset_updated_keys(last_key.clone(), None, 1, Some(keys)) .unwrap(); assert!( new_keys.is_empty(), @@ -139,7 +139,7 @@ mod tests { .storage; // Verify fetch_asset_updated_keys with None as last key let (keys, last_key) = storage - .fetch_non_fungible_asset_updated_keys( + .fetch_nft_asset_updated_keys( None, None, 1, @@ -168,7 +168,7 @@ mod tests { // Verify fetch_asset_updated_keys with up to key which is less then the first key let (keys, last_key) = storage - .fetch_non_fungible_asset_updated_keys( + .fetch_nft_asset_updated_keys( None, Some(AssetUpdatedKey::new(0, 2, DEFAULT_PUBKEY_OF_ONES.clone())), 10, @@ -180,7 +180,7 @@ mod tests { // verify fetch_asset_updated_keys with up to key which is equal to the first key let (keys, last_key) = storage - .fetch_non_fungible_asset_updated_keys( + .fetch_nft_asset_updated_keys( None, Some(AssetUpdatedKey::new(1, 4, DEFAULT_PUBKEY_OF_ONES.clone())), 10, @@ -205,7 +205,7 @@ mod tests { // verify fetch_asset_updated_keys with up to key which is equal to the last key returns all the keys let (keys, last_key) = storage - .fetch_non_fungible_asset_updated_keys( + .fetch_nft_asset_updated_keys( None, Some(AssetUpdatedKey::new(4, 5, PUBKEY_OF_TWOS.clone())), 10, @@ -236,7 +236,7 @@ mod tests { fn test_last_known_asset_updated_key_on_empty_db() { let storage = RocksTestEnvironment::new(&[]).storage; let last_key = storage - .last_known_non_fungible_asset_updated_key() + .last_known_nft_asset_updated_key() .expect("Failed to get last known asset updated key"); assert!(last_key.is_none(), "Expected no last key"); } @@ -251,7 +251,7 @@ mod tests { ]) .storage; let last_key = storage - .last_known_non_fungible_asset_updated_key() + .last_known_nft_asset_updated_key() .expect("Failed to get last known asset updated key"); assert!(last_key.is_some(), "Expected a last key"); let expected_key = AssetUpdatedKey::new(4, 5, PUBKEY_OF_TWOS.clone()); @@ -272,7 +272,7 @@ mod tests { ]) .storage; let (keys, last_key) = storage - .fetch_non_fungible_asset_updated_keys(None, None, 10, None) + .fetch_nft_asset_updated_keys(None, None, 10, None) .unwrap(); assert_eq!(keys.len(), 2, "Expected 2 keys"); @@ -296,7 +296,7 @@ mod tests { let key = Pubkey::new_unique(); storage.asset_updated(5, key.clone()).unwrap(); let (keys, last_key) = storage - .fetch_non_fungible_asset_updated_keys(last_key, None, 10, None) + .fetch_nft_asset_updated_keys(last_key, None, 10, None) .unwrap(); assert_eq!(keys.len(), 1, "Expected 1 key"); @@ -326,7 +326,7 @@ mod tests { let mut last_seen_key = last_key.clone(); for i in 0..10 { let (new_keys, last_key) = storage - .fetch_non_fungible_asset_updated_keys(last_seen_key, None, 1000, None) + .fetch_nft_asset_updated_keys(last_seen_key, None, 1000, None) .unwrap(); assert_eq!(new_keys.len(), 1000, "Expected 1000 keys"); assert!(last_key.is_some(), "Expected a last key"); diff --git a/tests/setup/src/lib.rs b/tests/setup/src/lib.rs index 714e64d8a..54213e45f 100644 --- a/tests/setup/src/lib.rs +++ b/tests/setup/src/lib.rs @@ -89,7 +89,7 @@ impl<'a> TestEnvironment<'a> { tasks.spawn(async move { match asset_type { AssetType::NonFungible => synchronizer - .synchronize_non_fungible_asset_indexes(&rx, 0) + .synchronize_nft_asset_indexes(&rx, 0) .await .unwrap(), AssetType::Fungible => synchronizer