diff --git a/src/mapper/crawl.rs b/src/mapper/crawl.rs index c051055f..cd8f6fe1 100644 --- a/src/mapper/crawl.rs +++ b/src/mapper/crawl.rs @@ -127,9 +127,10 @@ impl EventWriter { fn crawl_transaction( &self, tx: &TransactionBody, + tx_hash: &str, aux_data: Option<&AuxiliaryData>, ) -> Result<(), Error> { - let record = self.to_transaction_record(tx, aux_data)?; + let record = self.to_transaction_record(tx, tx_hash, aux_data)?; self.append_from(record.clone())?; @@ -206,11 +207,11 @@ impl EventWriter { let child = self.child_writer(EventContext { tx_idx: Some(idx), - tx_hash: Some(tx_hash), + tx_hash: Some(tx_hash.to_owned()), ..EventContext::default() }); - child.crawl_transaction(tx, aux_data)?; + child.crawl_transaction(tx, &tx_hash, aux_data)?; } if self.config.include_block_end_events { diff --git a/src/mapper/map.rs b/src/mapper/map.rs index f45ce14c..00477fb2 100644 --- a/src/mapper/map.rs +++ b/src/mapper/map.rs @@ -261,10 +261,13 @@ impl EventWriter { pub fn to_transaction_record( &self, body: &TransactionBody, + tx_hash: &str, aux_data: Option<&AuxiliaryData>, ) -> Result { let mut record = TransactionRecord::default(); + record.hash.push_str(tx_hash); + for component in body.iter() { match component { TransactionBodyComponent::Fee(x) => { diff --git a/src/model.rs b/src/model.rs index 6a23ee9c..71cfca68 100644 --- a/src/model.rs +++ b/src/model.rs @@ -114,6 +114,7 @@ impl From for EventData { #[derive(Serialize, Deserialize, Debug, Clone, Default)] pub struct TransactionRecord { + pub hash: String, pub fee: u64, pub ttl: Option, pub validity_interval_start: Option, diff --git a/src/sinks/terminal/format.rs b/src/sinks/terminal/format.rs index 27968097..f307fd9b 100644 --- a/src/sinks/terminal/format.rs +++ b/src/sinks/terminal/format.rs @@ -67,23 +67,24 @@ impl LogLine { total_output, fee, ttl, + hash, .. }) => LogLine { prefix: "TX", color: Color::DarkBlue, content: format!( - "{{ total_output: {}, fee: {}, hash: {:?}, ttl: {:?} }}", - total_output, fee, &source.context.tx_hash, ttl + "{{ total_output: {}, fee: {}, hash: {}, ttl: {:?} }}", + total_output, fee, hash, ttl ), source, max_width, }, - EventData::TransactionEnd(TransactionRecord { .. }) => LogLine { + EventData::TransactionEnd(TransactionRecord { hash, .. }) => LogLine { prefix: "ENDTX", color: Color::DarkBlue, content: format!( - "{{ hash: {:?} }}", - &source.context.tx_hash + "{{ hash: {} }}", + hash ), source, max_width,