Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/expose invalid transactions #494

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/mapper/babbage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use pallas::ledger::primitives::babbage::{

use pallas::crypto::hash::Hash;

use std::ops::Deref;

use crate::model::{BlockRecord, Era, TransactionRecord};
use crate::utils::time::TimeProvider;
use crate::{
Expand Down Expand Up @@ -142,6 +144,7 @@ impl EventWriter {
false => None,
},
transactions: None,
invalid_transactions: self.collect_invalid_tx_indices(source)
};

if self.config.include_block_details {
Expand All @@ -151,6 +154,13 @@ impl EventWriter {
Ok(record)
}

pub fn collect_invalid_tx_indices(
&self,
block: &MintedBlock,
) -> Option<Vec<u32>> {
block.invalid_transactions.as_ref().map(|im| im.deref().to_vec())
}

pub fn collect_babbage_tx_records(
&self,
block: &MintedBlock,
Expand Down
2 changes: 2 additions & 0 deletions src/mapper/byron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ impl EventWriter {
false => None,
},
transactions: None,
invalid_transactions: None
};

if self.config.include_block_details {
Expand Down Expand Up @@ -235,6 +236,7 @@ impl EventWriter {
false => None,
},
transactions: None,
invalid_transactions: None
})
}

Expand Down
1 change: 1 addition & 0 deletions src/mapper/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ impl EventWriter {
false => None,
},
transactions: None,
invalid_transactions: None
};

if self.config.include_block_details {
Expand Down
1 change: 1 addition & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ pub struct BlockRecord {
pub previous_hash: String,
pub cbor_hex: Option<String>,
pub transactions: Option<Vec<TransactionRecord>>,
pub invalid_transactions: Option<Vec<u32>>
}

impl From<BlockRecord> for EventData {
Expand Down