From 6568a1f3dd40e533725edb271aec96a3d6e4eaea Mon Sep 17 00:00:00 2001 From: Enzo Cioppettini Date: Tue, 5 Mar 2024 00:41:39 -0300 Subject: [PATCH] update tx_count change to cml multiera after rebase --- indexer/tasks/src/multiera/multiera_block.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/indexer/tasks/src/multiera/multiera_block.rs b/indexer/tasks/src/multiera/multiera_block.rs index b5c390ff..d919f85e 100644 --- a/indexer/tasks/src/multiera/multiera_block.rs +++ b/indexer/tasks/src/multiera/multiera_block.rs @@ -49,8 +49,25 @@ async fn handle_block( epoch: Set(block.2.epoch.unwrap() as i32), slot: Set(block.1.header().slot() as i32), payload: Set(Some(block_payload)), - tx_count: Set(block.1.txs().len() as i32), + tx_count: Set(block_tx_count(block.1) as i32), ..Default::default() }; block.insert(db_tx).await } + +fn block_tx_count(block: &cml_multi_era::MultiEraBlock) -> usize { + match block { + cml_multi_era::MultiEraBlock::Byron( + cml_multi_era::byron::block::ByronBlock::EpochBoundary(_), + ) => 0, + cml_multi_era::MultiEraBlock::Byron(cml_multi_era::byron::block::ByronBlock::Main( + block, + )) => block.body.tx_payload.len(), + cml_multi_era::MultiEraBlock::Shelley(block) => block.transaction_bodies.len(), + cml_multi_era::MultiEraBlock::Allegra(block) => block.transaction_bodies.len(), + cml_multi_era::MultiEraBlock::Mary(block) => block.transaction_bodies.len(), + cml_multi_era::MultiEraBlock::Alonzo(block) => block.transaction_bodies.len(), + cml_multi_era::MultiEraBlock::Babbage(block) => block.transaction_bodies.len(), + cml_multi_era::MultiEraBlock::Conway(block) => block.transaction_bodies.len(), + } +}