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

Fix Gossip Syncing for Blocks at Same Epoch #971

Merged
merged 1 commit into from
Jan 28, 2021
Merged
Changes from all commits
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
12 changes: 6 additions & 6 deletions blockchain/chain_sync/src/sync_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ where
let mut accepted_blocks: Vec<Cid> = Vec::new();

let sync_len = head.epoch() - to.epoch();
if !sync_len.is_positive() {
if sync_len < 0 {
return Err(Error::Other(
"Target tipset must be after heaviest".to_string(),
));
Expand Down Expand Up @@ -239,15 +239,15 @@ where
}

let last_ts = return_set.last().unwrap();
if last_ts.parents() == to.parents() {
// block received part of same tipset as best block
// This removes need to sync fork
return Ok(return_set);
}

// Check if local chain was fork
if last_ts.key() != to.key() {
info!("Local chain was fork. Syncing fork...");
if last_ts.parents() == to.parents() {
// block received part of same tipset as best block
// This removes need to sync fork
return Ok(return_set);
}
// add fork into return set
let fork = self.sync_fork(&last_ts, &to).await?;
info!("Fork Synced");
Expand Down