@@ -43,22 +43,12 @@ impl EventScannerBuilder<Historic> {
4343 let from_num = scanner. config . from_block . as_number ( ) . unwrap_or ( 0 ) ;
4444 let to_num = scanner. config . to_block . as_number ( ) . unwrap_or ( 0 ) ;
4545
46- let from_exceeds = from_num > latest_block;
47- let to_exceeds = to_num > latest_block;
48-
49- match ( from_exceeds, to_exceeds) {
50- ( true , true ) => Err ( ScannerError :: BlockExceedsLatest (
51- "from_block and to_block" ,
52- from_num. max ( to_num) ,
53- latest_block,
54- ) ) ?,
55- ( true , false ) => {
56- Err ( ScannerError :: BlockExceedsLatest ( "from_block" , from_num, latest_block) ) ?;
57- }
58- ( false , true ) => {
59- Err ( ScannerError :: BlockExceedsLatest ( "to_block" , to_num, latest_block) ) ?;
60- }
61- ( false , false ) => { }
46+ if from_num > latest_block {
47+ Err ( ScannerError :: BlockExceedsLatest ( "from_block" , from_num, latest_block) ) ?;
48+ }
49+
50+ if to_num > latest_block {
51+ Err ( ScannerError :: BlockExceedsLatest ( "to_block" , to_num, latest_block) ) ?;
6252 }
6353
6454 Ok ( scanner)
@@ -198,11 +188,11 @@ mod tests {
198188 . await ;
199189
200190 match result {
201- Err ( ScannerError :: BlockExceedsLatest ( "from_block and to_block " , max, latest) ) => {
202- assert_eq ! ( max, latest_block + 100 ) ;
191+ Err ( ScannerError :: BlockExceedsLatest ( "from_block" , max, latest) ) => {
192+ assert_eq ! ( max, latest_block + 50 ) ;
203193 assert_eq ! ( latest, latest_block) ;
204194 }
205- _ => panic ! ( "Expected BlockExceedsLatest error with 'from_block and to_block '" ) ,
195+ _ => panic ! ( "Expected BlockExceedsLatest error for 'from_block'" ) ,
206196 }
207197 }
208198
0 commit comments