@@ -7,6 +7,7 @@ use pallas_hardano::storage::immutable::chunk::{read_blocks, Reader};
7
7
use pallas_traverse:: MultiEraBlock ;
8
8
use slog:: { debug, error, Logger } ;
9
9
10
+ use crate :: cardano_block_scanner:: ChainScannedBlocks ;
10
11
use crate :: cardano_block_scanner:: { BlockStreamer , ScannedBlock } ;
11
12
use crate :: digesters:: ImmutableFile ;
12
13
use crate :: StdResult ;
@@ -20,7 +21,7 @@ pub struct ImmutableBlockStreamer {
20
21
21
22
#[ async_trait]
22
23
impl BlockStreamer for ImmutableBlockStreamer {
23
- async fn poll_next ( & mut self ) -> StdResult < Option < Vec < ScannedBlock > > > {
24
+ async fn poll_next ( & mut self ) -> StdResult < Option < ChainScannedBlocks > > {
24
25
match & self . remaining_immutable_files . pop_front ( ) {
25
26
Some ( immutable_file) => {
26
27
debug ! (
@@ -37,7 +38,7 @@ impl BlockStreamer for ImmutableBlockStreamer {
37
38
immutable_file. path. display( )
38
39
)
39
40
} ) ?;
40
- Ok ( Some ( blocks) )
41
+ Ok ( Some ( ChainScannedBlocks :: RollForwards ( blocks) ) )
41
42
}
42
43
None => Ok ( None ) ,
43
44
}
@@ -123,12 +124,22 @@ impl ImmutableBlockStreamer {
123
124
124
125
#[ cfg( test) ]
125
126
mod tests {
127
+ use crate :: cardano_block_scanner:: BlockStreamerTestExtensions ;
126
128
use crate :: test_utils:: { TempDir , TestLogger } ;
127
129
128
130
use super :: * ;
129
131
130
132
#[ tokio:: test]
131
133
async fn test_parse_expected_number_of_transactions ( ) {
134
+ fn sum_of_transactions_len ( o : Option < ChainScannedBlocks > ) -> Option < usize > {
135
+ match o {
136
+ Some ( ChainScannedBlocks :: RollForwards ( b) ) => {
137
+ Some ( b. into_iter ( ) . map ( |b| b. transactions_len ( ) ) . sum ( ) )
138
+ }
139
+ _ => None ,
140
+ }
141
+ }
142
+
132
143
// We know the number of transactions in those prebuilt immutables
133
144
let immutable_files = [
134
145
( "00000.chunk" , 0usize ) ,
@@ -148,19 +159,19 @@ mod tests {
148
159
149
160
let immutable_blocks = streamer. poll_next ( ) . await . unwrap ( ) ;
150
161
assert_eq ! (
151
- immutable_blocks . map ( |b| b . into_iter ( ) . map ( |b| b . transactions_len ( ) ) . sum ( ) ) ,
162
+ sum_of_transactions_len ( immutable_blocks ) ,
152
163
Some ( immutable_files[ 0 ] . 1 )
153
164
) ;
154
165
155
166
let immutable_blocks = streamer. poll_next ( ) . await . unwrap ( ) ;
156
167
assert_eq ! (
157
- immutable_blocks . map ( |b| b . into_iter ( ) . map ( |b| b . transactions_len ( ) ) . sum ( ) ) ,
168
+ sum_of_transactions_len ( immutable_blocks ) ,
158
169
Some ( immutable_files[ 1 ] . 1 )
159
170
) ;
160
171
161
172
let immutable_blocks = streamer. poll_next ( ) . await . unwrap ( ) ;
162
173
assert_eq ! (
163
- immutable_blocks . map ( |b| b . into_iter ( ) . map ( |b| b . transactions_len ( ) ) . sum ( ) ) ,
174
+ sum_of_transactions_len ( immutable_blocks ) ,
164
175
Some ( immutable_files[ 2 ] . 1 )
165
176
) ;
166
177
0 commit comments