Skip to content

Commit

Permalink
Merge pull request #1959 from subspace/fix-dsn-sync
Browse files Browse the repository at this point in the history
Fix DSN sync
  • Loading branch information
nazar-pc authored Sep 13, 2023
2 parents e69ee3e + 40e7a4c commit 8c494e4
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions crates/subspace-service/src/sync_from_dsn/import_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,21 @@ where
}
}

// Import queue handles verification and importing it into the client
let last_segment = segment_indices_iter.peek().is_none();
if last_segment {
let last_block = blocks_to_import
.pop()
.expect("Not empty, checked above; qed");
import_queue_service.import_blocks(BlockOrigin::NetworkInitialSync, blocks_to_import);
// This will notify Substrate's sync mechanism and allow regular Substrate sync to continue gracefully
import_queue_service.import_blocks(BlockOrigin::NetworkBroadcast, vec![last_block]);
} else {
import_queue_service.import_blocks(BlockOrigin::NetworkInitialSync, blocks_to_import);
if !blocks_to_import.is_empty() {
// Import queue handles verification and importing it into the client
let last_segment = segment_indices_iter.peek().is_none();
if last_segment {
let last_block = blocks_to_import
.pop()
.expect("Not empty, checked above; qed");
import_queue_service
.import_blocks(BlockOrigin::NetworkInitialSync, blocks_to_import);
// This will notify Substrate's sync mechanism and allow regular Substrate sync to continue gracefully
import_queue_service.import_blocks(BlockOrigin::NetworkBroadcast, vec![last_block]);
} else {
import_queue_service
.import_blocks(BlockOrigin::NetworkInitialSync, blocks_to_import);
}
}

*last_processed_segment_index = segment_index;
Expand Down

0 comments on commit 8c494e4

Please sign in to comment.