From 3b02d5739cf8404358d06aafb427b4f6870e7bbc Mon Sep 17 00:00:00 2001 From: Guoteng Rao <3603304+grao1991@users.noreply.github.com> Date: Wed, 17 Apr 2024 23:06:26 +0000 Subject: [PATCH] Refactor the code to make it easier to support multiple db backends in the future. --- rust/processor/README.md | 3 ++ rust/processor/src/db/common/mod.rs | 1 + .../account_transactions.rs | 2 +- .../models/account_transaction_models/mod.rs | 0 .../common}/models/ans_models/ans_lookup.rs | 0 .../models/ans_models/ans_lookup_v2.rs | 2 +- .../common}/models/ans_models/ans_utils.rs | 50 +------------------ .../{ => db/common}/models/ans_models/mod.rs | 0 .../models/coin_models/coin_activities.rs | 2 +- .../models/coin_models/coin_balances.rs | 2 +- .../common}/models/coin_models/coin_infos.rs | 0 .../common}/models/coin_models/coin_supply.rs | 2 +- .../common}/models/coin_models/coin_utils.rs | 9 +--- .../{ => db/common}/models/coin_models/mod.rs | 0 .../block_metadata_transactions.rs | 0 .../common}/models/default_models/mod.rs | 0 .../models/default_models/move_modules.rs | 0 .../models/default_models/move_resources.rs | 0 .../models/default_models/move_tables.rs | 0 .../models/default_models/transactions.rs | 0 .../default_models/write_set_changes.rs | 0 .../common}/models/events_models/events.rs | 0 .../common}/models/events_models/mod.rs | 0 .../models/fungible_asset_models/mod.rs | 0 .../v2_fungible_asset_activities.rs | 2 +- .../v2_fungible_asset_balances.rs | 2 +- .../v2_fungible_asset_utils.rs | 2 +- .../v2_fungible_metadata.rs | 2 +- .../src/{ => db/common}/models/ledger_info.rs | 4 +- .../src/{ => db/common}/models/mod.rs | 0 .../common}/models/object_models/mod.rs | 0 .../models/object_models/v2_object_utils.rs | 2 +- .../models/object_models/v2_objects.rs | 10 ++-- .../common}/models/processor_status.rs | 4 +- .../{ => db/common}/models/property_map.rs | 0 .../stake_models/current_delegated_voter.rs | 14 +++--- .../stake_models/delegator_activities.rs | 0 .../models/stake_models/delegator_balances.rs | 14 +++--- .../models/stake_models/delegator_pools.rs | 0 .../common}/models/stake_models/mod.rs | 0 .../models/stake_models/proposal_votes.rs | 0 .../models/stake_models/stake_utils.rs | 4 +- .../models/stake_models/staking_pool_voter.rs | 0 .../models/token_models/collection_datas.rs | 8 +-- .../common}/models/token_models/mod.rs | 0 .../common}/models/token_models/nft_points.rs | 0 .../models/token_models/token_activities.rs | 0 .../models/token_models/token_claims.rs | 0 .../models/token_models/token_datas.rs | 0 .../models/token_models/token_ownerships.rs | 0 .../models/token_models/token_utils.rs | 8 --- .../common}/models/token_models/tokens.rs | 6 +-- .../common}/models/token_v2_models/mod.rs | 0 .../token_v2_models/v1_token_royalty.rs | 4 +- .../models/token_v2_models/v2_collections.rs | 10 ++-- .../token_v2_models/v2_token_activities.rs | 2 +- .../models/token_v2_models/v2_token_datas.rs | 2 +- .../token_v2_models/v2_token_metadata.rs | 2 +- .../token_v2_models/v2_token_ownerships.rs | 14 +++--- .../models/token_v2_models/v2_token_utils.rs | 3 +- .../event_size_info.rs | 0 .../models/transaction_metadata_model/mod.rs | 0 .../transaction_size_info.rs | 0 .../write_set_size_info.rs | 0 .../models/user_transactions_models/mod.rs | 0 .../user_transactions_models/signatures.rs | 0 .../user_transactions.rs | 0 rust/processor/src/db/mod.rs | 1 + .../2024-04-18-173631_fungible_token/down.sql | 0 .../2024-04-18-173631_fungible_token/up.sql | 0 .../down.sql | 0 .../2024-04-29-215042_token_datas_burn/up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../2024-05-21-221101_add_royalty_v1/down.sql | 0 .../2024-05-21-221101_add_royalty_v1/up.sql | 0 .../{ => src/db/postgres}/diesel.toml | 0 .../{ => src/db/postgres}/migrations/.keep | 0 .../down.sql | 0 .../up.sql | 0 .../2022-08-08-043603_core_tables/down.sql | 0 .../2022-08-08-043603_core_tables/up.sql | 2 +- .../2022-09-04-194128_add_token_data/down.sql | 0 .../2022-09-04-194128_add_token_data/up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../2022-09-22-185845_token_offers/down.sql | 0 .../2022-09-22-185845_token_offers/up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../down.sql | 0 .../2022-10-02-011020_ans_lookup_table/up.sql | 0 .../down.sql | 0 .../2022-10-04-073529_add_coin_tables/up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../down.sql | 0 .../2022-10-07-231825_add_coin_supply/up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../2022-10-21-055518_stake_to_voter/down.sql | 0 .../2022-10-21-055518_stake_to_voter/up.sql | 0 .../2022-10-30-053525_add_vote_data/down.sql | 0 .../2022-10-30-053525_add_vote_data/up.sql | 0 .../down.sql | 0 .../2022-12-29-222902_curr_table_items/up.sql | 0 .../down.sql | 0 .../2023-02-15-070116_stake_delegation/up.sql | 0 .../2023-03-08-205402_nft_points/down.sql | 0 .../2023-03-08-205402_nft_points/up.sql | 0 .../down.sql | 0 .../2023-04-02-032121_delegator_pools/up.sql | 0 .../down.sql | 0 .../2023-04-14-033932_optimize_queries/up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../down.sql | 0 .../2023-04-28-053048_object_token_v2/up.sql | 0 .../2023-05-17-010107_activities_v2/down.sql | 0 .../2023-05-17-010107_activities_v2/up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../2023-07-28-053854_entry_function/down.sql | 0 .../2023-07-28-053854_entry_function/up.sql | 0 .../down.sql | 0 .../2023-08-01-042050_fungible_assets/up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../2023-08-22-232603_add_ans_view/down.sql | 0 .../2023-08-22-232603_add_ans_view/up.sql | 0 .../2023-08-23-192343_fix_ans_view/down.sql | 0 .../2023-08-23-192343_fix_ans_view/up.sql | 0 .../2023-09-01-231248_events_v2/down.sql | 0 .../2023-09-01-231248_events_v2/up.sql | 0 .../2023-09-07-175640_storage_refund/down.sql | 0 .../2023-09-07-175640_storage_refund/up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../2023-09-22-161603_add_ans_v2/down.sql | 0 .../2023-09-22-161603_add_ans_v2/up.sql | 0 .../2023-09-28-210956_nft_metadata/down.sql | 0 .../2023-09-28-210956_nft_metadata/up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../2023-10-27-030502_event_type/down.sql | 0 .../2023-10-27-030502_event_type/up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../2023-12-15-221028_payload_type/down.sql | 0 .../2023-12-15-221028_payload_type/up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../2024-02-16-234847_any_signature/down.sql | 0 .../2024-02-16-234847_any_signature/up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../down.sql | 0 .../up.sql | 0 .../processor/src/{ => db/postgres}/schema.rs | 0 rust/processor/src/lib.rs | 5 +- .../account_transactions_processor.rs | 12 ++--- .../processor/src/processors/ans_processor.rs | 12 ++--- .../src/processors/coin_processor.rs | 12 ++--- .../src/processors/default_processor.rs | 14 +++--- .../src/processors/events_processor.rs | 12 ++--- .../processors/fungible_asset_processor.rs | 12 ++--- rust/processor/src/processors/mod.rs | 13 ++--- .../src/processors/monitoring_processor.rs | 8 +-- .../src/processors/nft_metadata_processor.rs | 12 ++--- .../src/processors/objects_processor.rs | 12 ++--- .../src/processors/stake_processor.rs | 12 ++--- .../src/processors/token_processor.rs | 12 ++--- .../src/processors/token_v2_processor.rs | 14 +++--- .../transaction_metadata_processor.rs | 12 ++--- .../processors/user_transaction_processor.rs | 12 ++--- rust/processor/src/utils/database.rs | 50 +++++++++---------- rust/processor/src/utils/util.rs | 2 +- rust/processor/src/worker.rs | 10 ++-- 192 files changed, 194 insertions(+), 249 deletions(-) create mode 100644 rust/processor/src/db/common/mod.rs rename rust/processor/src/{ => db/common}/models/account_transaction_models/account_transactions.rs (99%) rename rust/processor/src/{ => db/common}/models/account_transaction_models/mod.rs (100%) rename rust/processor/src/{ => db/common}/models/ans_models/ans_lookup.rs (100%) rename rust/processor/src/{ => db/common}/models/ans_models/ans_lookup_v2.rs (99%) rename rust/processor/src/{ => db/common}/models/ans_models/ans_utils.rs (88%) rename rust/processor/src/{ => db/common}/models/ans_models/mod.rs (100%) rename rust/processor/src/{ => db/common}/models/coin_models/coin_activities.rs (99%) rename rust/processor/src/{ => db/common}/models/coin_models/coin_balances.rs (97%) rename rust/processor/src/{ => db/common}/models/coin_models/coin_infos.rs (100%) rename rust/processor/src/{ => db/common}/models/coin_models/coin_supply.rs (98%) rename rust/processor/src/{ => db/common}/models/coin_models/coin_utils.rs (97%) rename rust/processor/src/{ => db/common}/models/coin_models/mod.rs (100%) rename rust/processor/src/{ => db/common}/models/default_models/block_metadata_transactions.rs (100%) rename rust/processor/src/{ => db/common}/models/default_models/mod.rs (100%) rename rust/processor/src/{ => db/common}/models/default_models/move_modules.rs (100%) rename rust/processor/src/{ => db/common}/models/default_models/move_resources.rs (100%) rename rust/processor/src/{ => db/common}/models/default_models/move_tables.rs (100%) rename rust/processor/src/{ => db/common}/models/default_models/transactions.rs (100%) rename rust/processor/src/{ => db/common}/models/default_models/write_set_changes.rs (100%) rename rust/processor/src/{ => db/common}/models/events_models/events.rs (100%) rename rust/processor/src/{ => db/common}/models/events_models/mod.rs (100%) rename rust/processor/src/{ => db/common}/models/fungible_asset_models/mod.rs (100%) rename rust/processor/src/{ => db/common}/models/fungible_asset_models/v2_fungible_asset_activities.rs (99%) rename rust/processor/src/{ => db/common}/models/fungible_asset_models/v2_fungible_asset_balances.rs (99%) rename rust/processor/src/{ => db/common}/models/fungible_asset_models/v2_fungible_asset_utils.rs (99%) rename rust/processor/src/{ => db/common}/models/fungible_asset_models/v2_fungible_metadata.rs (99%) rename rust/processor/src/{ => db/common}/models/ledger_info.rs (81%) rename rust/processor/src/{ => db/common}/models/mod.rs (100%) rename rust/processor/src/{ => db/common}/models/object_models/mod.rs (100%) rename rust/processor/src/{ => db/common}/models/object_models/v2_object_utils.rs (99%) rename rust/processor/src/{ => db/common}/models/object_models/v2_objects.rs (97%) rename rust/processor/src/{ => db/common}/models/processor_status.rs (91%) rename rust/processor/src/{ => db/common}/models/property_map.rs (100%) rename rust/processor/src/{ => db/common}/models/stake_models/current_delegated_voter.rs (97%) rename rust/processor/src/{ => db/common}/models/stake_models/delegator_activities.rs (100%) rename rust/processor/src/{ => db/common}/models/stake_models/delegator_balances.rs (98%) rename rust/processor/src/{ => db/common}/models/stake_models/delegator_pools.rs (100%) rename rust/processor/src/{ => db/common}/models/stake_models/mod.rs (100%) rename rust/processor/src/{ => db/common}/models/stake_models/proposal_votes.rs (100%) rename rust/processor/src/{ => db/common}/models/stake_models/stake_utils.rs (98%) rename rust/processor/src/{ => db/common}/models/stake_models/staking_pool_voter.rs (100%) rename rust/processor/src/{ => db/common}/models/token_models/collection_datas.rs (97%) rename rust/processor/src/{ => db/common}/models/token_models/mod.rs (100%) rename rust/processor/src/{ => db/common}/models/token_models/nft_points.rs (100%) rename rust/processor/src/{ => db/common}/models/token_models/token_activities.rs (100%) rename rust/processor/src/{ => db/common}/models/token_models/token_claims.rs (100%) rename rust/processor/src/{ => db/common}/models/token_models/token_datas.rs (100%) rename rust/processor/src/{ => db/common}/models/token_models/token_ownerships.rs (100%) rename rust/processor/src/{ => db/common}/models/token_models/token_utils.rs (98%) rename rust/processor/src/{ => db/common}/models/token_models/tokens.rs (99%) rename rust/processor/src/{ => db/common}/models/token_v2_models/mod.rs (100%) rename rust/processor/src/{ => db/common}/models/token_v2_models/v1_token_royalty.rs (96%) rename rust/processor/src/{ => db/common}/models/token_v2_models/v2_collections.rs (98%) rename rust/processor/src/{ => db/common}/models/token_v2_models/v2_token_activities.rs (99%) rename rust/processor/src/{ => db/common}/models/token_v2_models/v2_token_datas.rs (99%) rename rust/processor/src/{ => db/common}/models/token_v2_models/v2_token_metadata.rs (99%) rename rust/processor/src/{ => db/common}/models/token_v2_models/v2_token_ownerships.rs (98%) rename rust/processor/src/{ => db/common}/models/token_v2_models/v2_token_utils.rs (99%) rename rust/processor/src/{ => db/common}/models/transaction_metadata_model/event_size_info.rs (100%) rename rust/processor/src/{ => db/common}/models/transaction_metadata_model/mod.rs (100%) rename rust/processor/src/{ => db/common}/models/transaction_metadata_model/transaction_size_info.rs (100%) rename rust/processor/src/{ => db/common}/models/transaction_metadata_model/write_set_size_info.rs (100%) rename rust/processor/src/{ => db/common}/models/user_transactions_models/mod.rs (100%) rename rust/processor/src/{ => db/common}/models/user_transactions_models/signatures.rs (100%) rename rust/processor/src/{ => db/common}/models/user_transactions_models/user_transactions.rs (100%) create mode 100644 rust/processor/src/db/mod.rs rename rust/processor/{migrations => src/db/postgres}/2024-04-18-173631_fungible_token/down.sql (100%) rename rust/processor/{migrations => src/db/postgres}/2024-04-18-173631_fungible_token/up.sql (100%) rename rust/processor/{migrations => src/db/postgres}/2024-04-29-215042_token_datas_burn/down.sql (100%) rename rust/processor/{migrations => src/db/postgres}/2024-04-29-215042_token_datas_burn/up.sql (100%) rename rust/processor/{migrations => src/db/postgres}/2024-05-04-025823_current_unified_fungible_asset_balance/down.sql (100%) rename rust/processor/{migrations => src/db/postgres}/2024-05-04-025823_current_unified_fungible_asset_balance/up.sql (100%) rename rust/processor/{migrations => src/db/postgres}/2024-05-17-215042_token_datas_burn_2/down.sql (100%) rename rust/processor/{migrations => src/db/postgres}/2024-05-17-215042_token_datas_burn_2/up.sql (100%) rename rust/processor/{migrations => src/db/postgres}/2024-05-21-221101_add_royalty_v1/down.sql (100%) rename rust/processor/{migrations => src/db/postgres}/2024-05-21-221101_add_royalty_v1/up.sql (100%) rename rust/processor/{ => src/db/postgres}/diesel.toml (100%) rename rust/processor/{ => src/db/postgres}/migrations/.keep (100%) rename rust/processor/{ => src/db/postgres}/migrations/00000000000000_diesel_initial_setup/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/00000000000000_diesel_initial_setup/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-08-08-043603_core_tables/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-08-08-043603_core_tables/up.sql (99%) rename rust/processor/{ => src/db/postgres}/migrations/2022-09-04-194128_add_token_data/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-09-04-194128_add_token_data/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-09-20-055651_add_current_token_data/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-09-20-055651_add_current_token_data/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-09-22-185845_token_offers/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-09-22-185845_token_offers/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-02-011015_add_table_handle_to_collection/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-02-011015_add_table_handle_to_collection/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-02-011020_ans_lookup_table/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-02-011020_ans_lookup_table/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-04-073529_add_coin_tables/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-04-073529_add_coin_tables/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-06-193846_add_indexer_status/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-06-193846_add_indexer_status/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-07-231825_add_coin_supply/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-07-231825_add_coin_supply/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-15-185912_improve_processor_recovery/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-15-185912_improve_processor_recovery/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-21-055518_stake_to_voter/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-21-055518_stake_to_voter/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-30-053525_add_vote_data/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-10-30-053525_add_vote_data/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-12-29-222902_curr_table_items/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2022-12-29-222902_curr_table_items/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-02-15-070116_stake_delegation/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-02-15-070116_stake_delegation/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-03-08-205402_nft_points/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-03-08-205402_nft_points/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-04-02-032121_delegator_pools/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-04-02-032121_delegator_pools/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-04-14-033932_optimize_queries/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-04-14-033932_optimize_queries/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-04-27-233343_delegation_pool_balances/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-04-27-233343_delegation_pool_balances/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-04-28-053048_object_token_v2/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-04-28-053048_object_token_v2/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-05-17-010107_activities_v2/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-05-17-010107_activities_v2/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-05-22-234344_delegated_staking_improvements/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-05-22-234344_delegated_staking_improvements/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-05-24-052435_token_properties_v2/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-05-24-052435_token_properties_v2/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-07-06-042159_minor_optimizations/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-07-06-042159_minor_optimizations/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-07-13-060328_transactions_by_address/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-07-13-060328_transactions_by_address/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-07-28-053854_entry_function/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-07-28-053854_entry_function/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-08-01-042050_fungible_assets/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-08-01-042050_fungible_assets/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-08-12-190707_add_ans_is_primary/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-08-12-190707_add_ans_is_primary/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-08-14-235438_add_current_delegated_voter_table/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-08-14-235438_add_current_delegated_voter_table/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-08-22-232603_add_ans_view/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-08-22-232603_add_ans_view/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-08-23-192343_fix_ans_view/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-08-23-192343_fix_ans_view/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-09-01-231248_events_v2/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-09-01-231248_events_v2/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-09-07-175640_storage_refund/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-09-07-175640_storage_refund/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-09-11-164718_ut_remove_constraint/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-09-11-164718_ut_remove_constraint/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-09-22-161603_add_ans_v2/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-09-22-161603_add_ans_v2/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-09-28-210956_nft_metadata/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-09-28-210956_nft_metadata/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-10-16-002253_alter_the_pubkey_column_length/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-10-16-002253_alter_the_pubkey_column_length/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-10-27-030502_event_type/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-10-27-030502_event_type/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-11-09-234724_delegator_balances/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-11-09-234724_delegator_balances/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-12-15-221028_payload_type/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-12-15-221028_payload_type/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-12-16-233224_add_objects_model/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2023-12-16-233224_add_objects_model/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2024-01-11-224315_update_process_status/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2024-01-11-224315_update_process_status/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2024-02-16-234847_any_signature/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2024-02-16-234847_any_signature/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2024-02-29-210322_transaction_metadata/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2024-02-29-210322_transaction_metadata/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2024-03-07-224504_fungible_asset_metadata_is_token_v2/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2024-03-07-224504_fungible_asset_metadata_is_token_v2/up.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2024-04-09-204519_ans_expiration_policy/down.sql (100%) rename rust/processor/{ => src/db/postgres}/migrations/2024-04-09-204519_ans_expiration_policy/up.sql (100%) rename rust/processor/src/{ => db/postgres}/schema.rs (100%) diff --git a/rust/processor/README.md b/rust/processor/README.md index 9b76901d5..e2e77684b 100644 --- a/rust/processor/README.md +++ b/rust/processor/README.md @@ -65,3 +65,6 @@ Indexer GRPC parser is to indexer data processor that leverages the indexer grpc ### Use a custom parser - Check our [indexer processors](https://github.com/aptos-labs/aptos-indexer-processors)! + +### Manually running diesel-cli +- `cd` into the database folder under `src/db/`, then run it. diff --git a/rust/processor/src/db/common/mod.rs b/rust/processor/src/db/common/mod.rs new file mode 100644 index 000000000..c446ac883 --- /dev/null +++ b/rust/processor/src/db/common/mod.rs @@ -0,0 +1 @@ +pub mod models; diff --git a/rust/processor/src/models/account_transaction_models/account_transactions.rs b/rust/processor/src/db/common/models/account_transaction_models/account_transactions.rs similarity index 99% rename from rust/processor/src/models/account_transaction_models/account_transactions.rs rename to rust/processor/src/db/common/models/account_transaction_models/account_transactions.rs index 6903c7773..fcf0c4666 100644 --- a/rust/processor/src/models/account_transaction_models/account_transactions.rs +++ b/rust/processor/src/db/common/models/account_transaction_models/account_transactions.rs @@ -6,7 +6,7 @@ #![allow(clippy::unused_unit)] use crate::{ - models::{ + db::common::models::{ object_models::v2_object_utils::ObjectWithMetadata, user_transactions_models::user_transactions::UserTransaction, }, diff --git a/rust/processor/src/models/account_transaction_models/mod.rs b/rust/processor/src/db/common/models/account_transaction_models/mod.rs similarity index 100% rename from rust/processor/src/models/account_transaction_models/mod.rs rename to rust/processor/src/db/common/models/account_transaction_models/mod.rs diff --git a/rust/processor/src/models/ans_models/ans_lookup.rs b/rust/processor/src/db/common/models/ans_models/ans_lookup.rs similarity index 100% rename from rust/processor/src/models/ans_models/ans_lookup.rs rename to rust/processor/src/db/common/models/ans_models/ans_lookup.rs diff --git a/rust/processor/src/models/ans_models/ans_lookup_v2.rs b/rust/processor/src/db/common/models/ans_models/ans_lookup_v2.rs similarity index 99% rename from rust/processor/src/models/ans_models/ans_lookup_v2.rs rename to rust/processor/src/db/common/models/ans_models/ans_lookup_v2.rs index e4a62d44c..7b68d7891 100644 --- a/rust/processor/src/models/ans_models/ans_lookup_v2.rs +++ b/rust/processor/src/db/common/models/ans_models/ans_lookup_v2.rs @@ -10,7 +10,7 @@ use super::{ ans_utils::{get_token_name, NameRecordV2, SetReverseLookupEvent, SubdomainExtV2}, }; use crate::{ - models::token_v2_models::v2_token_utils::TokenStandard, + db::common::models::token_v2_models::v2_token_utils::TokenStandard, schema::{ ans_lookup_v2, ans_primary_name_v2, current_ans_lookup_v2, current_ans_primary_name_v2, }, diff --git a/rust/processor/src/models/ans_models/ans_utils.rs b/rust/processor/src/db/common/models/ans_models/ans_utils.rs similarity index 88% rename from rust/processor/src/models/ans_models/ans_utils.rs rename to rust/processor/src/db/common/models/ans_models/ans_utils.rs index b607e78d8..4f6ee6ed9 100644 --- a/rust/processor/src/models/ans_models/ans_utils.rs +++ b/rust/processor/src/db/common/models/ans_models/ans_utils.rs @@ -5,7 +5,7 @@ #![allow(clippy::extra_unused_lifetimes)] use crate::{ - models::default_models::move_resources::MoveResource, + db::common::models::default_models::move_resources::MoveResource, utils::util::{ bigdecimal_to_u64, deserialize_from_string, parse_timestamp_secs, standardize_address, truncate_str, @@ -38,12 +38,6 @@ pub struct OptionalBigDecimal { vec: Vec, } -impl OptionalBigDecimal { - fn get_big_decimal(&self) -> Option { - self.vec.first().map(|x| x.0.clone()) - } -} - pub fn get_token_name(domain_name: &str, subdomain_name: &str) -> String { let domain = truncate_str(domain_name, DOMAIN_LENGTH); let subdomain = truncate_str(subdomain_name, DOMAIN_LENGTH); @@ -99,10 +93,6 @@ impl NameRecordV1 { parse_timestamp_secs(bigdecimal_to_u64(&self.expiration_time_sec), 0) } - pub fn get_property_version(&self) -> u64 { - bigdecimal_to_u64(&self.property_version) - } - pub fn get_target_address(&self) -> Option { self.target_address .get_string() @@ -309,44 +299,6 @@ impl SetReverseLookupEvent { get_token_name(&domain, &subdomain) } - pub fn get_curr_expiration_time(&self) -> Option { - self.curr_expiration_time_secs - .get_big_decimal() - .map(|x| parse_timestamp_secs(bigdecimal_to_u64(&x), 0)) - } - - pub fn get_prev_domain_trunc(&self) -> String { - truncate_str( - self.prev_domain_name - .get_string() - .unwrap_or_default() - .as_str(), - DOMAIN_LENGTH, - ) - } - - pub fn get_prev_subdomain_trunc(&self) -> String { - truncate_str( - self.prev_subdomain_name - .get_string() - .unwrap_or_default() - .as_str(), - DOMAIN_LENGTH, - ) - } - - pub fn get_prev_token_name(&self) -> String { - let domain = self.get_prev_domain_trunc(); - let subdomain = self.get_prev_subdomain_trunc(); - get_token_name(&domain, &subdomain) - } - - pub fn get_prev_expiration_time(&self) -> Option { - self.prev_expiration_time_secs - .get_big_decimal() - .map(|x| parse_timestamp_secs(bigdecimal_to_u64(&x), 0)) - } - pub fn from_event( event: &Event, ans_v2_contract_address: &str, diff --git a/rust/processor/src/models/ans_models/mod.rs b/rust/processor/src/db/common/models/ans_models/mod.rs similarity index 100% rename from rust/processor/src/models/ans_models/mod.rs rename to rust/processor/src/db/common/models/ans_models/mod.rs diff --git a/rust/processor/src/models/coin_models/coin_activities.rs b/rust/processor/src/db/common/models/coin_models/coin_activities.rs similarity index 99% rename from rust/processor/src/models/coin_models/coin_activities.rs rename to rust/processor/src/db/common/models/coin_models/coin_activities.rs index ced25cbf7..de81cd49c 100644 --- a/rust/processor/src/models/coin_models/coin_activities.rs +++ b/rust/processor/src/db/common/models/coin_models/coin_activities.rs @@ -11,7 +11,7 @@ use super::{ coin_utils::{CoinEvent, EventGuidResource}, }; use crate::{ - models::{ + db::common::models::{ fungible_asset_models::{ v2_fungible_asset_activities::{ CoinType, CurrentCoinBalancePK, EventToCoinType, BURN_GAS_EVENT_CREATION_NUM, diff --git a/rust/processor/src/models/coin_models/coin_balances.rs b/rust/processor/src/db/common/models/coin_models/coin_balances.rs similarity index 97% rename from rust/processor/src/models/coin_models/coin_balances.rs rename to rust/processor/src/db/common/models/coin_models/coin_balances.rs index 365730f04..a50691a77 100644 --- a/rust/processor/src/models/coin_models/coin_balances.rs +++ b/rust/processor/src/db/common/models/coin_models/coin_balances.rs @@ -7,7 +7,7 @@ use super::coin_utils::{CoinInfoType, CoinResource}; use crate::{ - models::fungible_asset_models::v2_fungible_asset_activities::EventToCoinType, + db::common::models::fungible_asset_models::v2_fungible_asset_activities::EventToCoinType, schema::{coin_balances, current_coin_balances}, utils::util::standardize_address, }; diff --git a/rust/processor/src/models/coin_models/coin_infos.rs b/rust/processor/src/db/common/models/coin_models/coin_infos.rs similarity index 100% rename from rust/processor/src/models/coin_models/coin_infos.rs rename to rust/processor/src/db/common/models/coin_models/coin_infos.rs diff --git a/rust/processor/src/models/coin_models/coin_supply.rs b/rust/processor/src/db/common/models/coin_models/coin_supply.rs similarity index 98% rename from rust/processor/src/models/coin_models/coin_supply.rs rename to rust/processor/src/db/common/models/coin_models/coin_supply.rs index e6fd91b45..f3942dae8 100644 --- a/rust/processor/src/models/coin_models/coin_supply.rs +++ b/rust/processor/src/db/common/models/coin_models/coin_supply.rs @@ -6,7 +6,7 @@ #![allow(clippy::unused_unit)] use crate::{ - models::default_models::move_tables::TableItem, + db::common::models::default_models::move_tables::TableItem, schema::coin_supply, utils::util::{hash_str, APTOS_COIN_TYPE_STR}, }; diff --git a/rust/processor/src/models/coin_models/coin_utils.rs b/rust/processor/src/db/common/models/coin_models/coin_utils.rs similarity index 97% rename from rust/processor/src/models/coin_models/coin_utils.rs rename to rust/processor/src/db/common/models/coin_models/coin_utils.rs index 9478f0eca..ec46f532c 100644 --- a/rust/processor/src/models/coin_models/coin_utils.rs +++ b/rust/processor/src/db/common/models/coin_models/coin_utils.rs @@ -5,7 +5,7 @@ #![allow(clippy::extra_unused_lifetimes)] use crate::{ - models::default_models::move_resources::MoveResource, + db::common::models::default_models::move_resources::MoveResource, utils::util::{deserialize_from_string, hash_str, standardize_address, truncate_str}, }; use anyhow::{bail, Context, Result}; @@ -78,13 +78,6 @@ pub struct IntegerWrapperResource { pub vec: Vec, } -impl IntegerWrapperResource { - /// In case we do want to track supply - pub fn get_supply(&self) -> Option { - self.vec.first().map(|inner| inner.value.clone()) - } -} - #[derive(Serialize, Deserialize, Debug, Clone)] pub struct AggregatorResource { pub handle: String, diff --git a/rust/processor/src/models/coin_models/mod.rs b/rust/processor/src/db/common/models/coin_models/mod.rs similarity index 100% rename from rust/processor/src/models/coin_models/mod.rs rename to rust/processor/src/db/common/models/coin_models/mod.rs diff --git a/rust/processor/src/models/default_models/block_metadata_transactions.rs b/rust/processor/src/db/common/models/default_models/block_metadata_transactions.rs similarity index 100% rename from rust/processor/src/models/default_models/block_metadata_transactions.rs rename to rust/processor/src/db/common/models/default_models/block_metadata_transactions.rs diff --git a/rust/processor/src/models/default_models/mod.rs b/rust/processor/src/db/common/models/default_models/mod.rs similarity index 100% rename from rust/processor/src/models/default_models/mod.rs rename to rust/processor/src/db/common/models/default_models/mod.rs diff --git a/rust/processor/src/models/default_models/move_modules.rs b/rust/processor/src/db/common/models/default_models/move_modules.rs similarity index 100% rename from rust/processor/src/models/default_models/move_modules.rs rename to rust/processor/src/db/common/models/default_models/move_modules.rs diff --git a/rust/processor/src/models/default_models/move_resources.rs b/rust/processor/src/db/common/models/default_models/move_resources.rs similarity index 100% rename from rust/processor/src/models/default_models/move_resources.rs rename to rust/processor/src/db/common/models/default_models/move_resources.rs diff --git a/rust/processor/src/models/default_models/move_tables.rs b/rust/processor/src/db/common/models/default_models/move_tables.rs similarity index 100% rename from rust/processor/src/models/default_models/move_tables.rs rename to rust/processor/src/db/common/models/default_models/move_tables.rs diff --git a/rust/processor/src/models/default_models/transactions.rs b/rust/processor/src/db/common/models/default_models/transactions.rs similarity index 100% rename from rust/processor/src/models/default_models/transactions.rs rename to rust/processor/src/db/common/models/default_models/transactions.rs diff --git a/rust/processor/src/models/default_models/write_set_changes.rs b/rust/processor/src/db/common/models/default_models/write_set_changes.rs similarity index 100% rename from rust/processor/src/models/default_models/write_set_changes.rs rename to rust/processor/src/db/common/models/default_models/write_set_changes.rs diff --git a/rust/processor/src/models/events_models/events.rs b/rust/processor/src/db/common/models/events_models/events.rs similarity index 100% rename from rust/processor/src/models/events_models/events.rs rename to rust/processor/src/db/common/models/events_models/events.rs diff --git a/rust/processor/src/models/events_models/mod.rs b/rust/processor/src/db/common/models/events_models/mod.rs similarity index 100% rename from rust/processor/src/models/events_models/mod.rs rename to rust/processor/src/db/common/models/events_models/mod.rs diff --git a/rust/processor/src/models/fungible_asset_models/mod.rs b/rust/processor/src/db/common/models/fungible_asset_models/mod.rs similarity index 100% rename from rust/processor/src/models/fungible_asset_models/mod.rs rename to rust/processor/src/db/common/models/fungible_asset_models/mod.rs diff --git a/rust/processor/src/models/fungible_asset_models/v2_fungible_asset_activities.rs b/rust/processor/src/db/common/models/fungible_asset_models/v2_fungible_asset_activities.rs similarity index 99% rename from rust/processor/src/models/fungible_asset_models/v2_fungible_asset_activities.rs rename to rust/processor/src/db/common/models/fungible_asset_models/v2_fungible_asset_activities.rs index 06802ba1e..c4ee7880b 100644 --- a/rust/processor/src/models/fungible_asset_models/v2_fungible_asset_activities.rs +++ b/rust/processor/src/db/common/models/fungible_asset_models/v2_fungible_asset_activities.rs @@ -7,7 +7,7 @@ use super::v2_fungible_asset_utils::{FeeStatement, FungibleAssetEvent}; use crate::{ - models::{ + db::common::models::{ coin_models::{ coin_activities::CoinActivity, coin_utils::{CoinEvent, CoinInfoType, EventGuidResource}, diff --git a/rust/processor/src/models/fungible_asset_models/v2_fungible_asset_balances.rs b/rust/processor/src/db/common/models/fungible_asset_models/v2_fungible_asset_balances.rs similarity index 99% rename from rust/processor/src/models/fungible_asset_models/v2_fungible_asset_balances.rs rename to rust/processor/src/db/common/models/fungible_asset_models/v2_fungible_asset_balances.rs index b409de169..369bc1287 100644 --- a/rust/processor/src/models/fungible_asset_models/v2_fungible_asset_balances.rs +++ b/rust/processor/src/db/common/models/fungible_asset_models/v2_fungible_asset_balances.rs @@ -9,7 +9,7 @@ use super::{ v2_fungible_asset_activities::EventToCoinType, v2_fungible_asset_utils::FungibleAssetStore, }; use crate::{ - models::{ + db::common::models::{ coin_models::coin_utils::{CoinInfoType, CoinResource}, object_models::v2_object_utils::ObjectAggregatedDataMapping, token_v2_models::v2_token_utils::{TokenStandard, V2_STANDARD}, diff --git a/rust/processor/src/models/fungible_asset_models/v2_fungible_asset_utils.rs b/rust/processor/src/db/common/models/fungible_asset_models/v2_fungible_asset_utils.rs similarity index 99% rename from rust/processor/src/models/fungible_asset_models/v2_fungible_asset_utils.rs rename to rust/processor/src/db/common/models/fungible_asset_models/v2_fungible_asset_utils.rs index 6529b7cbd..5de2a9d49 100644 --- a/rust/processor/src/models/fungible_asset_models/v2_fungible_asset_utils.rs +++ b/rust/processor/src/db/common/models/fungible_asset_models/v2_fungible_asset_utils.rs @@ -5,7 +5,7 @@ #![allow(clippy::extra_unused_lifetimes)] use crate::{ - models::{ + db::common::models::{ coin_models::coin_utils::COIN_ADDR, default_models::move_resources::MoveResource, token_models::token_utils::URI_LENGTH, token_v2_models::v2_token_utils::ResourceReference, }, diff --git a/rust/processor/src/models/fungible_asset_models/v2_fungible_metadata.rs b/rust/processor/src/db/common/models/fungible_asset_models/v2_fungible_metadata.rs similarity index 99% rename from rust/processor/src/models/fungible_asset_models/v2_fungible_metadata.rs rename to rust/processor/src/db/common/models/fungible_asset_models/v2_fungible_metadata.rs index 452e71716..bcb1df18d 100644 --- a/rust/processor/src/models/fungible_asset_models/v2_fungible_metadata.rs +++ b/rust/processor/src/db/common/models/fungible_asset_models/v2_fungible_metadata.rs @@ -7,7 +7,7 @@ use super::v2_fungible_asset_utils::FungibleAssetMetadata; use crate::{ - models::{ + db::common::models::{ coin_models::coin_utils::{CoinInfoType, CoinResource}, object_models::v2_object_utils::ObjectAggregatedDataMapping, token_v2_models::v2_token_utils::TokenStandard, diff --git a/rust/processor/src/models/ledger_info.rs b/rust/processor/src/db/common/models/ledger_info.rs similarity index 81% rename from rust/processor/src/models/ledger_info.rs rename to rust/processor/src/db/common/models/ledger_info.rs index 17ca11add..f25759ec5 100644 --- a/rust/processor/src/models/ledger_info.rs +++ b/rust/processor/src/db/common/models/ledger_info.rs @@ -3,7 +3,7 @@ #![allow(clippy::extra_unused_lifetimes)] -use crate::{schema::ledger_infos, utils::database::PgPoolConnection}; +use crate::{schema::ledger_infos, utils::database::DbPoolConnection}; use diesel::{OptionalExtension, QueryDsl}; use diesel_async::RunQueryDsl; @@ -15,7 +15,7 @@ pub struct LedgerInfo { } impl LedgerInfo { - pub async fn get(conn: &mut PgPoolConnection<'_>) -> diesel::QueryResult> { + pub async fn get(conn: &mut DbPoolConnection<'_>) -> diesel::QueryResult> { ledger_infos::table .select(ledger_infos::all_columns) .first::(conn) diff --git a/rust/processor/src/models/mod.rs b/rust/processor/src/db/common/models/mod.rs similarity index 100% rename from rust/processor/src/models/mod.rs rename to rust/processor/src/db/common/models/mod.rs diff --git a/rust/processor/src/models/object_models/mod.rs b/rust/processor/src/db/common/models/object_models/mod.rs similarity index 100% rename from rust/processor/src/models/object_models/mod.rs rename to rust/processor/src/db/common/models/object_models/mod.rs diff --git a/rust/processor/src/models/object_models/v2_object_utils.rs b/rust/processor/src/db/common/models/object_models/v2_object_utils.rs similarity index 99% rename from rust/processor/src/models/object_models/v2_object_utils.rs rename to rust/processor/src/db/common/models/object_models/v2_object_utils.rs index 8bb8659a2..7c1c850bc 100644 --- a/rust/processor/src/models/object_models/v2_object_utils.rs +++ b/rust/processor/src/db/common/models/object_models/v2_object_utils.rs @@ -6,7 +6,7 @@ #![allow(clippy::unused_unit)] use crate::{ - models::{ + db::common::models::{ default_models::move_resources::MoveResource, fungible_asset_models::v2_fungible_asset_utils::{ ConcurrentFungibleAssetBalance, ConcurrentFungibleAssetSupply, FungibleAssetMetadata, diff --git a/rust/processor/src/models/object_models/v2_objects.rs b/rust/processor/src/db/common/models/object_models/v2_objects.rs similarity index 97% rename from rust/processor/src/models/object_models/v2_objects.rs rename to rust/processor/src/db/common/models/object_models/v2_objects.rs index 31381e157..26ec38ced 100644 --- a/rust/processor/src/models/object_models/v2_objects.rs +++ b/rust/processor/src/db/common/models/object_models/v2_objects.rs @@ -7,9 +7,9 @@ use super::v2_object_utils::{CurrentObjectPK, ObjectAggregatedDataMapping}; use crate::{ - models::default_models::move_resources::MoveResource, + db::common::models::default_models::move_resources::MoveResource, schema::{current_objects, objects}, - utils::{database::PgPoolConnection, util::standardize_address}, + utils::{database::DbPoolConnection, util::standardize_address}, }; use ahash::AHashMap; use aptos_protos::transaction::v1::{DeleteResource, WriteResource}; @@ -106,7 +106,7 @@ impl Object { txn_version: i64, write_set_change_index: i64, object_mapping: &AHashMap, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, query_retries: u32, query_retry_delay_ms: u64, ) -> anyhow::Result> { @@ -169,7 +169,7 @@ impl Object { /// This is actually not great because object owner can change. The best we can do now though. /// This will loop forever until we get the object from the db pub async fn get_current_object( - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, object_address: &str, query_retries: u32, query_retry_delay_ms: u64, @@ -205,7 +205,7 @@ impl CurrentObjectQuery { /// TODO: Change this to a KV store pub async fn get_by_address( object_address: &str, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, ) -> diesel::QueryResult { current_objects::table .filter(current_objects::object_address.eq(object_address)) diff --git a/rust/processor/src/models/processor_status.rs b/rust/processor/src/db/common/models/processor_status.rs similarity index 91% rename from rust/processor/src/models/processor_status.rs rename to rust/processor/src/db/common/models/processor_status.rs index 0141a4eef..2d7928511 100644 --- a/rust/processor/src/models/processor_status.rs +++ b/rust/processor/src/db/common/models/processor_status.rs @@ -3,7 +3,7 @@ #![allow(clippy::extra_unused_lifetimes)] -use crate::{schema::processor_status, utils::database::PgPoolConnection}; +use crate::{schema::processor_status, utils::database::DbPoolConnection}; use diesel::{ExpressionMethods, OptionalExtension, QueryDsl}; use diesel_async::RunQueryDsl; @@ -29,7 +29,7 @@ pub struct ProcessorStatusQuery { impl ProcessorStatusQuery { pub async fn get_by_processor( processor_name: &str, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, ) -> diesel::QueryResult> { processor_status::table .filter(processor_status::processor.eq(processor_name)) diff --git a/rust/processor/src/models/property_map.rs b/rust/processor/src/db/common/models/property_map.rs similarity index 100% rename from rust/processor/src/models/property_map.rs rename to rust/processor/src/db/common/models/property_map.rs diff --git a/rust/processor/src/models/stake_models/current_delegated_voter.rs b/rust/processor/src/db/common/models/stake_models/current_delegated_voter.rs similarity index 97% rename from rust/processor/src/models/stake_models/current_delegated_voter.rs rename to rust/processor/src/db/common/models/stake_models/current_delegated_voter.rs index 889a28e29..e87dcde71 100644 --- a/rust/processor/src/models/stake_models/current_delegated_voter.rs +++ b/rust/processor/src/db/common/models/stake_models/current_delegated_voter.rs @@ -10,7 +10,7 @@ use super::{ }; use crate::{ schema::current_delegated_voter, - utils::{database::PgPoolConnection, util::standardize_address}, + utils::{database::DbPoolConnection, util::standardize_address}, }; use ahash::AHashMap; use aptos_protos::transaction::v1::WriteTableItem; @@ -75,7 +75,7 @@ impl CurrentDelegatedVoter { txn_version: i64, txn_timestamp: chrono::NaiveDateTime, vote_delegation_handle_to_pool_address: &VoteDelegationTableHandleToPool, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, query_retries: u32, query_retry_delay_ms: u64, ) -> anyhow::Result { @@ -137,7 +137,7 @@ impl CurrentDelegatedVoter { txn_timestamp: chrono::NaiveDateTime, active_pool_to_staking_pool: &ShareToStakingPoolMapping, previous_delegated_voters: &CurrentDelegatedVoterMap, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, query_retries: u32, query_retry_delay_ms: u64, ) -> anyhow::Result> { @@ -185,7 +185,7 @@ impl CurrentDelegatedVoter { } pub async fn get_delegation_pool_address_by_table_handle( - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, table_handle: &str, query_retries: u32, query_retry_delay_ms: u64, @@ -211,7 +211,7 @@ impl CurrentDelegatedVoter { } pub async fn get_existence_by_pk( - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, delegator_address: &str, delegation_pool_address: &str, query_retries: u32, @@ -242,7 +242,7 @@ impl CurrentDelegatedVoter { impl CurrentDelegatedVoterQuery { pub async fn get_by_table_handle( - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, table_handle: &str, ) -> diesel::QueryResult { current_delegated_voter::table @@ -252,7 +252,7 @@ impl CurrentDelegatedVoterQuery { } pub async fn get_by_pk( - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, delegator_address: &str, delegation_pool_address: &str, ) -> diesel::QueryResult { diff --git a/rust/processor/src/models/stake_models/delegator_activities.rs b/rust/processor/src/db/common/models/stake_models/delegator_activities.rs similarity index 100% rename from rust/processor/src/models/stake_models/delegator_activities.rs rename to rust/processor/src/db/common/models/stake_models/delegator_activities.rs diff --git a/rust/processor/src/models/stake_models/delegator_balances.rs b/rust/processor/src/db/common/models/stake_models/delegator_balances.rs similarity index 98% rename from rust/processor/src/models/stake_models/delegator_balances.rs rename to rust/processor/src/db/common/models/stake_models/delegator_balances.rs index 0293574a6..54790f43b 100644 --- a/rust/processor/src/models/stake_models/delegator_balances.rs +++ b/rust/processor/src/db/common/models/stake_models/delegator_balances.rs @@ -5,9 +5,9 @@ use super::delegator_pools::{DelegatorPool, DelegatorPoolBalanceMetadata, PoolBalanceMetadata}; use crate::{ - models::default_models::move_tables::TableItem, + db::common::models::default_models::move_tables::TableItem, schema::{current_delegator_balances, delegator_balances}, - utils::{database::PgPoolConnection, util::standardize_address}, + utils::{database::DbPoolConnection, util::standardize_address}, }; use ahash::AHashMap; use anyhow::Context; @@ -133,7 +133,7 @@ impl CurrentDelegatorBalance { write_set_change_index: i64, inactive_pool_to_staking_pool: &ShareToStakingPoolMapping, inactive_share_to_pool: &ShareToPoolMapping, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, query_retries: u32, query_retry_delay_ms: u64, ) -> anyhow::Result> { @@ -257,7 +257,7 @@ impl CurrentDelegatorBalance { write_set_change_index: i64, inactive_pool_to_staking_pool: &ShareToStakingPoolMapping, inactive_share_to_pool: &ShareToPoolMapping, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, query_retries: u32, query_retry_delay_ms: u64, ) -> anyhow::Result> { @@ -369,7 +369,7 @@ impl CurrentDelegatorBalance { } pub async fn get_staking_pool_from_inactive_share_handle( - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, table_handle: &str, query_retries: u32, query_retry_delay_ms: u64, @@ -397,7 +397,7 @@ impl CurrentDelegatorBalance { pub async fn from_transaction( transaction: &Transaction, active_pool_to_staking_pool: &ShareToStakingPoolMapping, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, query_retries: u32, query_retry_delay_ms: u64, ) -> anyhow::Result<(Vec, CurrentDelegatorBalanceMap)> { @@ -503,7 +503,7 @@ impl CurrentDelegatorBalance { impl CurrentDelegatorBalanceQuery { pub async fn get_by_inactive_share_handle( - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, table_handle: &str, ) -> diesel::QueryResult { current_delegator_balances::table diff --git a/rust/processor/src/models/stake_models/delegator_pools.rs b/rust/processor/src/db/common/models/stake_models/delegator_pools.rs similarity index 100% rename from rust/processor/src/models/stake_models/delegator_pools.rs rename to rust/processor/src/db/common/models/stake_models/delegator_pools.rs diff --git a/rust/processor/src/models/stake_models/mod.rs b/rust/processor/src/db/common/models/stake_models/mod.rs similarity index 100% rename from rust/processor/src/models/stake_models/mod.rs rename to rust/processor/src/db/common/models/stake_models/mod.rs diff --git a/rust/processor/src/models/stake_models/proposal_votes.rs b/rust/processor/src/db/common/models/stake_models/proposal_votes.rs similarity index 100% rename from rust/processor/src/models/stake_models/proposal_votes.rs rename to rust/processor/src/db/common/models/stake_models/proposal_votes.rs diff --git a/rust/processor/src/models/stake_models/stake_utils.rs b/rust/processor/src/db/common/models/stake_models/stake_utils.rs similarity index 98% rename from rust/processor/src/models/stake_models/stake_utils.rs rename to rust/processor/src/db/common/models/stake_models/stake_utils.rs index 6c91364d6..f623d3ffb 100644 --- a/rust/processor/src/models/stake_models/stake_utils.rs +++ b/rust/processor/src/db/common/models/stake_models/stake_utils.rs @@ -2,7 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 use crate::{ - models::{default_models::move_resources::MoveResource, token_models::token_utils::Table}, + db::common::models::{ + default_models::move_resources::MoveResource, token_models::token_utils::Table, + }, utils::util::{deserialize_from_string, standardize_address}, }; use anyhow::{Context, Result}; diff --git a/rust/processor/src/models/stake_models/staking_pool_voter.rs b/rust/processor/src/db/common/models/stake_models/staking_pool_voter.rs similarity index 100% rename from rust/processor/src/models/stake_models/staking_pool_voter.rs rename to rust/processor/src/db/common/models/stake_models/staking_pool_voter.rs diff --git a/rust/processor/src/models/token_models/collection_datas.rs b/rust/processor/src/db/common/models/token_models/collection_datas.rs similarity index 97% rename from rust/processor/src/models/token_models/collection_datas.rs rename to rust/processor/src/db/common/models/token_models/collection_datas.rs index 57444dac4..977fa8fc8 100644 --- a/rust/processor/src/models/token_models/collection_datas.rs +++ b/rust/processor/src/db/common/models/token_models/collection_datas.rs @@ -11,7 +11,7 @@ use super::{ }; use crate::{ schema::{collection_datas, current_collection_datas}, - utils::{database::PgPoolConnection, util::standardize_address}, + utils::{database::DbPoolConnection, util::standardize_address}, }; use aptos_protos::transaction::v1::WriteTableItem; use bigdecimal::BigDecimal; @@ -85,7 +85,7 @@ impl CollectionData { txn_version: i64, txn_timestamp: chrono::NaiveDateTime, table_handle_to_owner: &TableHandleToOwner, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, query_retries: u32, query_retry_delay_ms: u64, ) -> anyhow::Result> { @@ -173,7 +173,7 @@ impl CollectionData { /// cannot change, we can just look in the current_collection_datas table. /// Retrying a few times since this collection could've been written in a separate thread. pub async fn get_collection_creator( - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, table_handle: &str, query_retries: u32, query_retry_delay_ms: u64, @@ -197,7 +197,7 @@ impl CollectionData { impl CurrentCollectionDataQuery { pub async fn get_by_table_handle( - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, table_handle: &str, ) -> diesel::QueryResult { current_collection_datas::table diff --git a/rust/processor/src/models/token_models/mod.rs b/rust/processor/src/db/common/models/token_models/mod.rs similarity index 100% rename from rust/processor/src/models/token_models/mod.rs rename to rust/processor/src/db/common/models/token_models/mod.rs diff --git a/rust/processor/src/models/token_models/nft_points.rs b/rust/processor/src/db/common/models/token_models/nft_points.rs similarity index 100% rename from rust/processor/src/models/token_models/nft_points.rs rename to rust/processor/src/db/common/models/token_models/nft_points.rs diff --git a/rust/processor/src/models/token_models/token_activities.rs b/rust/processor/src/db/common/models/token_models/token_activities.rs similarity index 100% rename from rust/processor/src/models/token_models/token_activities.rs rename to rust/processor/src/db/common/models/token_models/token_activities.rs diff --git a/rust/processor/src/models/token_models/token_claims.rs b/rust/processor/src/db/common/models/token_models/token_claims.rs similarity index 100% rename from rust/processor/src/models/token_models/token_claims.rs rename to rust/processor/src/db/common/models/token_models/token_claims.rs diff --git a/rust/processor/src/models/token_models/token_datas.rs b/rust/processor/src/db/common/models/token_models/token_datas.rs similarity index 100% rename from rust/processor/src/models/token_models/token_datas.rs rename to rust/processor/src/db/common/models/token_models/token_datas.rs diff --git a/rust/processor/src/models/token_models/token_ownerships.rs b/rust/processor/src/db/common/models/token_models/token_ownerships.rs similarity index 100% rename from rust/processor/src/models/token_models/token_ownerships.rs rename to rust/processor/src/db/common/models/token_models/token_ownerships.rs diff --git a/rust/processor/src/models/token_models/token_utils.rs b/rust/processor/src/db/common/models/token_models/token_utils.rs similarity index 98% rename from rust/processor/src/models/token_models/token_utils.rs rename to rust/processor/src/db/common/models/token_models/token_utils.rs index 94efbc77d..aa2d74c18 100644 --- a/rust/processor/src/models/token_models/token_utils.rs +++ b/rust/processor/src/db/common/models/token_models/token_utils.rs @@ -95,10 +95,6 @@ impl CollectionDataIdType { hash_str(&self.to_string()) } - pub fn get_name_trunc(&self) -> String { - truncate_str(&self.name, NAME_LENGTH) - } - pub fn to_id(&self) -> String { format!("0x{}", self.to_hash()) } @@ -149,10 +145,6 @@ impl TokenDataType { pub fn get_uri_trunc(&self) -> String { truncate_str(&self.uri, URI_LENGTH) } - - pub fn get_name_trunc(&self) -> String { - truncate_str(&self.name, NAME_LENGTH) - } } #[derive(Serialize, Deserialize, Debug, Clone)] diff --git a/rust/processor/src/models/token_models/tokens.rs b/rust/processor/src/db/common/models/token_models/tokens.rs similarity index 99% rename from rust/processor/src/models/token_models/tokens.rs rename to rust/processor/src/db/common/models/token_models/tokens.rs index a6703ea3e..f6d2e8fab 100644 --- a/rust/processor/src/models/token_models/tokens.rs +++ b/rust/processor/src/db/common/models/token_models/tokens.rs @@ -13,11 +13,11 @@ use super::{ token_utils::{TokenResource, TokenWriteSet}, }; use crate::{ - models::default_models::move_resources::MoveResource, + db::common::models::default_models::move_resources::MoveResource, schema::tokens, utils::{ counters::PROCESSOR_UNKNOWN_TYPE_COUNT, - database::PgPoolConnection, + database::DbPoolConnection, util::{ensure_not_negative, parse_timestamp, standardize_address}, }, }; @@ -72,7 +72,7 @@ impl Token { pub async fn from_transaction( transaction: &Transaction, table_handle_to_owner: &TableHandleToOwner, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, query_retries: u32, query_retry_delay_ms: u64, ) -> ( diff --git a/rust/processor/src/models/token_v2_models/mod.rs b/rust/processor/src/db/common/models/token_v2_models/mod.rs similarity index 100% rename from rust/processor/src/models/token_v2_models/mod.rs rename to rust/processor/src/db/common/models/token_v2_models/mod.rs diff --git a/rust/processor/src/models/token_v2_models/v1_token_royalty.rs b/rust/processor/src/db/common/models/token_v2_models/v1_token_royalty.rs similarity index 96% rename from rust/processor/src/models/token_v2_models/v1_token_royalty.rs rename to rust/processor/src/db/common/models/token_v2_models/v1_token_royalty.rs index b45d7c6a9..f7e1cb124 100644 --- a/rust/processor/src/models/token_v2_models/v1_token_royalty.rs +++ b/rust/processor/src/db/common/models/token_v2_models/v1_token_royalty.rs @@ -5,7 +5,9 @@ #![allow(clippy::extra_unused_lifetimes)] #![allow(clippy::unused_unit)] -use crate::{models::token_models::token_utils::TokenWriteSet, schema::current_token_royalty_v1}; +use crate::{ + db::common::models::token_models::token_utils::TokenWriteSet, schema::current_token_royalty_v1, +}; use aptos_protos::transaction::v1::WriteTableItem; use bigdecimal::BigDecimal; use field_count::FieldCount; diff --git a/rust/processor/src/models/token_v2_models/v2_collections.rs b/rust/processor/src/db/common/models/token_v2_models/v2_collections.rs similarity index 98% rename from rust/processor/src/models/token_v2_models/v2_collections.rs rename to rust/processor/src/db/common/models/token_v2_models/v2_collections.rs index 66eabcc2a..5d3a394a9 100644 --- a/rust/processor/src/models/token_v2_models/v2_collections.rs +++ b/rust/processor/src/db/common/models/token_v2_models/v2_collections.rs @@ -7,7 +7,7 @@ use super::v2_token_utils::{TokenStandard, V2TokenResource}; use crate::{ - models::{ + db::common::models::{ default_models::move_resources::MoveResource, object_models::v2_object_utils::ObjectAggregatedDataMapping, token_models::{ @@ -17,7 +17,7 @@ use crate::{ }, }, schema::{collections_v2, current_collections_v2}, - utils::{database::PgPoolConnection, util::standardize_address}, + utils::{database::DbPoolConnection, util::standardize_address}, }; use anyhow::Context; use aptos_protos::transaction::v1::{WriteResource, WriteTableItem}; @@ -200,7 +200,7 @@ impl CollectionV2 { write_set_change_index: i64, txn_timestamp: chrono::NaiveDateTime, table_handle_to_owner: &TableHandleToOwner, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, query_retries: u32, query_retry_delay_ms: u64, ) -> anyhow::Result> { @@ -309,7 +309,7 @@ impl CollectionV2 { /// cannot change, we can just look in the current_collection_datas table. /// Retrying a few times since this collection could've been written in a separate thread. async fn get_collection_creator_for_v1( - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, table_handle: &str, query_retries: u32, query_retry_delay_ms: u64, @@ -332,7 +332,7 @@ impl CollectionV2 { /// TODO: Change this to a KV store async fn get_by_table_handle( - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, table_handle: &str, ) -> anyhow::Result { let mut res: Vec> = sql_query( diff --git a/rust/processor/src/models/token_v2_models/v2_token_activities.rs b/rust/processor/src/db/common/models/token_v2_models/v2_token_activities.rs similarity index 99% rename from rust/processor/src/models/token_v2_models/v2_token_activities.rs rename to rust/processor/src/db/common/models/token_v2_models/v2_token_activities.rs index af66fe17b..83ee38388 100644 --- a/rust/processor/src/models/token_v2_models/v2_token_activities.rs +++ b/rust/processor/src/db/common/models/token_v2_models/v2_token_activities.rs @@ -7,7 +7,7 @@ use super::v2_token_utils::{TokenStandard, V2TokenEvent}; use crate::{ - models::{ + db::common::models::{ object_models::v2_object_utils::ObjectAggregatedDataMapping, token_models::token_utils::{TokenDataIdType, TokenEvent}, }, diff --git a/rust/processor/src/models/token_v2_models/v2_token_datas.rs b/rust/processor/src/db/common/models/token_v2_models/v2_token_datas.rs similarity index 99% rename from rust/processor/src/models/token_v2_models/v2_token_datas.rs rename to rust/processor/src/db/common/models/token_v2_models/v2_token_datas.rs index 0e1b2de13..3be211eb0 100644 --- a/rust/processor/src/models/token_v2_models/v2_token_datas.rs +++ b/rust/processor/src/db/common/models/token_v2_models/v2_token_datas.rs @@ -7,7 +7,7 @@ use super::v2_token_utils::{TokenStandard, TokenV2, TokenV2Burned}; use crate::{ - models::{ + db::common::models::{ object_models::v2_object_utils::ObjectAggregatedDataMapping, token_models::token_utils::TokenWriteSet, }, diff --git a/rust/processor/src/models/token_v2_models/v2_token_metadata.rs b/rust/processor/src/db/common/models/token_v2_models/v2_token_metadata.rs similarity index 99% rename from rust/processor/src/models/token_v2_models/v2_token_metadata.rs rename to rust/processor/src/db/common/models/token_v2_models/v2_token_metadata.rs index 3a2599b28..d059a3da9 100644 --- a/rust/processor/src/models/token_v2_models/v2_token_metadata.rs +++ b/rust/processor/src/db/common/models/token_v2_models/v2_token_metadata.rs @@ -7,7 +7,7 @@ use super::v2_token_utils::TOKEN_V2_ADDR; use crate::{ - models::{ + db::common::models::{ coin_models::coin_utils::COIN_ADDR, default_models::move_resources::MoveResource, object_models::v2_object_utils::ObjectAggregatedDataMapping, diff --git a/rust/processor/src/models/token_v2_models/v2_token_ownerships.rs b/rust/processor/src/db/common/models/token_v2_models/v2_token_ownerships.rs similarity index 98% rename from rust/processor/src/models/token_v2_models/v2_token_ownerships.rs rename to rust/processor/src/db/common/models/token_v2_models/v2_token_ownerships.rs index 4d305558c..6377d1849 100644 --- a/rust/processor/src/models/token_v2_models/v2_token_ownerships.rs +++ b/rust/processor/src/db/common/models/token_v2_models/v2_token_ownerships.rs @@ -10,14 +10,14 @@ use super::{ v2_token_utils::{TokenStandard, TokenV2Burned}, }; use crate::{ - models::{ + db::common::models::{ object_models::v2_object_utils::{ObjectAggregatedDataMapping, ObjectWithMetadata}, token_models::{token_utils::TokenWriteSet, tokens::TableHandleToOwner}, token_v2_models::v2_token_utils::DEFAULT_OWNER_ADDRESS, }, schema::{current_token_ownerships_v2, token_ownerships_v2}, utils::{ - database::PgPoolConnection, + database::DbPoolConnection, util::{ensure_not_negative, standardize_address}, }, }; @@ -227,7 +227,7 @@ impl TokenOwnershipV2 { txn_timestamp: chrono::NaiveDateTime, prior_nft_ownership: &AHashMap, tokens_burned: &TokenV2Burned, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, query_retries: u32, query_retry_delay_ms: u64, ) -> anyhow::Result> { @@ -303,7 +303,7 @@ impl TokenOwnershipV2 { txn_timestamp: chrono::NaiveDateTime, prior_nft_ownership: &AHashMap, tokens_burned: &TokenV2Burned, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, query_retries: u32, query_retry_delay_ms: u64, ) -> anyhow::Result> { @@ -329,7 +329,7 @@ impl TokenOwnershipV2 { txn_timestamp: chrono::NaiveDateTime, prior_nft_ownership: &AHashMap, tokens_burned: &TokenV2Burned, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, query_retries: u32, query_retry_delay_ms: u64, ) -> anyhow::Result> { @@ -569,7 +569,7 @@ impl TokenOwnershipV2 { impl CurrentTokenOwnershipV2Query { pub async fn get_latest_owned_nft_by_token_data_id( - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, token_data_id: &str, query_retries: u32, query_retry_delay_ms: u64, @@ -600,7 +600,7 @@ impl CurrentTokenOwnershipV2Query { } async fn get_latest_owned_nft_by_token_data_id_impl( - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, token_data_id: &str, ) -> diesel::QueryResult { current_token_ownerships_v2::table diff --git a/rust/processor/src/models/token_v2_models/v2_token_utils.rs b/rust/processor/src/db/common/models/token_v2_models/v2_token_utils.rs similarity index 99% rename from rust/processor/src/models/token_v2_models/v2_token_utils.rs rename to rust/processor/src/db/common/models/token_v2_models/v2_token_utils.rs index 539fb1f97..b5a3e938c 100644 --- a/rust/processor/src/models/token_v2_models/v2_token_utils.rs +++ b/rust/processor/src/db/common/models/token_v2_models/v2_token_utils.rs @@ -5,7 +5,7 @@ #![allow(clippy::extra_unused_lifetimes)] use crate::{ - models::{ + db::common::models::{ coin_models::coin_utils::COIN_ADDR, default_models::move_resources::MoveResource, object_models::v2_object_utils::{CurrentObjectPK, ObjectCore}, @@ -37,7 +37,6 @@ lazy_static! { /// Maps address to burn event. If it's an old event previous_owner will be empty pub type TokenV2Burned = AHashMap; pub type TokenV2Minted = AHashSet; -pub type TokenV2MintedPK = (CurrentObjectPK, i64); /// Tracks which token standard a token / collection is built upon #[derive(Serialize)] diff --git a/rust/processor/src/models/transaction_metadata_model/event_size_info.rs b/rust/processor/src/db/common/models/transaction_metadata_model/event_size_info.rs similarity index 100% rename from rust/processor/src/models/transaction_metadata_model/event_size_info.rs rename to rust/processor/src/db/common/models/transaction_metadata_model/event_size_info.rs diff --git a/rust/processor/src/models/transaction_metadata_model/mod.rs b/rust/processor/src/db/common/models/transaction_metadata_model/mod.rs similarity index 100% rename from rust/processor/src/models/transaction_metadata_model/mod.rs rename to rust/processor/src/db/common/models/transaction_metadata_model/mod.rs diff --git a/rust/processor/src/models/transaction_metadata_model/transaction_size_info.rs b/rust/processor/src/db/common/models/transaction_metadata_model/transaction_size_info.rs similarity index 100% rename from rust/processor/src/models/transaction_metadata_model/transaction_size_info.rs rename to rust/processor/src/db/common/models/transaction_metadata_model/transaction_size_info.rs diff --git a/rust/processor/src/models/transaction_metadata_model/write_set_size_info.rs b/rust/processor/src/db/common/models/transaction_metadata_model/write_set_size_info.rs similarity index 100% rename from rust/processor/src/models/transaction_metadata_model/write_set_size_info.rs rename to rust/processor/src/db/common/models/transaction_metadata_model/write_set_size_info.rs diff --git a/rust/processor/src/models/user_transactions_models/mod.rs b/rust/processor/src/db/common/models/user_transactions_models/mod.rs similarity index 100% rename from rust/processor/src/models/user_transactions_models/mod.rs rename to rust/processor/src/db/common/models/user_transactions_models/mod.rs diff --git a/rust/processor/src/models/user_transactions_models/signatures.rs b/rust/processor/src/db/common/models/user_transactions_models/signatures.rs similarity index 100% rename from rust/processor/src/models/user_transactions_models/signatures.rs rename to rust/processor/src/db/common/models/user_transactions_models/signatures.rs diff --git a/rust/processor/src/models/user_transactions_models/user_transactions.rs b/rust/processor/src/db/common/models/user_transactions_models/user_transactions.rs similarity index 100% rename from rust/processor/src/models/user_transactions_models/user_transactions.rs rename to rust/processor/src/db/common/models/user_transactions_models/user_transactions.rs diff --git a/rust/processor/src/db/mod.rs b/rust/processor/src/db/mod.rs new file mode 100644 index 000000000..34994bf5a --- /dev/null +++ b/rust/processor/src/db/mod.rs @@ -0,0 +1 @@ +pub mod common; diff --git a/rust/processor/migrations/2024-04-18-173631_fungible_token/down.sql b/rust/processor/src/db/postgres/2024-04-18-173631_fungible_token/down.sql similarity index 100% rename from rust/processor/migrations/2024-04-18-173631_fungible_token/down.sql rename to rust/processor/src/db/postgres/2024-04-18-173631_fungible_token/down.sql diff --git a/rust/processor/migrations/2024-04-18-173631_fungible_token/up.sql b/rust/processor/src/db/postgres/2024-04-18-173631_fungible_token/up.sql similarity index 100% rename from rust/processor/migrations/2024-04-18-173631_fungible_token/up.sql rename to rust/processor/src/db/postgres/2024-04-18-173631_fungible_token/up.sql diff --git a/rust/processor/migrations/2024-04-29-215042_token_datas_burn/down.sql b/rust/processor/src/db/postgres/2024-04-29-215042_token_datas_burn/down.sql similarity index 100% rename from rust/processor/migrations/2024-04-29-215042_token_datas_burn/down.sql rename to rust/processor/src/db/postgres/2024-04-29-215042_token_datas_burn/down.sql diff --git a/rust/processor/migrations/2024-04-29-215042_token_datas_burn/up.sql b/rust/processor/src/db/postgres/2024-04-29-215042_token_datas_burn/up.sql similarity index 100% rename from rust/processor/migrations/2024-04-29-215042_token_datas_burn/up.sql rename to rust/processor/src/db/postgres/2024-04-29-215042_token_datas_burn/up.sql diff --git a/rust/processor/migrations/2024-05-04-025823_current_unified_fungible_asset_balance/down.sql b/rust/processor/src/db/postgres/2024-05-04-025823_current_unified_fungible_asset_balance/down.sql similarity index 100% rename from rust/processor/migrations/2024-05-04-025823_current_unified_fungible_asset_balance/down.sql rename to rust/processor/src/db/postgres/2024-05-04-025823_current_unified_fungible_asset_balance/down.sql diff --git a/rust/processor/migrations/2024-05-04-025823_current_unified_fungible_asset_balance/up.sql b/rust/processor/src/db/postgres/2024-05-04-025823_current_unified_fungible_asset_balance/up.sql similarity index 100% rename from rust/processor/migrations/2024-05-04-025823_current_unified_fungible_asset_balance/up.sql rename to rust/processor/src/db/postgres/2024-05-04-025823_current_unified_fungible_asset_balance/up.sql diff --git a/rust/processor/migrations/2024-05-17-215042_token_datas_burn_2/down.sql b/rust/processor/src/db/postgres/2024-05-17-215042_token_datas_burn_2/down.sql similarity index 100% rename from rust/processor/migrations/2024-05-17-215042_token_datas_burn_2/down.sql rename to rust/processor/src/db/postgres/2024-05-17-215042_token_datas_burn_2/down.sql diff --git a/rust/processor/migrations/2024-05-17-215042_token_datas_burn_2/up.sql b/rust/processor/src/db/postgres/2024-05-17-215042_token_datas_burn_2/up.sql similarity index 100% rename from rust/processor/migrations/2024-05-17-215042_token_datas_burn_2/up.sql rename to rust/processor/src/db/postgres/2024-05-17-215042_token_datas_burn_2/up.sql diff --git a/rust/processor/migrations/2024-05-21-221101_add_royalty_v1/down.sql b/rust/processor/src/db/postgres/2024-05-21-221101_add_royalty_v1/down.sql similarity index 100% rename from rust/processor/migrations/2024-05-21-221101_add_royalty_v1/down.sql rename to rust/processor/src/db/postgres/2024-05-21-221101_add_royalty_v1/down.sql diff --git a/rust/processor/migrations/2024-05-21-221101_add_royalty_v1/up.sql b/rust/processor/src/db/postgres/2024-05-21-221101_add_royalty_v1/up.sql similarity index 100% rename from rust/processor/migrations/2024-05-21-221101_add_royalty_v1/up.sql rename to rust/processor/src/db/postgres/2024-05-21-221101_add_royalty_v1/up.sql diff --git a/rust/processor/diesel.toml b/rust/processor/src/db/postgres/diesel.toml similarity index 100% rename from rust/processor/diesel.toml rename to rust/processor/src/db/postgres/diesel.toml diff --git a/rust/processor/migrations/.keep b/rust/processor/src/db/postgres/migrations/.keep similarity index 100% rename from rust/processor/migrations/.keep rename to rust/processor/src/db/postgres/migrations/.keep diff --git a/rust/processor/migrations/00000000000000_diesel_initial_setup/down.sql b/rust/processor/src/db/postgres/migrations/00000000000000_diesel_initial_setup/down.sql similarity index 100% rename from rust/processor/migrations/00000000000000_diesel_initial_setup/down.sql rename to rust/processor/src/db/postgres/migrations/00000000000000_diesel_initial_setup/down.sql diff --git a/rust/processor/migrations/00000000000000_diesel_initial_setup/up.sql b/rust/processor/src/db/postgres/migrations/00000000000000_diesel_initial_setup/up.sql similarity index 100% rename from rust/processor/migrations/00000000000000_diesel_initial_setup/up.sql rename to rust/processor/src/db/postgres/migrations/00000000000000_diesel_initial_setup/up.sql diff --git a/rust/processor/migrations/2022-08-08-043603_core_tables/down.sql b/rust/processor/src/db/postgres/migrations/2022-08-08-043603_core_tables/down.sql similarity index 100% rename from rust/processor/migrations/2022-08-08-043603_core_tables/down.sql rename to rust/processor/src/db/postgres/migrations/2022-08-08-043603_core_tables/down.sql diff --git a/rust/processor/migrations/2022-08-08-043603_core_tables/up.sql b/rust/processor/src/db/postgres/migrations/2022-08-08-043603_core_tables/up.sql similarity index 99% rename from rust/processor/migrations/2022-08-08-043603_core_tables/up.sql rename to rust/processor/src/db/postgres/migrations/2022-08-08-043603_core_tables/up.sql index 9bcdd9c79..7bc2c6caa 100644 --- a/rust/processor/migrations/2022-08-08-043603_core_tables/up.sql +++ b/rust/processor/src/db/postgres/migrations/2022-08-08-043603_core_tables/up.sql @@ -302,4 +302,4 @@ CREATE TABLE table_metadatas ( inserted_at TIMESTAMP NOT NULL DEFAULT NOW() ); CREATE INDEX tm_insat_index ON table_metadatas (inserted_at); -CREATE TABLE ledger_infos (chain_id BIGINT UNIQUE PRIMARY KEY NOT NULL); \ No newline at end of file +CREATE TABLE ledger_infos (chain_id BIGINT UNIQUE PRIMARY KEY NOT NULL); diff --git a/rust/processor/migrations/2022-09-04-194128_add_token_data/down.sql b/rust/processor/src/db/postgres/migrations/2022-09-04-194128_add_token_data/down.sql similarity index 100% rename from rust/processor/migrations/2022-09-04-194128_add_token_data/down.sql rename to rust/processor/src/db/postgres/migrations/2022-09-04-194128_add_token_data/down.sql diff --git a/rust/processor/migrations/2022-09-04-194128_add_token_data/up.sql b/rust/processor/src/db/postgres/migrations/2022-09-04-194128_add_token_data/up.sql similarity index 100% rename from rust/processor/migrations/2022-09-04-194128_add_token_data/up.sql rename to rust/processor/src/db/postgres/migrations/2022-09-04-194128_add_token_data/up.sql diff --git a/rust/processor/migrations/2022-09-20-055651_add_current_token_data/down.sql b/rust/processor/src/db/postgres/migrations/2022-09-20-055651_add_current_token_data/down.sql similarity index 100% rename from rust/processor/migrations/2022-09-20-055651_add_current_token_data/down.sql rename to rust/processor/src/db/postgres/migrations/2022-09-20-055651_add_current_token_data/down.sql diff --git a/rust/processor/migrations/2022-09-20-055651_add_current_token_data/up.sql b/rust/processor/src/db/postgres/migrations/2022-09-20-055651_add_current_token_data/up.sql similarity index 100% rename from rust/processor/migrations/2022-09-20-055651_add_current_token_data/up.sql rename to rust/processor/src/db/postgres/migrations/2022-09-20-055651_add_current_token_data/up.sql diff --git a/rust/processor/migrations/2022-09-22-185845_token_offers/down.sql b/rust/processor/src/db/postgres/migrations/2022-09-22-185845_token_offers/down.sql similarity index 100% rename from rust/processor/migrations/2022-09-22-185845_token_offers/down.sql rename to rust/processor/src/db/postgres/migrations/2022-09-22-185845_token_offers/down.sql diff --git a/rust/processor/migrations/2022-09-22-185845_token_offers/up.sql b/rust/processor/src/db/postgres/migrations/2022-09-22-185845_token_offers/up.sql similarity index 100% rename from rust/processor/migrations/2022-09-22-185845_token_offers/up.sql rename to rust/processor/src/db/postgres/migrations/2022-09-22-185845_token_offers/up.sql diff --git a/rust/processor/migrations/2022-10-02-011015_add_table_handle_to_collection/down.sql b/rust/processor/src/db/postgres/migrations/2022-10-02-011015_add_table_handle_to_collection/down.sql similarity index 100% rename from rust/processor/migrations/2022-10-02-011015_add_table_handle_to_collection/down.sql rename to rust/processor/src/db/postgres/migrations/2022-10-02-011015_add_table_handle_to_collection/down.sql diff --git a/rust/processor/migrations/2022-10-02-011015_add_table_handle_to_collection/up.sql b/rust/processor/src/db/postgres/migrations/2022-10-02-011015_add_table_handle_to_collection/up.sql similarity index 100% rename from rust/processor/migrations/2022-10-02-011015_add_table_handle_to_collection/up.sql rename to rust/processor/src/db/postgres/migrations/2022-10-02-011015_add_table_handle_to_collection/up.sql diff --git a/rust/processor/migrations/2022-10-02-011020_ans_lookup_table/down.sql b/rust/processor/src/db/postgres/migrations/2022-10-02-011020_ans_lookup_table/down.sql similarity index 100% rename from rust/processor/migrations/2022-10-02-011020_ans_lookup_table/down.sql rename to rust/processor/src/db/postgres/migrations/2022-10-02-011020_ans_lookup_table/down.sql diff --git a/rust/processor/migrations/2022-10-02-011020_ans_lookup_table/up.sql b/rust/processor/src/db/postgres/migrations/2022-10-02-011020_ans_lookup_table/up.sql similarity index 100% rename from rust/processor/migrations/2022-10-02-011020_ans_lookup_table/up.sql rename to rust/processor/src/db/postgres/migrations/2022-10-02-011020_ans_lookup_table/up.sql diff --git a/rust/processor/migrations/2022-10-04-073529_add_coin_tables/down.sql b/rust/processor/src/db/postgres/migrations/2022-10-04-073529_add_coin_tables/down.sql similarity index 100% rename from rust/processor/migrations/2022-10-04-073529_add_coin_tables/down.sql rename to rust/processor/src/db/postgres/migrations/2022-10-04-073529_add_coin_tables/down.sql diff --git a/rust/processor/migrations/2022-10-04-073529_add_coin_tables/up.sql b/rust/processor/src/db/postgres/migrations/2022-10-04-073529_add_coin_tables/up.sql similarity index 100% rename from rust/processor/migrations/2022-10-04-073529_add_coin_tables/up.sql rename to rust/processor/src/db/postgres/migrations/2022-10-04-073529_add_coin_tables/up.sql diff --git a/rust/processor/migrations/2022-10-06-193846_add_indexer_status/down.sql b/rust/processor/src/db/postgres/migrations/2022-10-06-193846_add_indexer_status/down.sql similarity index 100% rename from rust/processor/migrations/2022-10-06-193846_add_indexer_status/down.sql rename to rust/processor/src/db/postgres/migrations/2022-10-06-193846_add_indexer_status/down.sql diff --git a/rust/processor/migrations/2022-10-06-193846_add_indexer_status/up.sql b/rust/processor/src/db/postgres/migrations/2022-10-06-193846_add_indexer_status/up.sql similarity index 100% rename from rust/processor/migrations/2022-10-06-193846_add_indexer_status/up.sql rename to rust/processor/src/db/postgres/migrations/2022-10-06-193846_add_indexer_status/up.sql diff --git a/rust/processor/migrations/2022-10-07-231825_add_coin_supply/down.sql b/rust/processor/src/db/postgres/migrations/2022-10-07-231825_add_coin_supply/down.sql similarity index 100% rename from rust/processor/migrations/2022-10-07-231825_add_coin_supply/down.sql rename to rust/processor/src/db/postgres/migrations/2022-10-07-231825_add_coin_supply/down.sql diff --git a/rust/processor/migrations/2022-10-07-231825_add_coin_supply/up.sql b/rust/processor/src/db/postgres/migrations/2022-10-07-231825_add_coin_supply/up.sql similarity index 100% rename from rust/processor/migrations/2022-10-07-231825_add_coin_supply/up.sql rename to rust/processor/src/db/postgres/migrations/2022-10-07-231825_add_coin_supply/up.sql diff --git a/rust/processor/migrations/2022-10-15-185912_improve_processor_recovery/down.sql b/rust/processor/src/db/postgres/migrations/2022-10-15-185912_improve_processor_recovery/down.sql similarity index 100% rename from rust/processor/migrations/2022-10-15-185912_improve_processor_recovery/down.sql rename to rust/processor/src/db/postgres/migrations/2022-10-15-185912_improve_processor_recovery/down.sql diff --git a/rust/processor/migrations/2022-10-15-185912_improve_processor_recovery/up.sql b/rust/processor/src/db/postgres/migrations/2022-10-15-185912_improve_processor_recovery/up.sql similarity index 100% rename from rust/processor/migrations/2022-10-15-185912_improve_processor_recovery/up.sql rename to rust/processor/src/db/postgres/migrations/2022-10-15-185912_improve_processor_recovery/up.sql diff --git a/rust/processor/migrations/2022-10-21-055518_stake_to_voter/down.sql b/rust/processor/src/db/postgres/migrations/2022-10-21-055518_stake_to_voter/down.sql similarity index 100% rename from rust/processor/migrations/2022-10-21-055518_stake_to_voter/down.sql rename to rust/processor/src/db/postgres/migrations/2022-10-21-055518_stake_to_voter/down.sql diff --git a/rust/processor/migrations/2022-10-21-055518_stake_to_voter/up.sql b/rust/processor/src/db/postgres/migrations/2022-10-21-055518_stake_to_voter/up.sql similarity index 100% rename from rust/processor/migrations/2022-10-21-055518_stake_to_voter/up.sql rename to rust/processor/src/db/postgres/migrations/2022-10-21-055518_stake_to_voter/up.sql diff --git a/rust/processor/migrations/2022-10-30-053525_add_vote_data/down.sql b/rust/processor/src/db/postgres/migrations/2022-10-30-053525_add_vote_data/down.sql similarity index 100% rename from rust/processor/migrations/2022-10-30-053525_add_vote_data/down.sql rename to rust/processor/src/db/postgres/migrations/2022-10-30-053525_add_vote_data/down.sql diff --git a/rust/processor/migrations/2022-10-30-053525_add_vote_data/up.sql b/rust/processor/src/db/postgres/migrations/2022-10-30-053525_add_vote_data/up.sql similarity index 100% rename from rust/processor/migrations/2022-10-30-053525_add_vote_data/up.sql rename to rust/processor/src/db/postgres/migrations/2022-10-30-053525_add_vote_data/up.sql diff --git a/rust/processor/migrations/2022-12-29-222902_curr_table_items/down.sql b/rust/processor/src/db/postgres/migrations/2022-12-29-222902_curr_table_items/down.sql similarity index 100% rename from rust/processor/migrations/2022-12-29-222902_curr_table_items/down.sql rename to rust/processor/src/db/postgres/migrations/2022-12-29-222902_curr_table_items/down.sql diff --git a/rust/processor/migrations/2022-12-29-222902_curr_table_items/up.sql b/rust/processor/src/db/postgres/migrations/2022-12-29-222902_curr_table_items/up.sql similarity index 100% rename from rust/processor/migrations/2022-12-29-222902_curr_table_items/up.sql rename to rust/processor/src/db/postgres/migrations/2022-12-29-222902_curr_table_items/up.sql diff --git a/rust/processor/migrations/2023-02-15-070116_stake_delegation/down.sql b/rust/processor/src/db/postgres/migrations/2023-02-15-070116_stake_delegation/down.sql similarity index 100% rename from rust/processor/migrations/2023-02-15-070116_stake_delegation/down.sql rename to rust/processor/src/db/postgres/migrations/2023-02-15-070116_stake_delegation/down.sql diff --git a/rust/processor/migrations/2023-02-15-070116_stake_delegation/up.sql b/rust/processor/src/db/postgres/migrations/2023-02-15-070116_stake_delegation/up.sql similarity index 100% rename from rust/processor/migrations/2023-02-15-070116_stake_delegation/up.sql rename to rust/processor/src/db/postgres/migrations/2023-02-15-070116_stake_delegation/up.sql diff --git a/rust/processor/migrations/2023-03-08-205402_nft_points/down.sql b/rust/processor/src/db/postgres/migrations/2023-03-08-205402_nft_points/down.sql similarity index 100% rename from rust/processor/migrations/2023-03-08-205402_nft_points/down.sql rename to rust/processor/src/db/postgres/migrations/2023-03-08-205402_nft_points/down.sql diff --git a/rust/processor/migrations/2023-03-08-205402_nft_points/up.sql b/rust/processor/src/db/postgres/migrations/2023-03-08-205402_nft_points/up.sql similarity index 100% rename from rust/processor/migrations/2023-03-08-205402_nft_points/up.sql rename to rust/processor/src/db/postgres/migrations/2023-03-08-205402_nft_points/up.sql diff --git a/rust/processor/migrations/2023-04-02-032121_delegator_pools/down.sql b/rust/processor/src/db/postgres/migrations/2023-04-02-032121_delegator_pools/down.sql similarity index 100% rename from rust/processor/migrations/2023-04-02-032121_delegator_pools/down.sql rename to rust/processor/src/db/postgres/migrations/2023-04-02-032121_delegator_pools/down.sql diff --git a/rust/processor/migrations/2023-04-02-032121_delegator_pools/up.sql b/rust/processor/src/db/postgres/migrations/2023-04-02-032121_delegator_pools/up.sql similarity index 100% rename from rust/processor/migrations/2023-04-02-032121_delegator_pools/up.sql rename to rust/processor/src/db/postgres/migrations/2023-04-02-032121_delegator_pools/up.sql diff --git a/rust/processor/migrations/2023-04-14-033932_optimize_queries/down.sql b/rust/processor/src/db/postgres/migrations/2023-04-14-033932_optimize_queries/down.sql similarity index 100% rename from rust/processor/migrations/2023-04-14-033932_optimize_queries/down.sql rename to rust/processor/src/db/postgres/migrations/2023-04-14-033932_optimize_queries/down.sql diff --git a/rust/processor/migrations/2023-04-14-033932_optimize_queries/up.sql b/rust/processor/src/db/postgres/migrations/2023-04-14-033932_optimize_queries/up.sql similarity index 100% rename from rust/processor/migrations/2023-04-14-033932_optimize_queries/up.sql rename to rust/processor/src/db/postgres/migrations/2023-04-14-033932_optimize_queries/up.sql diff --git a/rust/processor/migrations/2023-04-27-233343_delegation_pool_balances/down.sql b/rust/processor/src/db/postgres/migrations/2023-04-27-233343_delegation_pool_balances/down.sql similarity index 100% rename from rust/processor/migrations/2023-04-27-233343_delegation_pool_balances/down.sql rename to rust/processor/src/db/postgres/migrations/2023-04-27-233343_delegation_pool_balances/down.sql diff --git a/rust/processor/migrations/2023-04-27-233343_delegation_pool_balances/up.sql b/rust/processor/src/db/postgres/migrations/2023-04-27-233343_delegation_pool_balances/up.sql similarity index 100% rename from rust/processor/migrations/2023-04-27-233343_delegation_pool_balances/up.sql rename to rust/processor/src/db/postgres/migrations/2023-04-27-233343_delegation_pool_balances/up.sql diff --git a/rust/processor/migrations/2023-04-28-053048_object_token_v2/down.sql b/rust/processor/src/db/postgres/migrations/2023-04-28-053048_object_token_v2/down.sql similarity index 100% rename from rust/processor/migrations/2023-04-28-053048_object_token_v2/down.sql rename to rust/processor/src/db/postgres/migrations/2023-04-28-053048_object_token_v2/down.sql diff --git a/rust/processor/migrations/2023-04-28-053048_object_token_v2/up.sql b/rust/processor/src/db/postgres/migrations/2023-04-28-053048_object_token_v2/up.sql similarity index 100% rename from rust/processor/migrations/2023-04-28-053048_object_token_v2/up.sql rename to rust/processor/src/db/postgres/migrations/2023-04-28-053048_object_token_v2/up.sql diff --git a/rust/processor/migrations/2023-05-17-010107_activities_v2/down.sql b/rust/processor/src/db/postgres/migrations/2023-05-17-010107_activities_v2/down.sql similarity index 100% rename from rust/processor/migrations/2023-05-17-010107_activities_v2/down.sql rename to rust/processor/src/db/postgres/migrations/2023-05-17-010107_activities_v2/down.sql diff --git a/rust/processor/migrations/2023-05-17-010107_activities_v2/up.sql b/rust/processor/src/db/postgres/migrations/2023-05-17-010107_activities_v2/up.sql similarity index 100% rename from rust/processor/migrations/2023-05-17-010107_activities_v2/up.sql rename to rust/processor/src/db/postgres/migrations/2023-05-17-010107_activities_v2/up.sql diff --git a/rust/processor/migrations/2023-05-22-234344_delegated_staking_improvements/down.sql b/rust/processor/src/db/postgres/migrations/2023-05-22-234344_delegated_staking_improvements/down.sql similarity index 100% rename from rust/processor/migrations/2023-05-22-234344_delegated_staking_improvements/down.sql rename to rust/processor/src/db/postgres/migrations/2023-05-22-234344_delegated_staking_improvements/down.sql diff --git a/rust/processor/migrations/2023-05-22-234344_delegated_staking_improvements/up.sql b/rust/processor/src/db/postgres/migrations/2023-05-22-234344_delegated_staking_improvements/up.sql similarity index 100% rename from rust/processor/migrations/2023-05-22-234344_delegated_staking_improvements/up.sql rename to rust/processor/src/db/postgres/migrations/2023-05-22-234344_delegated_staking_improvements/up.sql diff --git a/rust/processor/migrations/2023-05-24-052435_token_properties_v2/down.sql b/rust/processor/src/db/postgres/migrations/2023-05-24-052435_token_properties_v2/down.sql similarity index 100% rename from rust/processor/migrations/2023-05-24-052435_token_properties_v2/down.sql rename to rust/processor/src/db/postgres/migrations/2023-05-24-052435_token_properties_v2/down.sql diff --git a/rust/processor/migrations/2023-05-24-052435_token_properties_v2/up.sql b/rust/processor/src/db/postgres/migrations/2023-05-24-052435_token_properties_v2/up.sql similarity index 100% rename from rust/processor/migrations/2023-05-24-052435_token_properties_v2/up.sql rename to rust/processor/src/db/postgres/migrations/2023-05-24-052435_token_properties_v2/up.sql diff --git a/rust/processor/migrations/2023-07-06-042159_minor_optimizations/down.sql b/rust/processor/src/db/postgres/migrations/2023-07-06-042159_minor_optimizations/down.sql similarity index 100% rename from rust/processor/migrations/2023-07-06-042159_minor_optimizations/down.sql rename to rust/processor/src/db/postgres/migrations/2023-07-06-042159_minor_optimizations/down.sql diff --git a/rust/processor/migrations/2023-07-06-042159_minor_optimizations/up.sql b/rust/processor/src/db/postgres/migrations/2023-07-06-042159_minor_optimizations/up.sql similarity index 100% rename from rust/processor/migrations/2023-07-06-042159_minor_optimizations/up.sql rename to rust/processor/src/db/postgres/migrations/2023-07-06-042159_minor_optimizations/up.sql diff --git a/rust/processor/migrations/2023-07-13-060328_transactions_by_address/down.sql b/rust/processor/src/db/postgres/migrations/2023-07-13-060328_transactions_by_address/down.sql similarity index 100% rename from rust/processor/migrations/2023-07-13-060328_transactions_by_address/down.sql rename to rust/processor/src/db/postgres/migrations/2023-07-13-060328_transactions_by_address/down.sql diff --git a/rust/processor/migrations/2023-07-13-060328_transactions_by_address/up.sql b/rust/processor/src/db/postgres/migrations/2023-07-13-060328_transactions_by_address/up.sql similarity index 100% rename from rust/processor/migrations/2023-07-13-060328_transactions_by_address/up.sql rename to rust/processor/src/db/postgres/migrations/2023-07-13-060328_transactions_by_address/up.sql diff --git a/rust/processor/migrations/2023-07-28-053854_entry_function/down.sql b/rust/processor/src/db/postgres/migrations/2023-07-28-053854_entry_function/down.sql similarity index 100% rename from rust/processor/migrations/2023-07-28-053854_entry_function/down.sql rename to rust/processor/src/db/postgres/migrations/2023-07-28-053854_entry_function/down.sql diff --git a/rust/processor/migrations/2023-07-28-053854_entry_function/up.sql b/rust/processor/src/db/postgres/migrations/2023-07-28-053854_entry_function/up.sql similarity index 100% rename from rust/processor/migrations/2023-07-28-053854_entry_function/up.sql rename to rust/processor/src/db/postgres/migrations/2023-07-28-053854_entry_function/up.sql diff --git a/rust/processor/migrations/2023-08-01-042050_fungible_assets/down.sql b/rust/processor/src/db/postgres/migrations/2023-08-01-042050_fungible_assets/down.sql similarity index 100% rename from rust/processor/migrations/2023-08-01-042050_fungible_assets/down.sql rename to rust/processor/src/db/postgres/migrations/2023-08-01-042050_fungible_assets/down.sql diff --git a/rust/processor/migrations/2023-08-01-042050_fungible_assets/up.sql b/rust/processor/src/db/postgres/migrations/2023-08-01-042050_fungible_assets/up.sql similarity index 100% rename from rust/processor/migrations/2023-08-01-042050_fungible_assets/up.sql rename to rust/processor/src/db/postgres/migrations/2023-08-01-042050_fungible_assets/up.sql diff --git a/rust/processor/migrations/2023-08-12-190707_add_ans_is_primary/down.sql b/rust/processor/src/db/postgres/migrations/2023-08-12-190707_add_ans_is_primary/down.sql similarity index 100% rename from rust/processor/migrations/2023-08-12-190707_add_ans_is_primary/down.sql rename to rust/processor/src/db/postgres/migrations/2023-08-12-190707_add_ans_is_primary/down.sql diff --git a/rust/processor/migrations/2023-08-12-190707_add_ans_is_primary/up.sql b/rust/processor/src/db/postgres/migrations/2023-08-12-190707_add_ans_is_primary/up.sql similarity index 100% rename from rust/processor/migrations/2023-08-12-190707_add_ans_is_primary/up.sql rename to rust/processor/src/db/postgres/migrations/2023-08-12-190707_add_ans_is_primary/up.sql diff --git a/rust/processor/migrations/2023-08-14-235438_add_current_delegated_voter_table/down.sql b/rust/processor/src/db/postgres/migrations/2023-08-14-235438_add_current_delegated_voter_table/down.sql similarity index 100% rename from rust/processor/migrations/2023-08-14-235438_add_current_delegated_voter_table/down.sql rename to rust/processor/src/db/postgres/migrations/2023-08-14-235438_add_current_delegated_voter_table/down.sql diff --git a/rust/processor/migrations/2023-08-14-235438_add_current_delegated_voter_table/up.sql b/rust/processor/src/db/postgres/migrations/2023-08-14-235438_add_current_delegated_voter_table/up.sql similarity index 100% rename from rust/processor/migrations/2023-08-14-235438_add_current_delegated_voter_table/up.sql rename to rust/processor/src/db/postgres/migrations/2023-08-14-235438_add_current_delegated_voter_table/up.sql diff --git a/rust/processor/migrations/2023-08-22-232603_add_ans_view/down.sql b/rust/processor/src/db/postgres/migrations/2023-08-22-232603_add_ans_view/down.sql similarity index 100% rename from rust/processor/migrations/2023-08-22-232603_add_ans_view/down.sql rename to rust/processor/src/db/postgres/migrations/2023-08-22-232603_add_ans_view/down.sql diff --git a/rust/processor/migrations/2023-08-22-232603_add_ans_view/up.sql b/rust/processor/src/db/postgres/migrations/2023-08-22-232603_add_ans_view/up.sql similarity index 100% rename from rust/processor/migrations/2023-08-22-232603_add_ans_view/up.sql rename to rust/processor/src/db/postgres/migrations/2023-08-22-232603_add_ans_view/up.sql diff --git a/rust/processor/migrations/2023-08-23-192343_fix_ans_view/down.sql b/rust/processor/src/db/postgres/migrations/2023-08-23-192343_fix_ans_view/down.sql similarity index 100% rename from rust/processor/migrations/2023-08-23-192343_fix_ans_view/down.sql rename to rust/processor/src/db/postgres/migrations/2023-08-23-192343_fix_ans_view/down.sql diff --git a/rust/processor/migrations/2023-08-23-192343_fix_ans_view/up.sql b/rust/processor/src/db/postgres/migrations/2023-08-23-192343_fix_ans_view/up.sql similarity index 100% rename from rust/processor/migrations/2023-08-23-192343_fix_ans_view/up.sql rename to rust/processor/src/db/postgres/migrations/2023-08-23-192343_fix_ans_view/up.sql diff --git a/rust/processor/migrations/2023-09-01-231248_events_v2/down.sql b/rust/processor/src/db/postgres/migrations/2023-09-01-231248_events_v2/down.sql similarity index 100% rename from rust/processor/migrations/2023-09-01-231248_events_v2/down.sql rename to rust/processor/src/db/postgres/migrations/2023-09-01-231248_events_v2/down.sql diff --git a/rust/processor/migrations/2023-09-01-231248_events_v2/up.sql b/rust/processor/src/db/postgres/migrations/2023-09-01-231248_events_v2/up.sql similarity index 100% rename from rust/processor/migrations/2023-09-01-231248_events_v2/up.sql rename to rust/processor/src/db/postgres/migrations/2023-09-01-231248_events_v2/up.sql diff --git a/rust/processor/migrations/2023-09-07-175640_storage_refund/down.sql b/rust/processor/src/db/postgres/migrations/2023-09-07-175640_storage_refund/down.sql similarity index 100% rename from rust/processor/migrations/2023-09-07-175640_storage_refund/down.sql rename to rust/processor/src/db/postgres/migrations/2023-09-07-175640_storage_refund/down.sql diff --git a/rust/processor/migrations/2023-09-07-175640_storage_refund/up.sql b/rust/processor/src/db/postgres/migrations/2023-09-07-175640_storage_refund/up.sql similarity index 100% rename from rust/processor/migrations/2023-09-07-175640_storage_refund/up.sql rename to rust/processor/src/db/postgres/migrations/2023-09-07-175640_storage_refund/up.sql diff --git a/rust/processor/migrations/2023-09-11-164718_ut_remove_constraint/down.sql b/rust/processor/src/db/postgres/migrations/2023-09-11-164718_ut_remove_constraint/down.sql similarity index 100% rename from rust/processor/migrations/2023-09-11-164718_ut_remove_constraint/down.sql rename to rust/processor/src/db/postgres/migrations/2023-09-11-164718_ut_remove_constraint/down.sql diff --git a/rust/processor/migrations/2023-09-11-164718_ut_remove_constraint/up.sql b/rust/processor/src/db/postgres/migrations/2023-09-11-164718_ut_remove_constraint/up.sql similarity index 100% rename from rust/processor/migrations/2023-09-11-164718_ut_remove_constraint/up.sql rename to rust/processor/src/db/postgres/migrations/2023-09-11-164718_ut_remove_constraint/up.sql diff --git a/rust/processor/migrations/2023-09-22-161603_add_ans_v2/down.sql b/rust/processor/src/db/postgres/migrations/2023-09-22-161603_add_ans_v2/down.sql similarity index 100% rename from rust/processor/migrations/2023-09-22-161603_add_ans_v2/down.sql rename to rust/processor/src/db/postgres/migrations/2023-09-22-161603_add_ans_v2/down.sql diff --git a/rust/processor/migrations/2023-09-22-161603_add_ans_v2/up.sql b/rust/processor/src/db/postgres/migrations/2023-09-22-161603_add_ans_v2/up.sql similarity index 100% rename from rust/processor/migrations/2023-09-22-161603_add_ans_v2/up.sql rename to rust/processor/src/db/postgres/migrations/2023-09-22-161603_add_ans_v2/up.sql diff --git a/rust/processor/migrations/2023-09-28-210956_nft_metadata/down.sql b/rust/processor/src/db/postgres/migrations/2023-09-28-210956_nft_metadata/down.sql similarity index 100% rename from rust/processor/migrations/2023-09-28-210956_nft_metadata/down.sql rename to rust/processor/src/db/postgres/migrations/2023-09-28-210956_nft_metadata/down.sql diff --git a/rust/processor/migrations/2023-09-28-210956_nft_metadata/up.sql b/rust/processor/src/db/postgres/migrations/2023-09-28-210956_nft_metadata/up.sql similarity index 100% rename from rust/processor/migrations/2023-09-28-210956_nft_metadata/up.sql rename to rust/processor/src/db/postgres/migrations/2023-09-28-210956_nft_metadata/up.sql diff --git a/rust/processor/migrations/2023-10-16-002253_alter_the_pubkey_column_length/down.sql b/rust/processor/src/db/postgres/migrations/2023-10-16-002253_alter_the_pubkey_column_length/down.sql similarity index 100% rename from rust/processor/migrations/2023-10-16-002253_alter_the_pubkey_column_length/down.sql rename to rust/processor/src/db/postgres/migrations/2023-10-16-002253_alter_the_pubkey_column_length/down.sql diff --git a/rust/processor/migrations/2023-10-16-002253_alter_the_pubkey_column_length/up.sql b/rust/processor/src/db/postgres/migrations/2023-10-16-002253_alter_the_pubkey_column_length/up.sql similarity index 100% rename from rust/processor/migrations/2023-10-16-002253_alter_the_pubkey_column_length/up.sql rename to rust/processor/src/db/postgres/migrations/2023-10-16-002253_alter_the_pubkey_column_length/up.sql diff --git a/rust/processor/migrations/2023-10-27-030502_event_type/down.sql b/rust/processor/src/db/postgres/migrations/2023-10-27-030502_event_type/down.sql similarity index 100% rename from rust/processor/migrations/2023-10-27-030502_event_type/down.sql rename to rust/processor/src/db/postgres/migrations/2023-10-27-030502_event_type/down.sql diff --git a/rust/processor/migrations/2023-10-27-030502_event_type/up.sql b/rust/processor/src/db/postgres/migrations/2023-10-27-030502_event_type/up.sql similarity index 100% rename from rust/processor/migrations/2023-10-27-030502_event_type/up.sql rename to rust/processor/src/db/postgres/migrations/2023-10-27-030502_event_type/up.sql diff --git a/rust/processor/migrations/2023-11-09-234724_delegator_balances/down.sql b/rust/processor/src/db/postgres/migrations/2023-11-09-234724_delegator_balances/down.sql similarity index 100% rename from rust/processor/migrations/2023-11-09-234724_delegator_balances/down.sql rename to rust/processor/src/db/postgres/migrations/2023-11-09-234724_delegator_balances/down.sql diff --git a/rust/processor/migrations/2023-11-09-234724_delegator_balances/up.sql b/rust/processor/src/db/postgres/migrations/2023-11-09-234724_delegator_balances/up.sql similarity index 100% rename from rust/processor/migrations/2023-11-09-234724_delegator_balances/up.sql rename to rust/processor/src/db/postgres/migrations/2023-11-09-234724_delegator_balances/up.sql diff --git a/rust/processor/migrations/2023-12-15-221028_payload_type/down.sql b/rust/processor/src/db/postgres/migrations/2023-12-15-221028_payload_type/down.sql similarity index 100% rename from rust/processor/migrations/2023-12-15-221028_payload_type/down.sql rename to rust/processor/src/db/postgres/migrations/2023-12-15-221028_payload_type/down.sql diff --git a/rust/processor/migrations/2023-12-15-221028_payload_type/up.sql b/rust/processor/src/db/postgres/migrations/2023-12-15-221028_payload_type/up.sql similarity index 100% rename from rust/processor/migrations/2023-12-15-221028_payload_type/up.sql rename to rust/processor/src/db/postgres/migrations/2023-12-15-221028_payload_type/up.sql diff --git a/rust/processor/migrations/2023-12-16-233224_add_objects_model/down.sql b/rust/processor/src/db/postgres/migrations/2023-12-16-233224_add_objects_model/down.sql similarity index 100% rename from rust/processor/migrations/2023-12-16-233224_add_objects_model/down.sql rename to rust/processor/src/db/postgres/migrations/2023-12-16-233224_add_objects_model/down.sql diff --git a/rust/processor/migrations/2023-12-16-233224_add_objects_model/up.sql b/rust/processor/src/db/postgres/migrations/2023-12-16-233224_add_objects_model/up.sql similarity index 100% rename from rust/processor/migrations/2023-12-16-233224_add_objects_model/up.sql rename to rust/processor/src/db/postgres/migrations/2023-12-16-233224_add_objects_model/up.sql diff --git a/rust/processor/migrations/2024-01-11-224315_update_process_status/down.sql b/rust/processor/src/db/postgres/migrations/2024-01-11-224315_update_process_status/down.sql similarity index 100% rename from rust/processor/migrations/2024-01-11-224315_update_process_status/down.sql rename to rust/processor/src/db/postgres/migrations/2024-01-11-224315_update_process_status/down.sql diff --git a/rust/processor/migrations/2024-01-11-224315_update_process_status/up.sql b/rust/processor/src/db/postgres/migrations/2024-01-11-224315_update_process_status/up.sql similarity index 100% rename from rust/processor/migrations/2024-01-11-224315_update_process_status/up.sql rename to rust/processor/src/db/postgres/migrations/2024-01-11-224315_update_process_status/up.sql diff --git a/rust/processor/migrations/2024-02-16-234847_any_signature/down.sql b/rust/processor/src/db/postgres/migrations/2024-02-16-234847_any_signature/down.sql similarity index 100% rename from rust/processor/migrations/2024-02-16-234847_any_signature/down.sql rename to rust/processor/src/db/postgres/migrations/2024-02-16-234847_any_signature/down.sql diff --git a/rust/processor/migrations/2024-02-16-234847_any_signature/up.sql b/rust/processor/src/db/postgres/migrations/2024-02-16-234847_any_signature/up.sql similarity index 100% rename from rust/processor/migrations/2024-02-16-234847_any_signature/up.sql rename to rust/processor/src/db/postgres/migrations/2024-02-16-234847_any_signature/up.sql diff --git a/rust/processor/migrations/2024-02-29-210322_transaction_metadata/down.sql b/rust/processor/src/db/postgres/migrations/2024-02-29-210322_transaction_metadata/down.sql similarity index 100% rename from rust/processor/migrations/2024-02-29-210322_transaction_metadata/down.sql rename to rust/processor/src/db/postgres/migrations/2024-02-29-210322_transaction_metadata/down.sql diff --git a/rust/processor/migrations/2024-02-29-210322_transaction_metadata/up.sql b/rust/processor/src/db/postgres/migrations/2024-02-29-210322_transaction_metadata/up.sql similarity index 100% rename from rust/processor/migrations/2024-02-29-210322_transaction_metadata/up.sql rename to rust/processor/src/db/postgres/migrations/2024-02-29-210322_transaction_metadata/up.sql diff --git a/rust/processor/migrations/2024-03-07-224504_fungible_asset_metadata_is_token_v2/down.sql b/rust/processor/src/db/postgres/migrations/2024-03-07-224504_fungible_asset_metadata_is_token_v2/down.sql similarity index 100% rename from rust/processor/migrations/2024-03-07-224504_fungible_asset_metadata_is_token_v2/down.sql rename to rust/processor/src/db/postgres/migrations/2024-03-07-224504_fungible_asset_metadata_is_token_v2/down.sql diff --git a/rust/processor/migrations/2024-03-07-224504_fungible_asset_metadata_is_token_v2/up.sql b/rust/processor/src/db/postgres/migrations/2024-03-07-224504_fungible_asset_metadata_is_token_v2/up.sql similarity index 100% rename from rust/processor/migrations/2024-03-07-224504_fungible_asset_metadata_is_token_v2/up.sql rename to rust/processor/src/db/postgres/migrations/2024-03-07-224504_fungible_asset_metadata_is_token_v2/up.sql diff --git a/rust/processor/migrations/2024-04-09-204519_ans_expiration_policy/down.sql b/rust/processor/src/db/postgres/migrations/2024-04-09-204519_ans_expiration_policy/down.sql similarity index 100% rename from rust/processor/migrations/2024-04-09-204519_ans_expiration_policy/down.sql rename to rust/processor/src/db/postgres/migrations/2024-04-09-204519_ans_expiration_policy/down.sql diff --git a/rust/processor/migrations/2024-04-09-204519_ans_expiration_policy/up.sql b/rust/processor/src/db/postgres/migrations/2024-04-09-204519_ans_expiration_policy/up.sql similarity index 100% rename from rust/processor/migrations/2024-04-09-204519_ans_expiration_policy/up.sql rename to rust/processor/src/db/postgres/migrations/2024-04-09-204519_ans_expiration_policy/up.sql diff --git a/rust/processor/src/schema.rs b/rust/processor/src/db/postgres/schema.rs similarity index 100% rename from rust/processor/src/schema.rs rename to rust/processor/src/db/postgres/schema.rs diff --git a/rust/processor/src/lib.rs b/rust/processor/src/lib.rs index ecb81ff3b..ce744c590 100644 --- a/rust/processor/src/lib.rs +++ b/rust/processor/src/lib.rs @@ -7,17 +7,18 @@ // #[macro_use] // extern crate diesel_migrations; -// Need to use this for because src/schema.rs uses the macros and is autogenerated +// Need to use this for because schema.rs uses the macros and is autogenerated #[macro_use] extern crate diesel; pub use config::IndexerGrpcProcessorConfig; mod config; +mod db; pub mod gap_detector; pub mod grpc_stream; -pub mod models; pub mod processors; +#[path = "db/postgres/schema.rs"] pub mod schema; pub mod transaction_filter; pub mod utils; diff --git a/rust/processor/src/processors/account_transactions_processor.rs b/rust/processor/src/processors/account_transactions_processor.rs index 1b984b17c..66955c32c 100644 --- a/rust/processor/src/processors/account_transactions_processor.rs +++ b/rust/processor/src/processors/account_transactions_processor.rs @@ -3,9 +3,9 @@ use super::{ProcessingResult, ProcessorName, ProcessorTrait}; use crate::{ - models::account_transaction_models::account_transactions::AccountTransaction, + db::common::models::account_transaction_models::account_transactions::AccountTransaction, schema, - utils::database::{execute_in_chunks, get_config_table_chunk_size, PgDbPool}, + utils::database::{execute_in_chunks, get_config_table_chunk_size, ArcDbPool}, }; use ahash::AHashMap; use anyhow::bail; @@ -16,12 +16,12 @@ use std::fmt::Debug; use tracing::error; pub struct AccountTransactionsProcessor { - connection_pool: PgDbPool, + connection_pool: ArcDbPool, per_table_chunk_sizes: AHashMap, } impl AccountTransactionsProcessor { - pub fn new(connection_pool: PgDbPool, per_table_chunk_sizes: AHashMap) -> Self { + pub fn new(connection_pool: ArcDbPool, per_table_chunk_sizes: AHashMap) -> Self { Self { connection_pool, per_table_chunk_sizes, @@ -41,7 +41,7 @@ impl Debug for AccountTransactionsProcessor { } async fn insert_to_db( - conn: PgDbPool, + conn: ArcDbPool, name: &'static str, start_version: u64, end_version: u64, @@ -149,7 +149,7 @@ impl ProcessorTrait for AccountTransactionsProcessor { } } - fn connection_pool(&self) -> &PgDbPool { + fn connection_pool(&self) -> &ArcDbPool { &self.connection_pool } } diff --git a/rust/processor/src/processors/ans_processor.rs b/rust/processor/src/processors/ans_processor.rs index 1521325cf..835cac42b 100644 --- a/rust/processor/src/processors/ans_processor.rs +++ b/rust/processor/src/processors/ans_processor.rs @@ -3,7 +3,7 @@ use super::{ProcessingResult, ProcessorName, ProcessorTrait}; use crate::{ - models::ans_models::{ + db::common::models::ans_models::{ ans_lookup::{AnsLookup, AnsPrimaryName, CurrentAnsLookup, CurrentAnsPrimaryName}, ans_lookup_v2::{ AnsLookupV2, AnsPrimaryNameV2, CurrentAnsLookupV2, CurrentAnsPrimaryNameV2, @@ -13,7 +13,7 @@ use crate::{ schema, utils::{ counters::PROCESSOR_UNKNOWN_TYPE_COUNT, - database::{execute_in_chunks, get_config_table_chunk_size, PgDbPool}, + database::{execute_in_chunks, get_config_table_chunk_size, ArcDbPool}, util::standardize_address, }, }; @@ -41,14 +41,14 @@ pub struct AnsProcessorConfig { } pub struct AnsProcessor { - connection_pool: PgDbPool, + connection_pool: ArcDbPool, config: AnsProcessorConfig, per_table_chunk_sizes: AHashMap, } impl AnsProcessor { pub fn new( - connection_pool: PgDbPool, + connection_pool: ArcDbPool, config: AnsProcessorConfig, per_table_chunk_sizes: AHashMap, ) -> Self { @@ -78,7 +78,7 @@ impl Debug for AnsProcessor { } async fn insert_to_db( - conn: PgDbPool, + conn: ArcDbPool, name: &'static str, start_version: u64, end_version: u64, @@ -430,7 +430,7 @@ impl ProcessorTrait for AnsProcessor { } } - fn connection_pool(&self) -> &PgDbPool { + fn connection_pool(&self) -> &ArcDbPool { &self.connection_pool } } diff --git a/rust/processor/src/processors/coin_processor.rs b/rust/processor/src/processors/coin_processor.rs index 8504ac397..b16e4398b 100644 --- a/rust/processor/src/processors/coin_processor.rs +++ b/rust/processor/src/processors/coin_processor.rs @@ -3,7 +3,7 @@ use super::{ProcessingResult, ProcessorName, ProcessorTrait}; use crate::{ - models::{ + db::common::models::{ coin_models::{ coin_activities::CoinActivity, coin_balances::{CoinBalance, CurrentCoinBalance}, @@ -12,7 +12,7 @@ use crate::{ fungible_asset_models::v2_fungible_asset_activities::CurrentCoinBalancePK, }, schema, - utils::database::{execute_in_chunks, get_config_table_chunk_size, PgDbPool}, + utils::database::{execute_in_chunks, get_config_table_chunk_size, ArcDbPool}, }; use ahash::AHashMap; use anyhow::{bail, Context}; @@ -27,12 +27,12 @@ use std::fmt::Debug; use tracing::error; pub struct CoinProcessor { - connection_pool: PgDbPool, + connection_pool: ArcDbPool, per_table_chunk_sizes: AHashMap, } impl CoinProcessor { - pub fn new(connection_pool: PgDbPool, per_table_chunk_sizes: AHashMap) -> Self { + pub fn new(connection_pool: ArcDbPool, per_table_chunk_sizes: AHashMap) -> Self { Self { connection_pool, per_table_chunk_sizes, @@ -52,7 +52,7 @@ impl Debug for CoinProcessor { } async fn insert_to_db( - conn: PgDbPool, + conn: ArcDbPool, name: &'static str, start_version: u64, end_version: u64, @@ -297,7 +297,7 @@ impl ProcessorTrait for CoinProcessor { } } - fn connection_pool(&self) -> &PgDbPool { + fn connection_pool(&self) -> &ArcDbPool { &self.connection_pool } } diff --git a/rust/processor/src/processors/default_processor.rs b/rust/processor/src/processors/default_processor.rs index eb685e197..5d38f36bd 100644 --- a/rust/processor/src/processors/default_processor.rs +++ b/rust/processor/src/processors/default_processor.rs @@ -3,7 +3,7 @@ use super::{ProcessingResult, ProcessorName, ProcessorTrait}; use crate::{ - models::default_models::{ + db::common::models::default_models::{ block_metadata_transactions::{BlockMetadataTransaction, BlockMetadataTransactionModel}, move_modules::MoveModule, move_resources::MoveResource, @@ -12,7 +12,7 @@ use crate::{ write_set_changes::{WriteSetChangeDetail, WriteSetChangeModel}, }, schema, - utils::database::{execute_in_chunks, get_config_table_chunk_size, PgDbPool}, + utils::database::{execute_in_chunks, get_config_table_chunk_size, ArcDbPool}, }; use ahash::AHashMap; use anyhow::bail; @@ -28,12 +28,12 @@ use tokio::join; use tracing::error; pub struct DefaultProcessor { - connection_pool: PgDbPool, + connection_pool: ArcDbPool, per_table_chunk_sizes: AHashMap, } impl DefaultProcessor { - pub fn new(connection_pool: PgDbPool, per_table_chunk_sizes: AHashMap) -> Self { + pub fn new(connection_pool: ArcDbPool, per_table_chunk_sizes: AHashMap) -> Self { Self { connection_pool, per_table_chunk_sizes, @@ -53,7 +53,7 @@ impl Debug for DefaultProcessor { } async fn insert_to_db( - conn: PgDbPool, + conn: ArcDbPool, name: &'static str, start_version: u64, end_version: u64, @@ -366,7 +366,7 @@ impl ProcessorTrait for DefaultProcessor { } } - fn connection_pool(&self) -> &PgDbPool { + fn connection_pool(&self) -> &ArcDbPool { &self.connection_pool } } @@ -374,7 +374,7 @@ impl ProcessorTrait for DefaultProcessor { fn process_transactions( transactions: Vec, ) -> ( - Vec, + Vec, Vec, Vec, ( diff --git a/rust/processor/src/processors/events_processor.rs b/rust/processor/src/processors/events_processor.rs index c382f82ec..b5ff0831c 100644 --- a/rust/processor/src/processors/events_processor.rs +++ b/rust/processor/src/processors/events_processor.rs @@ -3,11 +3,11 @@ use super::{ProcessingResult, ProcessorName, ProcessorTrait}; use crate::{ - models::events_models::events::EventModel, + db::common::models::events_models::events::EventModel, schema, utils::{ counters::PROCESSOR_UNKNOWN_TYPE_COUNT, - database::{execute_in_chunks, get_config_table_chunk_size, PgDbPool}, + database::{execute_in_chunks, get_config_table_chunk_size, ArcDbPool}, }, }; use ahash::AHashMap; @@ -23,12 +23,12 @@ use std::fmt::Debug; use tracing::error; pub struct EventsProcessor { - connection_pool: PgDbPool, + connection_pool: ArcDbPool, per_table_chunk_sizes: AHashMap, } impl EventsProcessor { - pub fn new(connection_pool: PgDbPool, per_table_chunk_sizes: AHashMap) -> Self { + pub fn new(connection_pool: ArcDbPool, per_table_chunk_sizes: AHashMap) -> Self { Self { connection_pool, per_table_chunk_sizes, @@ -48,7 +48,7 @@ impl Debug for EventsProcessor { } async fn insert_to_db( - conn: PgDbPool, + conn: ArcDbPool, name: &'static str, start_version: u64, end_version: u64, @@ -171,7 +171,7 @@ impl ProcessorTrait for EventsProcessor { } } - fn connection_pool(&self) -> &PgDbPool { + fn connection_pool(&self) -> &ArcDbPool { &self.connection_pool } } diff --git a/rust/processor/src/processors/fungible_asset_processor.rs b/rust/processor/src/processors/fungible_asset_processor.rs index 970ab39ae..7f0d1821c 100644 --- a/rust/processor/src/processors/fungible_asset_processor.rs +++ b/rust/processor/src/processors/fungible_asset_processor.rs @@ -3,7 +3,7 @@ use super::{ProcessingResult, ProcessorName, ProcessorTrait}; use crate::{ - models::{ + db::common::models::{ coin_models::coin_supply::CoinSupply, fungible_asset_models::{ v2_fungible_asset_activities::{EventToCoinType, FungibleAssetActivity}, @@ -24,7 +24,7 @@ use crate::{ schema, utils::{ counters::PROCESSOR_UNKNOWN_TYPE_COUNT, - database::{execute_in_chunks, get_config_table_chunk_size, PgDbPool}, + database::{execute_in_chunks, get_config_table_chunk_size, ArcDbPool}, util::{get_entry_function_from_user_request, standardize_address}, }, }; @@ -42,12 +42,12 @@ use std::fmt::Debug; use tracing::error; pub struct FungibleAssetProcessor { - connection_pool: PgDbPool, + connection_pool: ArcDbPool, per_table_chunk_sizes: AHashMap, } impl FungibleAssetProcessor { - pub fn new(connection_pool: PgDbPool, per_table_chunk_sizes: AHashMap) -> Self { + pub fn new(connection_pool: ArcDbPool, per_table_chunk_sizes: AHashMap) -> Self { Self { connection_pool, per_table_chunk_sizes, @@ -67,7 +67,7 @@ impl Debug for FungibleAssetProcessor { } async fn insert_to_db( - conn: PgDbPool, + conn: ArcDbPool, name: &'static str, start_version: u64, end_version: u64, @@ -401,7 +401,7 @@ impl ProcessorTrait for FungibleAssetProcessor { } } - fn connection_pool(&self) -> &PgDbPool { + fn connection_pool(&self) -> &ArcDbPool { &self.connection_pool } } diff --git a/rust/processor/src/processors/mod.rs b/rust/processor/src/processors/mod.rs index f85d9de7f..07257d6dc 100644 --- a/rust/processor/src/processors/mod.rs +++ b/rust/processor/src/processors/mod.rs @@ -4,9 +4,6 @@ // Note: For enum_dispatch to work nicely, it is easiest to have the trait and the enum // in the same file (ProcessorTrait and Processor). -// Note: For enum_dispatch to work nicely, it is easiest to have the trait and the enum -// in the same file (ProcessorTrait and Processor). - pub mod account_transactions_processor; pub mod ans_processor; pub mod coin_processor; @@ -39,11 +36,11 @@ use self::{ user_transaction_processor::UserTransactionProcessor, }; use crate::{ - models::processor_status::ProcessorStatus, + db::common::models::processor_status::ProcessorStatus, schema::processor_status, utils::{ counters::{GOT_CONNECTION_COUNT, UNABLE_TO_GET_CONNECTION_COUNT}, - database::{execute_with_better_error, PgDbPool, PgPoolConnection}, + database::{execute_with_better_error, ArcDbPool, DbPoolConnection}, util::parse_timestamp, }, }; @@ -80,19 +77,19 @@ pub trait ProcessorTrait: Send + Sync + Debug { /// Gets a reference to the connection pool /// This is used by the `get_conn()` helper below - fn connection_pool(&self) -> &PgDbPool; + fn connection_pool(&self) -> &ArcDbPool; //* Below are helper methods that don't need to be implemented *// /// Gets an instance of the connection pool - fn get_pool(&self) -> PgDbPool { + fn get_pool(&self) -> ArcDbPool { let pool = self.connection_pool(); pool.clone() } /// Gets the connection. /// If it was unable to do so (default timeout: 30s), it will keep retrying until it can. - async fn get_conn(&self) -> PgPoolConnection { + async fn get_conn(&self) -> DbPoolConnection { let pool = self.connection_pool(); loop { match pool.get().await { diff --git a/rust/processor/src/processors/monitoring_processor.rs b/rust/processor/src/processors/monitoring_processor.rs index b82453886..4fda0e9e8 100644 --- a/rust/processor/src/processors/monitoring_processor.rs +++ b/rust/processor/src/processors/monitoring_processor.rs @@ -2,17 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 use super::{ProcessingResult, ProcessorName, ProcessorTrait}; -use crate::utils::database::PgDbPool; +use crate::utils::database::ArcDbPool; use aptos_protos::transaction::v1::Transaction; use async_trait::async_trait; use std::fmt::Debug; pub struct MonitoringProcessor { - connection_pool: PgDbPool, + connection_pool: ArcDbPool, } impl MonitoringProcessor { - pub fn new(connection_pool: PgDbPool) -> Self { + pub fn new(connection_pool: ArcDbPool) -> Self { Self { connection_pool } } } @@ -50,7 +50,7 @@ impl ProcessorTrait for MonitoringProcessor { }) } - fn connection_pool(&self) -> &PgDbPool { + fn connection_pool(&self) -> &ArcDbPool { &self.connection_pool } } diff --git a/rust/processor/src/processors/nft_metadata_processor.rs b/rust/processor/src/processors/nft_metadata_processor.rs index 814d4ab4d..57896ee47 100644 --- a/rust/processor/src/processors/nft_metadata_processor.rs +++ b/rust/processor/src/processors/nft_metadata_processor.rs @@ -3,7 +3,7 @@ use super::{ProcessingResult, ProcessorName, ProcessorTrait}; use crate::{ - models::{ + db::common::models::{ object_models::v2_object_utils::{ ObjectAggregatedData, ObjectAggregatedDataMapping, ObjectWithMetadata, }, @@ -14,7 +14,7 @@ use crate::{ }, }, utils::{ - database::{PgDbPool, PgPoolConnection}, + database::{ArcDbPool, DbPoolConnection}, util::{parse_timestamp, remove_null_bytes, standardize_address}, }, IndexerGrpcProcessorConfig, @@ -46,13 +46,13 @@ pub struct NftMetadataProcessorConfig { } pub struct NftMetadataProcessor { - connection_pool: PgDbPool, + connection_pool: ArcDbPool, chain_id: u8, config: NftMetadataProcessorConfig, } impl NftMetadataProcessor { - pub fn new(connection_pool: PgDbPool, config: NftMetadataProcessorConfig) -> Self { + pub fn new(connection_pool: ArcDbPool, config: NftMetadataProcessorConfig) -> Self { tracing::info!("init NftMetadataProcessor"); // Crate reads from authentication from file specified in @@ -186,7 +186,7 @@ impl ProcessorTrait for NftMetadataProcessor { }) } - fn connection_pool(&self) -> &PgDbPool { + fn connection_pool(&self) -> &ArcDbPool { &self.connection_pool } } @@ -217,7 +217,7 @@ fn clean_collection_pubsub_message(cc: CurrentCollectionV2, db_chain_id: u64) -> async fn parse_v2_token( transactions: &[Transaction], table_handle_to_owner: &TableHandleToOwner, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, query_retries: u32, query_retry_delay_ms: u64, ) -> (Vec, Vec) { diff --git a/rust/processor/src/processors/objects_processor.rs b/rust/processor/src/processors/objects_processor.rs index f59b5ba86..37b4dd8c1 100644 --- a/rust/processor/src/processors/objects_processor.rs +++ b/rust/processor/src/processors/objects_processor.rs @@ -3,13 +3,13 @@ use super::{ProcessingResult, ProcessorName, ProcessorTrait}; use crate::{ - models::object_models::{ + db::common::models::object_models::{ v2_object_utils::{ObjectAggregatedData, ObjectAggregatedDataMapping, ObjectWithMetadata}, v2_objects::{CurrentObject, Object}, }, schema, utils::{ - database::{execute_in_chunks, get_config_table_chunk_size, PgDbPool}, + database::{execute_in_chunks, get_config_table_chunk_size, ArcDbPool}, util::standardize_address, }, IndexerGrpcProcessorConfig, @@ -36,14 +36,14 @@ pub struct ObjectsProcessorConfig { pub query_retry_delay_ms: u64, } pub struct ObjectsProcessor { - connection_pool: PgDbPool, + connection_pool: ArcDbPool, config: ObjectsProcessorConfig, per_table_chunk_sizes: AHashMap, } impl ObjectsProcessor { pub fn new( - connection_pool: PgDbPool, + connection_pool: ArcDbPool, config: ObjectsProcessorConfig, per_table_chunk_sizes: AHashMap, ) -> Self { @@ -67,7 +67,7 @@ impl Debug for ObjectsProcessor { } async fn insert_to_db( - conn: PgDbPool, + conn: ArcDbPool, name: &'static str, start_version: u64, end_version: u64, @@ -297,7 +297,7 @@ impl ProcessorTrait for ObjectsProcessor { } } - fn connection_pool(&self) -> &PgDbPool { + fn connection_pool(&self) -> &ArcDbPool { &self.connection_pool } } diff --git a/rust/processor/src/processors/stake_processor.rs b/rust/processor/src/processors/stake_processor.rs index 07d9d185d..e1268c4af 100644 --- a/rust/processor/src/processors/stake_processor.rs +++ b/rust/processor/src/processors/stake_processor.rs @@ -3,7 +3,7 @@ use super::{ProcessingResult, ProcessorName, ProcessorTrait}; use crate::{ - models::stake_models::{ + db::common::models::stake_models::{ current_delegated_voter::CurrentDelegatedVoter, delegator_activities::DelegatedStakingActivity, delegator_balances::{ @@ -18,7 +18,7 @@ use crate::{ }, schema, utils::{ - database::{execute_in_chunks, get_config_table_chunk_size, PgDbPool}, + database::{execute_in_chunks, get_config_table_chunk_size, ArcDbPool}, util::{parse_timestamp, standardize_address}, }, IndexerGrpcProcessorConfig, @@ -46,14 +46,14 @@ pub struct StakeProcessorConfig { } pub struct StakeProcessor { - connection_pool: PgDbPool, + connection_pool: ArcDbPool, config: StakeProcessorConfig, per_table_chunk_sizes: AHashMap, } impl StakeProcessor { pub fn new( - connection_pool: PgDbPool, + connection_pool: ArcDbPool, config: StakeProcessorConfig, per_table_chunk_sizes: AHashMap, ) -> Self { @@ -77,7 +77,7 @@ impl Debug for StakeProcessor { } async fn insert_to_db( - conn: PgDbPool, + conn: ArcDbPool, name: &'static str, start_version: u64, end_version: u64, @@ -598,7 +598,7 @@ impl ProcessorTrait for StakeProcessor { } } - fn connection_pool(&self) -> &PgDbPool { + fn connection_pool(&self) -> &ArcDbPool { &self.connection_pool } } diff --git a/rust/processor/src/processors/token_processor.rs b/rust/processor/src/processors/token_processor.rs index 27f08e7b2..f19fb1797 100644 --- a/rust/processor/src/processors/token_processor.rs +++ b/rust/processor/src/processors/token_processor.rs @@ -3,7 +3,7 @@ use super::{ProcessingResult, ProcessorName, ProcessorTrait}; use crate::{ - models::token_models::{ + db::common::models::token_models::{ collection_datas::{CollectionData, CurrentCollectionData}, nft_points::NftPoints, token_activities::TokenActivity, @@ -16,7 +16,7 @@ use crate::{ }, }, schema, - utils::database::{execute_in_chunks, get_config_table_chunk_size, PgDbPool}, + utils::database::{execute_in_chunks, get_config_table_chunk_size, ArcDbPool}, IndexerGrpcProcessorConfig, }; use ahash::AHashMap; @@ -43,14 +43,14 @@ pub struct TokenProcessorConfig { } pub struct TokenProcessor { - connection_pool: PgDbPool, + connection_pool: ArcDbPool, config: TokenProcessorConfig, per_table_chunk_sizes: AHashMap, } impl TokenProcessor { pub fn new( - connection_pool: PgDbPool, + connection_pool: ArcDbPool, config: TokenProcessorConfig, per_table_chunk_sizes: AHashMap, ) -> Self { @@ -74,7 +74,7 @@ impl Debug for TokenProcessor { } async fn insert_to_db( - conn: PgDbPool, + conn: ArcDbPool, name: &'static str, start_version: u64, end_version: u64, @@ -601,7 +601,7 @@ impl ProcessorTrait for TokenProcessor { } } - fn connection_pool(&self) -> &PgDbPool { + fn connection_pool(&self) -> &ArcDbPool { &self.connection_pool } } diff --git a/rust/processor/src/processors/token_v2_processor.rs b/rust/processor/src/processors/token_v2_processor.rs index 8b337341a..a262141c3 100644 --- a/rust/processor/src/processors/token_v2_processor.rs +++ b/rust/processor/src/processors/token_v2_processor.rs @@ -3,7 +3,7 @@ use super::{ProcessingResult, ProcessorName, ProcessorTrait}; use crate::{ - models::{ + db::common::models::{ fungible_asset_models::v2_fungible_asset_utils::FungibleAssetMetadata, object_models::v2_object_utils::{ ObjectAggregatedData, ObjectAggregatedDataMapping, ObjectWithMetadata, @@ -29,7 +29,7 @@ use crate::{ schema, utils::{ counters::PROCESSOR_UNKNOWN_TYPE_COUNT, - database::{execute_in_chunks, get_config_table_chunk_size, PgDbPool, PgPoolConnection}, + database::{execute_in_chunks, get_config_table_chunk_size, ArcDbPool, DbPoolConnection}, util::{get_entry_function_from_user_request, parse_timestamp, standardize_address}, }, IndexerGrpcProcessorConfig, @@ -57,14 +57,14 @@ pub struct TokenV2ProcessorConfig { } pub struct TokenV2Processor { - connection_pool: PgDbPool, + connection_pool: ArcDbPool, config: TokenV2ProcessorConfig, per_table_chunk_sizes: AHashMap, } impl TokenV2Processor { pub fn new( - connection_pool: PgDbPool, + connection_pool: ArcDbPool, config: TokenV2ProcessorConfig, per_table_chunk_sizes: AHashMap, ) -> Self { @@ -88,7 +88,7 @@ impl Debug for TokenV2Processor { } async fn insert_to_db( - conn: PgDbPool, + conn: ArcDbPool, name: &'static str, start_version: u64, end_version: u64, @@ -611,7 +611,7 @@ impl ProcessorTrait for TokenV2Processor { } } - fn connection_pool(&self) -> &PgDbPool { + fn connection_pool(&self) -> &ArcDbPool { &self.connection_pool } } @@ -619,7 +619,7 @@ impl ProcessorTrait for TokenV2Processor { async fn parse_v2_token( transactions: &[Transaction], table_handle_to_owner: &TableHandleToOwner, - conn: &mut PgPoolConnection<'_>, + conn: &mut DbPoolConnection<'_>, query_retries: u32, query_retry_delay_ms: u64, ) -> ( diff --git a/rust/processor/src/processors/transaction_metadata_processor.rs b/rust/processor/src/processors/transaction_metadata_processor.rs index a3393b301..cab5cff2e 100644 --- a/rust/processor/src/processors/transaction_metadata_processor.rs +++ b/rust/processor/src/processors/transaction_metadata_processor.rs @@ -3,12 +3,12 @@ use super::{ProcessingResult, ProcessorName, ProcessorTrait}; use crate::{ - models::transaction_metadata_model::{ + db::common::models::transaction_metadata_model::{ event_size_info::EventSize, transaction_size_info::TransactionSize, write_set_size_info::WriteSetSize, }, schema, - utils::database::{execute_in_chunks, get_config_table_chunk_size, PgDbPool}, + utils::database::{execute_in_chunks, get_config_table_chunk_size, ArcDbPool}, }; use ahash::AHashMap; use anyhow::bail; @@ -19,12 +19,12 @@ use std::fmt::Debug; use tracing::{error, warn}; pub struct TransactionMetadataProcessor { - connection_pool: PgDbPool, + connection_pool: ArcDbPool, per_table_chunk_sizes: AHashMap, } impl TransactionMetadataProcessor { - pub fn new(connection_pool: PgDbPool, per_table_chunk_sizes: AHashMap) -> Self { + pub fn new(connection_pool: ArcDbPool, per_table_chunk_sizes: AHashMap) -> Self { Self { connection_pool, per_table_chunk_sizes, @@ -44,7 +44,7 @@ impl Debug for TransactionMetadataProcessor { } async fn insert_to_db( - conn: PgDbPool, + conn: ArcDbPool, name: &'static str, start_version: u64, end_version: u64, @@ -218,7 +218,7 @@ impl ProcessorTrait for TransactionMetadataProcessor { } } - fn connection_pool(&self) -> &PgDbPool { + fn connection_pool(&self) -> &ArcDbPool { &self.connection_pool } } diff --git a/rust/processor/src/processors/user_transaction_processor.rs b/rust/processor/src/processors/user_transaction_processor.rs index 5571eedb9..ba6bba95a 100644 --- a/rust/processor/src/processors/user_transaction_processor.rs +++ b/rust/processor/src/processors/user_transaction_processor.rs @@ -3,13 +3,13 @@ use super::{ProcessingResult, ProcessorName, ProcessorTrait}; use crate::{ - models::user_transactions_models::{ + db::common::models::user_transactions_models::{ signatures::Signature, user_transactions::UserTransactionModel, }, schema, utils::{ counters::PROCESSOR_UNKNOWN_TYPE_COUNT, - database::{execute_in_chunks, get_config_table_chunk_size, PgDbPool}, + database::{execute_in_chunks, get_config_table_chunk_size, ArcDbPool}, }, }; use ahash::AHashMap; @@ -25,12 +25,12 @@ use std::fmt::Debug; use tracing::error; pub struct UserTransactionProcessor { - connection_pool: PgDbPool, + connection_pool: ArcDbPool, per_table_chunk_sizes: AHashMap, } impl UserTransactionProcessor { - pub fn new(connection_pool: PgDbPool, per_table_chunk_sizes: AHashMap) -> Self { + pub fn new(connection_pool: ArcDbPool, per_table_chunk_sizes: AHashMap) -> Self { Self { connection_pool, per_table_chunk_sizes, @@ -50,7 +50,7 @@ impl Debug for UserTransactionProcessor { } async fn insert_to_db( - conn: PgDbPool, + conn: ArcDbPool, name: &'static str, start_version: u64, end_version: u64, @@ -211,7 +211,7 @@ impl ProcessorTrait for UserTransactionProcessor { } } - fn connection_pool(&self) -> &PgDbPool { + fn connection_pool(&self) -> &ArcDbPool { &self.connection_pool } } diff --git a/rust/processor/src/utils/database.rs b/rust/processor/src/utils/database.rs index cc06fe08d..411ce46c9 100644 --- a/rust/processor/src/utils/database.rs +++ b/rust/processor/src/utils/database.rs @@ -7,28 +7,28 @@ use crate::utils::util::remove_null_bytes; use ahash::AHashMap; use diesel::{ - backend::Backend, query_builder::{AstPass, Query, QueryFragment}, ConnectionResult, QueryResult, }; use diesel_async::{ - pg::AsyncPgConnection, pooled_connection::{ bb8::{Pool, PooledConnection}, AsyncDieselConnectionManager, ManagerConfig, PoolError, }, - RunQueryDsl, + AsyncPgConnection, RunQueryDsl, }; use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness}; use futures_util::{future::BoxFuture, FutureExt}; use std::sync::Arc; +pub type Backend = diesel::pg::Pg; + pub type MyDbConnection = AsyncPgConnection; -pub type PgPool = Pool; -pub type PgDbPool = Arc; -pub type PgPoolConnection<'a> = PooledConnection<'a, MyDbConnection>; +pub type DbPool = Pool; +pub type ArcDbPool = Arc; +pub type DbPoolConnection<'a> = PooledConnection<'a, MyDbConnection>; -pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!(); +pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("src/db/postgres/migrations"); pub const DEFAULT_MAX_POOL_SIZE: u32 = 150; @@ -106,13 +106,13 @@ fn parse_and_clean_db_url(url: &str) -> (String, Option) { pub async fn new_db_pool( database_url: &str, max_pool_size: Option, -) -> Result { +) -> Result { let (_url, cert_path) = parse_and_clean_db_url(database_url); let config = if cert_path.is_some() { - let mut config = ManagerConfig::::default(); + let mut config = ManagerConfig::::default(); config.custom_setup = Box::new(|conn| Box::pin(establish_connection(conn))); - AsyncDieselConnectionManager::::new_with_config(database_url, config) + AsyncDieselConnectionManager::::new_with_config(database_url, config) } else { AsyncDieselConnectionManager::::new(database_url) }; @@ -124,13 +124,13 @@ pub async fn new_db_pool( } pub async fn execute_in_chunks( - conn: PgDbPool, + conn: ArcDbPool, build_query: fn(Vec) -> (U, Option<&'static str>), items_to_insert: &[T], chunk_size: usize, ) -> Result<(), diesel::result::Error> where - U: QueryFragment + diesel::query_builder::QueryId + Send + 'static, + U: QueryFragment + diesel::query_builder::QueryId + Send + 'static, T: serde::Serialize + for<'de> serde::Deserialize<'de> + Clone + Send + 'static, { let tasks = items_to_insert @@ -157,14 +157,14 @@ where } pub async fn execute_with_better_error( - pool: PgDbPool, + pool: ArcDbPool, query: U, mut additional_where_clause: Option<&'static str>, ) -> QueryResult where - U: QueryFragment + diesel::query_builder::QueryId + Send, + U: QueryFragment + diesel::query_builder::QueryId + Send, { - let original_query = diesel::debug_query::(&query).to_string(); + let original_query = diesel::debug_query::(&query).to_string(); // This is needed because if we don't insert any row, then diesel makes a call like this // SELECT 1 FROM TABLE WHERE 1=0 if original_query.to_lowercase().contains("where") { @@ -174,7 +174,7 @@ where query, where_clause: additional_where_clause, }; - let debug_string = diesel::debug_query::(&final_query).to_string(); + let debug_string = diesel::debug_query::(&final_query).to_string(); tracing::debug!("Executing query: {:?}", debug_string); let conn = &mut pool.get().await.map_err(|e| { tracing::warn!("Error getting connection from pool: {:?}", e); @@ -209,9 +209,9 @@ pub async fn execute_with_better_error_conn( mut additional_where_clause: Option<&'static str>, ) -> QueryResult where - U: QueryFragment + diesel::query_builder::QueryId + Send, + U: QueryFragment + diesel::query_builder::QueryId + Send, { - let original_query = diesel::debug_query::(&query).to_string(); + let original_query = diesel::debug_query::(&query).to_string(); // This is needed because if we don't insert any row, then diesel makes a call like this // SELECT 1 FROM TABLE WHERE 1=0 if original_query.to_lowercase().contains("where") { @@ -221,7 +221,7 @@ where query, where_clause: additional_where_clause, }; - let debug_string = diesel::debug_query::(&final_query).to_string(); + let debug_string = diesel::debug_query::(&final_query).to_string(); tracing::debug!("Executing query: {:?}", debug_string); let res = final_query.execute(conn).await; if let Err(ref e) = res { @@ -231,14 +231,14 @@ where } async fn execute_or_retry_cleaned( - conn: PgDbPool, + conn: ArcDbPool, build_query: fn(Vec) -> (U, Option<&'static str>), items: Vec, query: U, additional_where_clause: Option<&'static str>, ) -> Result<(), diesel::result::Error> where - U: QueryFragment + diesel::query_builder::QueryId + Send, + U: QueryFragment + diesel::query_builder::QueryId + Send, T: serde::Serialize + for<'de> serde::Deserialize<'de> + Clone, { match execute_with_better_error(conn.clone(), query, additional_where_clause).await { @@ -259,7 +259,7 @@ where Ok(()) } -pub fn run_pending_migrations(conn: &mut impl MigrationHarness) { +pub fn run_pending_migrations(conn: &mut impl MigrationHarness) { conn.run_pending_migrations(MIGRATIONS) .expect("[Parser] Migrations failed!"); } @@ -271,11 +271,11 @@ impl Query for UpsertFilterLatestTransactionQuery { //impl RunQueryDsl for UpsertFilterLatestTransactionQuery {} -impl QueryFragment for UpsertFilterLatestTransactionQuery +impl QueryFragment for UpsertFilterLatestTransactionQuery where - T: QueryFragment, + T: QueryFragment, { - fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, diesel::pg::Pg>) -> QueryResult<()> { + fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Backend>) -> QueryResult<()> { self.query.walk_ast(out.reborrow())?; if let Some(w) = self.where_clause { out.push_sql(w); diff --git a/rust/processor/src/utils/util.rs b/rust/processor/src/utils/util.rs index e8537f8df..2751050ad 100644 --- a/rust/processor/src/utils/util.rs +++ b/rust/processor/src/utils/util.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use crate::{ - models::property_map::{PropertyMap, TokenObjectPropertyMap}, + db::common::models::property_map::{PropertyMap, TokenObjectPropertyMap}, utils::counters::PROCESSOR_UNKNOWN_TYPE_COUNT, }; use aptos_protos::{ diff --git a/rust/processor/src/worker.rs b/rust/processor/src/worker.rs index 06ec9b213..4289a9879 100644 --- a/rust/processor/src/worker.rs +++ b/rust/processor/src/worker.rs @@ -3,8 +3,8 @@ use crate::{ config::IndexerGrpcHttp2Config, + db::common::models::{ledger_info::LedgerInfo, processor_status::ProcessorStatusQuery}, grpc_stream::TransactionsPBResponse, - models::{ledger_info::LedgerInfo, processor_status::ProcessorStatusQuery}, processors::{ account_transactions_processor::AccountTransactionsProcessor, ans_processor::AnsProcessor, coin_processor::CoinProcessor, default_processor::DefaultProcessor, @@ -28,7 +28,9 @@ use crate::{ SINGLE_BATCH_DB_INSERTION_TIME_IN_SECS, SINGLE_BATCH_PARSING_TIME_IN_SECS, SINGLE_BATCH_PROCESSING_TIME_IN_SECS, TRANSACTION_UNIX_TIMESTAMP, }, - database::{execute_with_better_error_conn, new_db_pool, run_pending_migrations, PgDbPool}, + database::{ + execute_with_better_error_conn, new_db_pool, run_pending_migrations, ArcDbPool, + }, util::{time_diff_since_pb_timestamp_in_secs, timestamp_to_iso, timestamp_to_unixtime}, }, }; @@ -46,7 +48,7 @@ pub const BUFFER_SIZE: usize = 100; pub const PROCESSOR_SERVICE_TYPE: &str = "processor"; pub struct Worker { - pub db_pool: PgDbPool, + pub db_pool: ArcDbPool, pub processor_config: ProcessorConfig, pub postgres_connection_string: String, pub indexer_grpc_data_service_address: Url, @@ -718,7 +720,7 @@ pub async fn do_processor( pub fn build_processor( config: &ProcessorConfig, per_table_chunk_sizes: AHashMap, - db_pool: PgDbPool, + db_pool: ArcDbPool, ) -> Processor { match config { ProcessorConfig::AccountTransactionsProcessor => Processor::from(