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

Feature/skip specific contract transactions #4

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions rust/processor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ Indexer GRPC parser is to indexer data processor that leverages the indexer grpc
- "0x07"
# Skip all transactions that aren't user transactions
focus_user_transactions: false
# Skip transactions that start with these strings
skip_contract_prefix_names:
- "test"
deprecated_tables: [
"MOVE_RESOURCES",
"WRITE_SET_CHANGES",
Expand Down
21 changes: 21 additions & 0 deletions rust/processor/src/transaction_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,23 @@ pub struct TransactionFilter {
skip_sender_addresses: Option<ahash::HashSet<String>>,
// Skip all transactions that aren't user transactions
focus_user_transactions: bool,
// Skip transactions that start with these strings
skip_contract_prefix_names: Option<Vec<String>>,
}

impl TransactionFilter {
pub fn new(
focus_contract_addresses: Option<ahash::HashSet<String>>,
skip_sender_addresses: Option<ahash::HashSet<String>>,
focus_user_transactions: bool,
skip_contract_prefix_names: Option<Vec<String>>,
) -> Self {
// TODO: normalize addresses
Self {
focus_contract_addresses,
skip_sender_addresses,
focus_user_transactions,
skip_contract_prefix_names,
}
}

Expand Down Expand Up @@ -72,6 +76,23 @@ impl TransactionFilter {
}
}
}

if let Some(skip_contract_prefix_names) = &self.skip_contract_prefix_names {
// Skip if contract prefix is in the skip_contract_prefix_names
if let Some(payload) = utr.payload.as_ref() {
if let Some(Payload::EntryFunctionPayload(efp)) = payload.payload.as_ref() {
if let Some(function) = efp.function.as_ref() {
if let Some(module) = function.module.as_ref() {
for prefix in skip_contract_prefix_names {
if module.name.starts_with(prefix) {
return false;
}
}
}
}
}
}
}
}
}

Expand Down