Skip to content

Commit

Permalink
Ignore older slots/segment headers too, not just equal
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Jun 28, 2024
1 parent f6ed626 commit 1967e4c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
20 changes: 12 additions & 8 deletions crates/subspace-farmer/src/cluster/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ impl NodeClient for ClusterNodeClient {
move |broadcast| {
let slot_info = broadcast.slot_info;

let maybe_slot_info = if last_slot_number == Some(slot_info.slot_number) {
let maybe_slot_info = if let Some(last_slot_number) = last_slot_number
&& last_slot_number >= slot_info.slot_number
{
None
} else {
last_slot_number.replace(slot_info.slot_number);
Expand Down Expand Up @@ -377,14 +379,16 @@ impl NodeClient for ClusterNodeClient {
let archived_segment_header = broadcast.archived_segment_header;
let segment_index = archived_segment_header.segment_index();

let maybe_archived_segment_header =
if last_archived_segment_index == Some(segment_index) {
None
} else {
last_archived_segment_index.replace(segment_index);
let maybe_archived_segment_header = if let Some(last_archived_segment_index) =
last_archived_segment_index
&& last_archived_segment_index >= segment_index
{
None
} else {
last_archived_segment_index.replace(segment_index);

Some(archived_segment_header)
};
Some(archived_segment_header)
};

async move { maybe_archived_segment_header }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ where
async move {
let mut last_slot_number = None;
while let Some(slot_info) = slot_info_subscription.next().await {
if last_slot_number == Some(slot_info.slot_number) {
if let Some(last_slot_number) = last_slot_number
&& last_slot_number >= slot_info.slot_number
{
continue;
}
last_slot_number.replace(slot_info.slot_number);
Expand Down Expand Up @@ -182,7 +184,9 @@ where
);
}

if last_archived_segment_index == Some(segment_index) {
if let Some(last_archived_segment_index) = last_archived_segment_index
&& last_archived_segment_index >= segment_index
{
continue;
}
last_archived_segment_index.replace(segment_index);
Expand Down

0 comments on commit 1967e4c

Please sign in to comment.