mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 00:31:07 +00:00
Allow changing the behavior for imported blocks (#5236)
* Added option to disable default block announce * Added on_block_imported on NetworkService * Revert "Added on_block_imported on NetworkService" This reverts commit ba360cad96e0cb041d7047af30df2a35eb112449. * Do not announce block if set to not announce block * Revert fix * Moving default announce block to NetworkConfig * WIP Forked at:ad90ab7ec9Parent branch: origin/master * WIP Forked at:ad90ab7ec9Parent branch: origin/master * Removing boolean in favor of explicit call * Fixing tests * WIP Forked at:ad90ab7ec9Parent branch: origin/master * WIP Forked at:ad90ab7ec9Parent branch: origin/master * increase spec_version * increase spec_version * Fixed test * Fixing test * Renamed should_announce_imported_blocks to announce_imported_blocks * Updated assert_cmd
This commit is contained in:
@@ -1204,6 +1204,7 @@ ServiceBuilder<
|
||||
network_status_sinks.clone(),
|
||||
system_rpc_rx,
|
||||
has_bootnodes,
|
||||
config.announce_block,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -127,6 +127,8 @@ pub struct Configuration {
|
||||
///
|
||||
/// The default value is 8.
|
||||
pub max_runtime_instances: usize,
|
||||
/// Announce block automatically after they have been imported
|
||||
pub announce_block: bool,
|
||||
}
|
||||
|
||||
/// Configuration of the client keystore.
|
||||
@@ -229,6 +231,7 @@ impl Default for Configuration {
|
||||
tracing_targets: Default::default(),
|
||||
tracing_receiver: Default::default(),
|
||||
max_runtime_instances: 8,
|
||||
announce_block: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,6 +328,7 @@ fn build_network_future<
|
||||
status_sinks: Arc<Mutex<status_sinks::StatusSinks<(NetworkStatus<B>, NetworkState)>>>,
|
||||
mut rpc_rx: mpsc::UnboundedReceiver<sc_rpc::system::Request<B>>,
|
||||
should_have_peers: bool,
|
||||
announce_imported_blocks: bool,
|
||||
) -> impl Future<Output = ()> {
|
||||
let mut imported_blocks_stream = client.import_notification_stream().fuse();
|
||||
let mut finality_notification_stream = client.finality_notification_stream().fuse();
|
||||
@@ -337,7 +338,11 @@ fn build_network_future<
|
||||
|
||||
// We poll `imported_blocks_stream`.
|
||||
while let Poll::Ready(Some(notification)) = Pin::new(&mut imported_blocks_stream).poll_next(cx) {
|
||||
network.on_block_imported(notification.header, Vec::new(), notification.is_new_best);
|
||||
network.on_block_imported(notification.header, notification.is_new_best);
|
||||
|
||||
if announce_imported_blocks {
|
||||
network.service().announce_block(notification.hash, Vec::new());
|
||||
}
|
||||
}
|
||||
|
||||
// We poll `finality_notification_stream`, but we only take the last event.
|
||||
|
||||
Reference in New Issue
Block a user