Skip to content

Commit

Permalink
Port changes from #178
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienGllmt committed Mar 19, 2024
1 parent a5237f9 commit 7e3982d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions indexer/entity/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ pub struct Model {
pub epoch: i32,
pub slot: i32,
pub payload: Option<Vec<u8>>,
/**
* tx_count is useful to skip empty blocks during pagination
* We cache tx_count here even though you can derive this number by doing a join of Block<>Transaction
* Since caching it is a relatively small amount of data for better performance
*/
pub tx_count: i32,
}

Expand Down
5 changes: 3 additions & 2 deletions indexer/tasks/src/byron/byron_txs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{dsl::task_macro::*, era_common::transactions_from_hashes, utils::blake2b256};
use cml_core::serialization::ToBytes;
use cml_crypto::RawBytesEncoding;
use cml_multi_era::byron::block::ByronBlock;
use cml_multi_era::MultiEraBlock;
use entity::sea_orm::Set;
Expand Down Expand Up @@ -48,7 +49,7 @@ async fn handle_tx(
.body
.tx_payload
.iter()
.map(|tx| <[u8; 32]>::from(tx.byron_tx.hash()).to_vec())
.map(|tx| tx.byron_tx.hash().to_raw_bytes().to_vec())
.collect::<Vec<Vec<u8>>>(),
_ => vec![],
};
Expand All @@ -70,7 +71,7 @@ async fn handle_tx(
};

TransactionActiveModel {
hash: Set(<[u8; 32]>::from(tx.byron_tx.hash()).to_vec()),
hash: Set(tx.byron_tx.hash().to_raw_bytes().to_vec()),
block_id: Set(database_block.id),
tx_index: Set(idx as i32),
payload: Set(tx_payload),
Expand Down
3 changes: 1 addition & 2 deletions indexer/tasks/src/multiera/multiera_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use cml_chain::auxdata::metadata::Metadata;
use cml_chain::auxdata::AuxiliaryData;
use cml_chain::auxdata::{AuxiliaryData, Metadata};
use cml_core::serialization::Serialize;
use std::collections::BTreeMap;

Expand Down
5 changes: 3 additions & 2 deletions indexer/tasks/src/multiera/multiera_txs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use cml_core::serialization::Serialize;
use cml_crypto::RawBytesEncoding;
use std::collections::{BTreeSet, HashSet};

use super::multiera_block::MultieraBlockTask;
Expand Down Expand Up @@ -45,7 +46,7 @@ async fn handle_tx(
.1
.transaction_bodies()
.iter()
.map(|tx_body| <[u8; 32]>::from(tx_body.hash()).to_vec())
.map(|tx_body| tx_body.hash().to_raw_bytes().to_vec())
.collect::<Vec<_>>()
.as_slice(),
)
Expand All @@ -72,7 +73,7 @@ async fn handle_tx(
vec![]
};
TransactionActiveModel {
hash: Set(<[u8; 32]>::from(tx.hash()).to_vec()),
hash: Set(tx.hash().to_raw_bytes().to_vec()),
block_id: Set(database_block.id),
tx_index: Set(idx as i32),
payload: Set(tx_payload),
Expand Down

0 comments on commit 7e3982d

Please sign in to comment.