fix: prune empty transaction protocol component groups from map_pools_created

This commit is contained in:
0xMochan
2024-02-01 13:52:02 -05:00
parent e7b458cc01
commit 0a031d8bf5

View File

@@ -41,14 +41,8 @@ pub fn map_pools_created(
Ok(tycho::GroupedTransactionProtocolComponents { Ok(tycho::GroupedTransactionProtocolComponents {
tx_components: block tx_components: block
.transactions() .transactions()
.map(|tx| tycho::TransactionProtocolComponents { .filter_map(|tx| {
tx: Some(tycho::Transaction { let components = tx
hash: tx.hash.clone(),
from: tx.from.clone(),
to: tx.to.clone(),
index: Into::<u64>::into(tx.index),
}),
components: tx
.logs_with_calls() .logs_with_calls()
.filter(|(_, call)| !call.call.state_reverted) .filter(|(_, call)| !call.call.state_reverted)
.filter_map(|(log, call)| { .filter_map(|(log, call)| {
@@ -58,7 +52,21 @@ pub fn map_pools_created(
call.call, call.call,
)?) )?)
}) })
.collect::<Vec<_>>(), .collect::<Vec<_>>();
if !components.is_empty() {
Some(tycho::TransactionProtocolComponents {
tx: Some(tycho::Transaction {
hash: tx.hash.clone(),
from: tx.from.clone(),
to: tx.to.clone(),
index: Into::<u64>::into(tx.index),
}),
components,
})
} else {
None
}
}) })
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
}) })