Skip to content

Commit 5ed4698

Browse files
committed
add comments for min common ancestor calc
1 parent 586a4a3 commit 5ed4698

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/block_range_scanner/common.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,12 @@ async fn initialize_live_streaming_state<N: Network>(
136136

137137
let confirmed = incoming_block_num.saturating_sub(block_confirmations);
138138

139+
// The minimum common ancestor is the block before the stream start
140+
let min_common_ancestor = stream_start.saturating_sub(1);
141+
139142
// Catch up on any confirmed blocks between stream_start and the confirmed tip
140-
// todo: explain why stream_start - 1 is min_common_ancestor
141143
let previous_batch_end = stream_range_with_reorg_handling(
142-
stream_start.saturating_sub(1),
144+
min_common_ancestor,
143145
stream_start,
144146
confirmed,
145147
max_block_range,
@@ -291,8 +293,11 @@ async fn stream_next_batch<N: Network>(
291293
return true;
292294
}
293295

296+
// The minimum common ancestor is the block before the stream start
297+
let min_common_ancestor = stream_start.saturating_sub(1);
298+
294299
state.previous_batch_end = stream_range_with_reorg_handling(
295-
stream_start.saturating_sub(1),
300+
min_common_ancestor,
296301
state.batch_start,
297302
batch_end_num,
298303
max_block_range,

0 commit comments

Comments
 (0)