Update sync chain info on own block import (#6424)

Before we only updated the chain info of sync when we have imported
something using the import queue. However, if you import your own
blocks, this is not done using the import queue and so sync is not
updated. If we don't do this, it can lead to sync switching to "major
sync" mode because sync is not informed about new blocks. This
especially happens on Cumulus, where a collator is selected multiple
times to include its block into the relay chain and thus, sync switches
to major sync mode while the node is still building blocks.
This commit is contained in:
Bastian Köcher
2020-06-19 16:00:58 +02:00
committed by GitHub
parent 737ba2ea20
commit 7858828d98
3 changed files with 22 additions and 1 deletions
+5
View File
@@ -544,6 +544,11 @@ impl<B: BlockT, H: ExHashT> Protocol<B, H> {
self.sync.update_chain_info(&info.best_hash, info.best_number);
}
/// Inform sync about an own imported block.
pub fn own_block_imported(&mut self, hash: B::Hash, number: NumberFor<B>) {
self.sync.update_chain_info(&hash, number);
}
fn update_peer_info(&mut self, who: &PeerId) {
if let Some(info) = self.sync.peer_info(who) {
if let Some(ref mut peer) = self.context_data.peers.get_mut(who) {