Skip to content

Commit

Permalink
suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex6323 committed Apr 22, 2024
1 parent adc96f4 commit b6601e1
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions src/analytics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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::<eyre::Result<Vec<_>>>()?;
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::<eyre::Result<Vec<_>>>()?;
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::<eyre::Result<Vec<_>>>()?;
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::<eyre::Result<Vec<_>>>()?;
analytics
.handle_transaction(payload, metadata, &consumed, &created, ctx)
.await?;
Ok(())
}

Expand Down

0 comments on commit b6601e1

Please sign in to comment.