Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move sync logic out of Client #12841

Merged
merged 7 commits into from
Jan 31, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feedback
  • Loading branch information
Longarithm committed Jan 31, 2025
commit d3036e2398b1abe862c37711c197e038c456e655
10 changes: 3 additions & 7 deletions chain/client/src/sync/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@ impl SyncHandler {
&shards_to_sync,
);
let state_sync_result = unwrap_and_report_state_sync_result!(state_sync_result);
match state_sync_result {
StateSyncResult::InProgress => return None,
StateSyncResult::Completed => (),
if matches!(state_sync_result, StateSyncResult::InProgress) {
return None;
}

tracing::info!(target: "sync", "State sync: all shards are done");
Expand Down Expand Up @@ -324,8 +323,6 @@ impl SyncHandler {
) -> Result<Vec<(CryptoHash, PeerId)>, near_chain::Error> {
let now = self.clock.now_utc();

let mut have_all = true;

let sync_hash = *block_header.hash();
let prev_hash = *block_header.prev_hash();

Expand All @@ -339,7 +336,6 @@ impl SyncHandler {
let (request_block, have_block) =
self.sync_block_status(chain, &sync_hash, &hash, now)?;
tracing::trace!(target: "sync", ?hash, ?request_block, ?have_block, "request_sync_blocks");
have_all = have_all && have_block;

if have_block {
self.last_time_sync_block_requested.remove(&hash);
Expand All @@ -360,7 +356,7 @@ impl SyncHandler {
blocks_to_request.push((hash, peer_id));
}

tracing::trace!(target: "sync", ?have_all, "request_sync_blocks: done");
tracing::trace!(target: "sync", num_blocks_to_request = blocks_to_request.len(), "request_sync_blocks: done");

Ok(blocks_to_request)
}
Expand Down
Loading