Skip to content

Commit

Permalink
simplified collect in the end
Browse files Browse the repository at this point in the history
  • Loading branch information
lassemand committed Jun 21, 2024
1 parent 5e8fa09 commit e54b551
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions notification-server/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use concordium_rust_sdk::base::contracts_common::AccountAddress;
use concordium_rust_sdk::types::Address::Account;
use futures::{Stream, StreamExt};

fn get_cis2_events_addresses(effects: &AccountTransactionEffects) -> Option<Vec<AccountAddress>> {
fn get_cis2_events_addresses(effects: &AccountTransactionEffects) -> Vec<AccountAddress> {
match &effects {
AccountTransactionEffects::ContractUpdateIssued { effects } => Some(
AccountTransactionEffects::ContractUpdateIssued { effects } =>
effects
.iter()
.flat_map(|effect| match effect {
Expand All @@ -33,8 +33,7 @@ fn get_cis2_events_addresses(effects: &AccountTransactionEffects) -> Option<Vec<
_ => vec![],
})
.collect(),
),
_ => None,
_ => vec![]
}
}

Expand All @@ -53,26 +52,18 @@ pub async fn process(
) -> Vec<AccountAddress> {
transactions
.filter_map(|result| async move { result.ok() })
.filter_map(|t| async move {
match t.details {
.map(|t| futures::stream::iter(match t.details {
AccountTransaction(ref account_transaction) => {
if is_notification_emitting_transaction_effect(&account_transaction.effects) {
Some(
t.affected_addresses()
.into_iter()
.map(|addr| addr)
.collect::<Vec<_>>(),
)
t.affected_addresses()
} else {
get_cis2_events_addresses(&account_transaction.effects)
}
}
_ => None,
_ => vec![],
}
})
.collect::<Vec<Vec<AccountAddress>>>()
.await
.into_iter()
))
.flatten()
.collect()
.collect::<Vec<AccountAddress>>()
.await
}

0 comments on commit e54b551

Please sign in to comment.