mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 20:31:13 +00:00
Rewrite network protocol/service to use channels (#1340)
* rewrite network protocol/service to use channels * remove use of unwrap * re-introduce with_spec * remove unnecessary mut * remove unused param * improve with_spec, add with_gossip * rename job to task * style: re-add comma * remove extra string allocs * rename use of channel * turn TODO into FIXME * remove mut in match * remove Self in new * pass headers by value to network service * remove network sender from service * remove TODO * better expect * rationalize use of network sender in ondemand
This commit is contained in:
committed by
Bastian Köcher
parent
8aae19e2db
commit
a2d2ed69ab
@@ -192,12 +192,12 @@ impl<Components: components::Components> Service<Components> {
|
||||
};
|
||||
|
||||
let has_bootnodes = !network_params.network_config.boot_nodes.is_empty();
|
||||
let network = network::Service::new(
|
||||
let (network, network_chan) = network::Service::new(
|
||||
network_params,
|
||||
protocol_id,
|
||||
import_queue
|
||||
)?;
|
||||
on_demand.map(|on_demand| on_demand.set_service_link(Arc::downgrade(&network)));
|
||||
on_demand.map(|on_demand| on_demand.set_network_sender(network_chan));
|
||||
|
||||
{
|
||||
// block notifications
|
||||
@@ -208,7 +208,7 @@ impl<Components: components::Components> Service<Components> {
|
||||
let events = client.import_notification_stream()
|
||||
.for_each(move |notification| {
|
||||
if let Some(network) = network.upgrade() {
|
||||
network.on_block_imported(notification.hash, ¬ification.header);
|
||||
network.on_block_imported(notification.hash, notification.header);
|
||||
}
|
||||
if let (Some(txpool), Some(client)) = (txpool.upgrade(), wclient.upgrade()) {
|
||||
Components::TransactionPool::on_block_imported(
|
||||
@@ -260,7 +260,7 @@ impl<Components: components::Components> Service<Components> {
|
||||
let events = MostRecentNotification(client.finality_notification_stream().fuse())
|
||||
.for_each(move |notification| {
|
||||
if let Some(network) = network.upgrade() {
|
||||
network.on_block_finalized(notification.hash, ¬ification.header);
|
||||
network.on_block_finalized(notification.hash, notification.header);
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user