Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Don't update common block on ancient block import (#4073)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkpar authored and gavofyork committed Nov 10, 2019
1 parent c14e1f8 commit 6aa8551
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions core/network/src/protocol/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -974,34 +974,34 @@ impl<B: BlockT> ChainSync<B> {
/// Updates our internal state for best queued block and then goes
/// through all peers to update our view of their state as well.
fn on_block_queued(&mut self, hash: &B::Hash, number: NumberFor<B>) {
if number > self.best_queued_number {
self.best_queued_number = number;
self.best_queued_hash = *hash;
}
if let Some(_) = self.fork_targets.remove(&hash) {
trace!(target: "sync", "Completed fork sync {:?}", hash);
}
// Update common blocks
for (n, peer) in self.peers.iter_mut() {
if let PeerSyncState::AncestorSearch(_, _) = peer.state {
// Wait for ancestry search to complete first.
continue;
if number > self.best_queued_number {
self.best_queued_number = number;
self.best_queued_hash = *hash;
// Update common blocks
for (n, peer) in self.peers.iter_mut() {
if let PeerSyncState::AncestorSearch(_, _) = peer.state {
// Wait for ancestry search to complete first.
continue;
}
let new_common_number = if peer.best_number >= number {
number
} else {
peer.best_number
};
trace!(
target: "sync",
"Updating peer {} info, ours={}, common={}->{}, their best={}",
n,
number,
peer.common_number,
new_common_number,
peer.best_number,
);
peer.common_number = new_common_number;
}
let new_common_number = if peer.best_number >= number {
number
} else {
peer.best_number
};
trace!(
target: "sync",
"Updating peer {} info, ours={}, common={}->{}, their best={}",
n,
number,
peer.common_number,
new_common_number,
peer.best_number,
);
peer.common_number = new_common_number;
}
self.is_idle = false;
}
Expand Down

0 comments on commit 6aa8551

Please sign in to comment.