Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
yuunlimm committed Sep 17, 2024
1 parent 46b644d commit 71e9486
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 56 deletions.
14 changes: 3 additions & 11 deletions rust/processor/src/db/common/models/default_models/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,10 @@
#![allow(clippy::unused_unit)]

use super::{
block_metadata_transactions::BlockMetadataTransaction,
write_set_changes::{WriteSetChangeDetail, WriteSetChangeModel},
};
use crate::{
schema::transactions,
utils::{
counters::PROCESSOR_UNKNOWN_TYPE_COUNT,
},
};
use aptos_protos::transaction::v1::{
transaction::TxnData, Transaction as TransactionPB,
block_metadata_transactions::BlockMetadataTransaction, write_set_changes::WriteSetChangeDetail,
};
use crate::{schema::transactions, utils::counters::PROCESSOR_UNKNOWN_TYPE_COUNT};
use aptos_protos::transaction::v1::{transaction::TxnData, Transaction as TransactionPB};
use bigdecimal::BigDecimal;
use field_count::FieldCount;
use serde::{Deserialize, Serialize};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ use super::{
move_tables::{CurrentTableItem, TableItem, TableMetadata},
transactions::Transaction,
};
use crate::{
schema::write_set_changes,
};
use crate::schema::write_set_changes;
use aptos_protos::transaction::v1::{
write_set_change::{Change as WriteSetChangeEnum},
WriteSetChange as WriteSetChangePB,
write_set_change::Change as WriteSetChangeEnum, WriteSetChange as WriteSetChangePB,
};
use field_count::FieldCount;
use serde::{Deserialize, Serialize};
use tracing::error;

#[derive(
Associations, Clone, Debug, Deserialize, FieldCount, Identifiable, Insertable, Serialize,
Expand Down Expand Up @@ -55,39 +51,38 @@ impl WriteSetChangeDetail {
.expect("WriteSetChange must have a change");

match change {
WriteSetChangeEnum::WriteModule(inner) =>
WriteSetChangeEnum::WriteModule(inner) => {
WriteSetChangeDetail::Module(MoveModule::from_write_module(
inner,
index,
transaction_version,
transaction_block_height,
)
),
WriteSetChangeEnum::DeleteModule(inner) =>

))
},
WriteSetChangeEnum::DeleteModule(inner) => {
WriteSetChangeDetail::Module(MoveModule::from_delete_module(
inner,
index,
transaction_version,
transaction_block_height,
)
),
WriteSetChangeEnum::WriteResource(inner) =>
))
},
WriteSetChangeEnum::WriteResource(inner) => {
WriteSetChangeDetail::Resource(MoveResource::from_write_resource(
inner,
index,
transaction_version,
transaction_block_height,
)
),
WriteSetChangeEnum::DeleteResource(inner) =>
))
},
WriteSetChangeEnum::DeleteResource(inner) => {
WriteSetChangeDetail::Resource(MoveResource::from_delete_resource(
inner,
index,
transaction_version,
transaction_block_height,
)
),
))
},
WriteSetChangeEnum::WriteTableItem(inner) => {
let (ti, cti) = TableItem::from_write_table_item(
inner,
Expand Down Expand Up @@ -132,27 +127,6 @@ impl WriteSetChangeDetail {
})
.collect::<Vec<WriteSetChangeDetail>>()
}

fn get_write_set_change_type(t: &WriteSetChangePB, index: i64, txn_version: i64) -> String {
match WriteSetChangeTypeEnum::try_from(t.r#type)
.expect("WriteSetChange must have a valid type.")
{
WriteSetChangeTypeEnum::DeleteModule => "delete_module".to_string(),
WriteSetChangeTypeEnum::DeleteResource => "delete_resource".to_string(),
WriteSetChangeTypeEnum::DeleteTableItem => "delete_table_item".to_string(),
WriteSetChangeTypeEnum::WriteModule => "write_module".to_string(),
WriteSetChangeTypeEnum::WriteResource => "write_resource".to_string(),
WriteSetChangeTypeEnum::WriteTableItem => "write_table_item".to_string(),
WriteSetChangeTypeEnum::Unspecified => {
error!(
wsc_index = index,
txn_version = txn_version,
"Encountered Unspecified WriteSetChange type. "
);
panic!("WriteSetChange type must be specified.")
},
}
}
}

// Prevent conflicts with other things named `WriteSetChange`
Expand Down
6 changes: 1 addition & 5 deletions rust/processor/src/processors/default_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,7 @@ fn process_transactions(
flags: TableFlags,
) -> (
Vec<BlockMetadataTransaction>,
(
Vec<TableItem>,
Vec<CurrentTableItem>,
Vec<TableMetadata>,
),
(Vec<TableItem>, Vec<CurrentTableItem>, Vec<TableMetadata>),
) {
let (block_metadata_txns, wsc_details) = TransactionModel::from_transactions(&transactions);
let mut block_metadata_transactions = vec![];
Expand Down

0 comments on commit 71e9486

Please sign in to comment.