1- use crate :: { Block0 , InMemoryNode } ;
1+ use crate :: { Block0 , InMemoryNode , CARDANO_MAINNET_SLOTS_PER_EPOCH } ;
22use cardano_serialization_lib:: metadata:: GeneralTransactionMetadata ;
33use cardano_serialization_lib:: utils:: BigNum ;
44use cardano_serialization_lib:: { Block , Transaction , TransactionWitnessSet } ;
@@ -15,8 +15,6 @@ use std::path::Path;
1515use std:: sync:: { Arc , RwLock } ;
1616use tokio:: task:: JoinHandle ;
1717
18- const CARDANO_MAINNET_SLOTS_PER_EPOCH : u64 = 43200 ;
19-
2018pub type BlockNo = u32 ;
2119pub type Address = String ;
2220
@@ -52,7 +50,6 @@ impl Debug for InMemoryDbSync {
5250}
5351
5452impl InMemoryDbSync {
55-
5653 /// Creates new instance out of block0
5754 #[ must_use]
5855 pub fn from_block0 ( block0 : & Block0 ) -> Self {
@@ -135,16 +132,15 @@ impl InMemoryDbSync {
135132
136133 /// Query transaction by it's hash representation
137134 #[ must_use]
138- pub fn transaction_by_hash ( & self , hash : & str ) -> Vec < ( & Block , & Transaction ) > {
135+ pub fn transaction_by_hash ( & self , hash : & str ) -> Vec < ( Option < & Block > , & Transaction ) > {
139136 self . transactions
140137 . iter ( )
141138 . filter_map ( |( block, txs) | {
142139 if let Some ( tx) = txs. iter ( ) . find ( |tx| tx. to_hex ( ) == hash) {
143140 let block = self
144141 . blocks
145142 . iter ( )
146- . find ( |x| x. header ( ) . header_body ( ) . block_number ( ) == * block)
147- . expect ( "data inconsitency. cannot find block with block no from tx" ) ;
143+ . find ( |x| x. header ( ) . header_body ( ) . block_number ( ) == * block) ;
148144
149145 return Some ( ( block, tx) ) ;
150146 }
0 commit comments