@@ -358,6 +358,7 @@ impl<N: Network> Service<N> {
358358
359359 tokio:: spawn ( async move {
360360 Self :: stream_historical_blocks (
361+ start_block_num,
361362 start_block_num,
362363 end_block_num,
363364 max_block_range,
@@ -437,6 +438,7 @@ impl<N: Network> Service<N> {
437438
438439 while start_block < confirmed_tip {
439440 Self :: stream_historical_blocks (
441+ start_block,
440442 start_block,
441443 confirmed_tip,
442444 max_block_range,
@@ -613,7 +615,8 @@ impl<N: Network> Service<N> {
613615 }
614616
615617 async fn stream_historical_blocks (
616- start : BlockNumber ,
618+ stream_start : BlockNumber ,
619+ mut next_start_block : BlockNumber ,
617620 end : BlockNumber ,
618621 max_block_range : u64 ,
619622 sender : & mpsc:: Sender < Message > ,
@@ -622,8 +625,6 @@ impl<N: Network> Service<N> {
622625 ) -> Option < N :: BlockResponse > {
623626 let mut batch_count = 0 ;
624627
625- let mut next_start_block = start;
626-
627628 // must be <= to include the edge case when start == end (i.e. return the single block
628629 // range)
629630 loop {
@@ -659,8 +660,8 @@ impl<N: Network> Service<N> {
659660 if !sender. try_stream ( Notification :: ReorgDetected ) . await {
660661 return None ;
661662 }
662- if common_ancestor. header ( ) . number ( ) < start {
663- start
663+ if common_ancestor. header ( ) . number ( ) < stream_start {
664+ stream_start
664665 } else {
665666 common_ancestor. header ( ) . number ( ) + 1
666667 }
@@ -707,6 +708,7 @@ impl<N: Network> Service<N> {
707708 let confirmed = incoming_block_num. saturating_sub ( block_confirmations) ;
708709
709710 let mut previous_batch_end = Self :: stream_historical_blocks (
711+ stream_start,
710712 stream_start,
711713 confirmed,
712714 max_block_range,
@@ -768,6 +770,7 @@ impl<N: Network> Service<N> {
768770 let batch_end_num = incoming_block_num. saturating_sub ( block_confirmations) ;
769771 if batch_end_num >= batch_start {
770772 previous_batch_end = Self :: stream_historical_blocks (
773+ stream_start,
771774 batch_start,
772775 batch_end_num,
773776 max_block_range,
0 commit comments