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 3 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
14 changes: 14 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,15 +144,27 @@ impl EventWriter {
false => None,
},
transactions: None,
invalid_transactions: None
};

if self.config.include_block_details {
record.transactions = Some(self.collect_babbage_tx_records(source)?);
}

if self.config.include_invalid_transaction_details {
record.invalid_transactions = self.collect_invalid_tx_indices(source);
}

Mercurial marked this conversation as resolved.
Show resolved Hide resolved
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
3 changes: 3 additions & 0 deletions src/mapper/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ pub struct Config {
#[serde(default)]
pub include_transaction_end_events: bool,

#[serde(default)]
pub include_invalid_transaction_details: bool,

#[serde(default)]
pub include_block_details: bool,

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