mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +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:
@@ -55,7 +55,7 @@ use sc_network::{NetworkService, NetworkStatus, network_state::NetworkState, Pee
|
||||
use log::{log, warn, debug, error, Level};
|
||||
use codec::{Encode, Decode};
|
||||
use sp_runtime::generic::BlockId;
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
|
||||
use parity_util_mem::MallocSizeOf;
|
||||
use sp_utils::{status_sinks, mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender}};
|
||||
|
||||
@@ -382,6 +382,13 @@ fn build_network_future<
|
||||
if announce_imported_blocks {
|
||||
network.service().announce_block(notification.hash, Vec::new());
|
||||
}
|
||||
|
||||
if let sp_consensus::BlockOrigin::Own = notification.origin {
|
||||
network.service().own_block_imported(
|
||||
notification.hash,
|
||||
notification.header.number().clone(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// We poll `finality_notification_stream`, but we only take the last event.
|
||||
|
||||
Reference in New Issue
Block a user