Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Processor] Simplify some logic to reduce unnecessary duplicated work. #501

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ bigdecimal = { version = "0.4.0", features = ["serde"] }
bitflags = "2.5.0"
chrono = { version = "0.4.19", features = ["clock", "serde"] }
clap = { version = "4.3.5", features = ["derive", "unstable-styles"] }
const_format = "0.2.33"
# Do NOT enable the postgres feature here, it is conditionally enabled in a feature
# block in the Cargo.toml file for the processor crate.
# https://github.com/aptos-labs/aptos-indexer-processors/pull/325
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use diesel::{Identifiable, Insertable, Queryable};
use field_count::FieldCount;
use processor::{
db::common::models::{
object_models::v2_object_utils::ObjectWithMetadata,
object_models::v2_object_utils::ObjectWithMetadata, resources::FromWriteResource,
user_transactions_models::user_transactions::UserTransaction,
},
schema::account_transactions,
Expand Down Expand Up @@ -98,9 +98,7 @@ impl AccountTransaction {
// owner as well.
// This handles partial deletes as well.
accounts.insert(standardize_address(res.address.as_str()));
if let Some(inner) =
&ObjectWithMetadata::from_write_resource(res, txn_version).unwrap()
{
if let Some(inner) = &ObjectWithMetadata::from_write_resource(res).unwrap() {
accounts.insert(inner.object_core.get_owner_address());
}
},
Expand Down
1 change: 1 addition & 0 deletions rust/processor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ bitflags = { workspace = true }
canonical_json = { workspace = true }
chrono = { workspace = true }
clap = { workspace = true }
const_format = { workspace = true }
diesel = { workspace = true }
diesel-async = { workspace = true }
diesel_migrations = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use crate::{
db::common::models::{
object_models::v2_object_utils::ObjectWithMetadata,
object_models::v2_object_utils::ObjectWithMetadata, resources::FromWriteResource,
user_transactions_models::user_transactions::UserTransaction,
},
schema::account_transactions,
Expand Down Expand Up @@ -98,9 +98,7 @@ impl AccountTransaction {
// owner as well.
// This handles partial deletes as well.
accounts.insert(standardize_address(res.address.as_str()));
if let Some(inner) =
&ObjectWithMetadata::from_write_resource(res, txn_version).unwrap()
{
if let Some(inner) = &ObjectWithMetadata::from_write_resource(res).unwrap() {
accounts.insert(inner.object_core.get_owner_address());
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#![allow(clippy::extra_unused_lifetimes)]

use crate::{
db::common::models::default_models::move_resources::MoveResource,
db::common::models::{default_models::move_resources::MoveResource, resources::COIN_ADDR},
utils::util::{deserialize_from_string, hash_str, standardize_address, truncate_str},
};
use anyhow::{bail, Context, Result};
Expand All @@ -16,7 +16,6 @@ use regex::Regex;
use serde::{Deserialize, Serialize};
use tracing::error;

pub const COIN_ADDR: &str = "0x0000000000000000000000000000000000000000000000000000000000000001";
const COIN_TYPE_HASH_LENGTH: usize = 5000;
const COIN_TYPE_MAX: usize = 1000;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::{
v2_fungible_asset_utils::FungibleAssetStore,
},
object_models::v2_object_utils::ObjectAggregatedDataMapping,
resources::FromWriteResource,
token_v2_models::v2_token_utils::TokenStandard,
},
utils::util::standardize_address,
Expand Down Expand Up @@ -76,8 +77,7 @@ impl FungibleAssetBalance {
txn_timestamp: chrono::NaiveDateTime,
object_metadatas: &ObjectAggregatedDataMapping,
) -> anyhow::Result<Option<(Self, CurrentFungibleAssetBalance)>> {
if let Some(inner) = &FungibleAssetStore::from_write_resource(write_resource, txn_version)?
{
if let Some(inner) = &FungibleAssetStore::from_write_resource(write_resource)? {
let storage_id = standardize_address(write_resource.address.as_str());
// Need to get the object of the store
if let Some(object_data) = object_metadatas.get(&storage_id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
db::common::models::{
coin_models::coin_utils::{CoinInfoType, CoinResource},
object_models::v2_object_utils::ObjectAggregatedDataMapping,
resources::FromWriteResource,
token_v2_models::v2_token_utils::{TokenStandard, V2_STANDARD},
},
schema::{
Expand Down Expand Up @@ -248,8 +249,7 @@ impl FungibleAssetBalance {
txn_timestamp: chrono::NaiveDateTime,
object_metadatas: &ObjectAggregatedDataMapping,
) -> anyhow::Result<Option<(Self, CurrentFungibleAssetBalance)>> {
if let Some(inner) = &FungibleAssetStore::from_write_resource(write_resource, txn_version)?
{
if let Some(inner) = &FungibleAssetStore::from_write_resource(write_resource)? {
let storage_id = standardize_address(write_resource.address.as_str());
// Need to get the object of the store
if let Some(object_data) = object_metadatas.get(&storage_id) {
Expand Down
Loading
Loading