@@ -119,38 +119,36 @@ impl CardanoTransactionParser {
119
119
let cardano_blocks_reader =
120
120
CardanoTransactionParser :: cardano_blocks_reader ( immutable_file) ?;
121
121
122
- cardano_blocks_reader
123
- . into_iter ( )
124
- . map ( |b| CardanoTransactionParser :: convert_to_block ( b, immutable_file) )
125
- . collect :: < Result < Vec < _ > , _ > > ( )
126
- . map_err ( |e| anyhow ! ( e) )
122
+ let mut blocks = Vec :: new ( ) ;
123
+ for block in cardano_blocks_reader {
124
+ let block = block. map_err ( |e| {
125
+ anyhow ! ( e) . context ( format ! (
126
+ "Error while reading block in immutable file: '{:?}'" ,
127
+ immutable_file. path
128
+ ) )
129
+ } ) ?;
130
+ blocks. push ( CardanoTransactionParser :: convert_to_block (
131
+ & block,
132
+ immutable_file,
133
+ ) ?) ;
134
+ }
135
+ Ok ( blocks)
127
136
}
128
137
129
- fn convert_to_block (
130
- block : Result < Vec < u8 > , std:: io:: Error > ,
131
- immutable_file : & ImmutableFile ,
132
- ) -> StdResult < Block > {
133
- let block = block. map_err ( |e| {
134
- anyhow ! ( e) . context ( format ! (
135
- "Error while reading block in immutable file: '{:?}'" ,
136
- immutable_file. path
137
- ) )
138
- } ) ?;
139
- let multi_era_block = MultiEraBlock :: decode ( & block) . map_err ( |e| {
138
+ fn convert_to_block ( block : & [ u8 ] , immutable_file : & ImmutableFile ) -> StdResult < Block > {
139
+ let multi_era_block = MultiEraBlock :: decode ( block) . map_err ( |e| {
140
140
anyhow ! ( e) . context ( format ! (
141
141
"Error while decoding block in immutable file: '{:?}'" ,
142
142
immutable_file. path
143
143
) )
144
144
} ) ?;
145
- let block =
146
- Block :: try_convert ( multi_era_block, immutable_file. number ) . with_context ( || {
147
- format ! (
148
- "CardanoTransactionParser could not read data from block in immutable file: {:?}" ,
149
- immutable_file. path
150
- )
151
- } ) ?;
152
145
153
- Ok ( block)
146
+ Block :: try_convert ( multi_era_block, immutable_file. number ) . with_context ( || {
147
+ format ! (
148
+ "CardanoTransactionParser could not read data from block in immutable file: {:?}" ,
149
+ immutable_file. path
150
+ )
151
+ } )
154
152
}
155
153
156
154
fn cardano_blocks_reader ( immutable_file : & ImmutableFile ) -> StdResult < Reader > {
0 commit comments