Skip to content

Commit

Permalink
fix filter of map_transaction_traces (#32)
Browse files Browse the repository at this point in the history
* fix filter

* Add receiver filter
  • Loading branch information
heifner authored Dec 13, 2023
1 parent b756dce commit 687aa1f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions common/src/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ fn map_transaction_traces(params: String, block: Block) -> Result<TransactionTra
let filter_receiver = utils::create_filters(params.as_str(), "receiver");

for trx in block.all_transaction_traces() {
if !filter_contract.is_empty() || !filter_action.is_empty() {
if !filter_contract.is_empty() || !filter_action.is_empty() || !filter_receiver.is_empty() {
let mut has_contract = false;
let mut has_action = false;
let mut has_receiver = false;
for trace in &trx.action_traces {
let action = trace.action.as_ref().unwrap();

// filter by params
if !filter_contract.is_empty() && !filter_contract.contains(&action.account) { has_contract = true; }
if !filter_action.is_empty() && !filter_action.contains(&action.name) { has_action = true; }
if !filter_receiver.is_empty() && !filter_receiver.contains(&trace.receiver) { has_receiver = true; }
if !filter_contract.is_empty() && filter_contract.contains(&action.account) { has_contract = true; }
if !filter_action.is_empty() && filter_action.contains(&action.name) { has_action = true; }
if !filter_receiver.is_empty() && filter_receiver.contains(&trace.receiver) { has_receiver = true; }
if has_contract || has_action || has_receiver { break; }
}
// don't include transaction
if !has_contract && !has_action && !has_receiver { continue; }
Expand Down

0 comments on commit 687aa1f

Please sign in to comment.