Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
Faster segment acknowledgement on the farmer
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Apr 30, 2022
1 parent b9a13e2 commit 40d9941
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion crates/sc-consensus-subspace-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,9 @@ where

if let Some(mut sender) = maybe_sender {
if let Err(error) = sender.send(()).await {
warn!("Failed to acknowledge archived segment: {error}");
if !error.is_disconnected() {
warn!("Failed to acknowledge archived segment: {error}");
}
}
}

Expand Down
10 changes: 7 additions & 3 deletions crates/subspace-farmer/src/archiving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,17 @@ impl Archiving {
Some(archived_segment) => {
let segment_index = archived_segment.root_block.segment_index();
let (acknowledge_sender, acknowledge_receiver) = oneshot::channel();
// Acknowledge immediately to allow node to continue sync quickly,
// but this will miss some segments in case farmer crashed in the
// meantime. Ideally we'd acknowledge after, but it makes node wait
// for it and the whole process very sequential.
if let Err(error) = client.acknowledge_archived_segment(segment_index).await {
error!("Failed to send archived segment acknowledgement: {error}");
}
if let Err(error) = archived_segments_sync_sender.send((archived_segment, acknowledge_sender)) {
error!("Failed to send archived segment for plotting: {error}");
}
let _ = acknowledge_receiver.await;
if let Err(error) = client.acknowledge_archived_segment(segment_index).await {
error!("Failed to send archived segment acknowledgement: {error}");
}
},
None => {
debug!("Subscription has forcefully closed from node side!");
Expand Down

0 comments on commit 40d9941

Please sign in to comment.