Skip to content
Snippets Groups Projects
Commit c58a9b7f authored by Arkadiy Paronyan's avatar Arkadiy Paronyan Committed by Gavin Wood
Browse files

Don't update common block on ancient block import (#4073)

parent f5f4c2d4
No related merge requests found
......@@ -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;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment