From b6601e178c64e37519761066a955a0bc451e8ec6 Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Mon, 22 Apr 2024 15:34:21 +0200 Subject: [PATCH] suggestions --- src/analytics/mod.rs | 80 ++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/analytics/mod.rs b/src/analytics/mod.rs index a58dff0eb..9cef798ce 100644 --- a/src/analytics/mod.rs +++ b/src/analytics/mod.rs @@ -327,9 +327,11 @@ impl<'a, I: InputSource> Slot<'a, I> { .and_then(|p| p.as_signed_transaction_opt()) .zip(data.transaction) { - self.handle_transaction(analytics, payload, &metadata, &ctx).await?; + if metadata.transaction_state == Some(TransactionState::Finalized) { + self.handle_transaction(analytics, payload, &metadata, &ctx).await?; + } + self.handle_block(analytics, &data.block, &ctx).await?; } - self.handle_block(analytics, &data.block, &ctx).await?; } influxdb @@ -346,44 +348,42 @@ impl<'a, I: InputSource> Slot<'a, I> { metadata: &TransactionMetadata, ctx: &BasicContext<'_>, ) -> eyre::Result<()> { - if let Some(TransactionState::Finalized) = metadata.transaction_state { - let consumed = payload - .transaction() - .inputs() - .iter() - .map(|input| input.as_utxo().output_id()) - .map(|output_id| { - Ok(self - .ledger_updates() - .get_consumed(output_id) - .ok_or(AnalyticsError::MissingLedgerSpent { - output_id: *output_id, - slot_index: metadata.transaction_id.slot_index(), - })? - .clone()) - }) - .collect::>>()?; - let created = payload - .transaction() - .outputs() - .iter() - .enumerate() - .map(|(index, _)| { - let output_id = metadata.transaction_id.into_output_id(index as _); - Ok(self - .ledger_updates() - .get_created(&output_id) - .ok_or(AnalyticsError::MissingLedgerOutput { - output_id, - slot_index: metadata.transaction_id.slot_index(), - })? - .clone()) - }) - .collect::>>()?; - analytics - .handle_transaction(payload, metadata, &consumed, &created, ctx) - .await?; - } + let consumed = payload + .transaction() + .inputs() + .iter() + .map(|input| input.as_utxo().output_id()) + .map(|output_id| { + Ok(self + .ledger_updates() + .get_consumed(output_id) + .ok_or(AnalyticsError::MissingLedgerSpent { + output_id: *output_id, + slot_index: metadata.transaction_id.slot_index(), + })? + .clone()) + }) + .collect::>>()?; + let created = payload + .transaction() + .outputs() + .iter() + .enumerate() + .map(|(index, _)| { + let output_id = metadata.transaction_id.into_output_id(index as _); + Ok(self + .ledger_updates() + .get_created(&output_id) + .ok_or(AnalyticsError::MissingLedgerOutput { + output_id, + slot_index: metadata.transaction_id.slot_index(), + })? + .clone()) + }) + .collect::>>()?; + analytics + .handle_transaction(payload, metadata, &consumed, &created, ctx) + .await?; Ok(()) }