mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 17:28:00 +00:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user