mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 21:41:12 +00:00
*: Register network event stream for authority discovery (#4344)
Previously one would create a sender and receiver channel pair, pass the sender to the `build_network_future` through the service builder and funnel network events returned from polling the network service into the sender to be consumed by the authority discovery module owning the receiver. With recent changes it is now possible to register an `event_stream` with the network service directly, thus one does not need to make the detour through the `build_network_future`.
This commit is contained in:
@@ -35,7 +35,7 @@ use futures03::{
|
||||
};
|
||||
use sc_keystore::{Store as Keystore};
|
||||
use log::{info, warn, error};
|
||||
use sc_network::{FinalityProofProvider, OnDemand, NetworkService, NetworkStateInfo, DhtEvent};
|
||||
use sc_network::{FinalityProofProvider, OnDemand, NetworkService, NetworkStateInfo};
|
||||
use sc_network::{config::BoxFinalityProofRequestBuilder, specialization::NetworkSpecialization};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use sp_core::{Blake2Hasher, H256, Hasher};
|
||||
@@ -90,7 +90,6 @@ pub struct ServiceBuilder<TBl, TRtApi, TCfg, TGen, TCSExt, TCl, TFchr, TSc, TImp
|
||||
transaction_pool: Arc<TExPool>,
|
||||
rpc_extensions: TRpc,
|
||||
remote_backend: Option<Arc<dyn RemoteBlockchain<TBl>>>,
|
||||
dht_event_tx: Option<mpsc::Sender<DhtEvent>>,
|
||||
marker: PhantomData<(TBl, TRtApi)>,
|
||||
}
|
||||
|
||||
@@ -225,7 +224,6 @@ where TGen: RuntimeGenesis, TCSExt: Extension {
|
||||
transaction_pool: Arc::new(()),
|
||||
rpc_extensions: Default::default(),
|
||||
remote_backend: None,
|
||||
dht_event_tx: None,
|
||||
marker: PhantomData,
|
||||
})
|
||||
}
|
||||
@@ -303,7 +301,6 @@ where TGen: RuntimeGenesis, TCSExt: Extension {
|
||||
transaction_pool: Arc::new(()),
|
||||
rpc_extensions: Default::default(),
|
||||
remote_backend: Some(remote_blockchain),
|
||||
dht_event_tx: None,
|
||||
marker: PhantomData,
|
||||
})
|
||||
}
|
||||
@@ -352,7 +349,6 @@ impl<TBl, TRtApi, TCfg, TGen, TCSExt, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TNet
|
||||
transaction_pool: self.transaction_pool,
|
||||
rpc_extensions: self.rpc_extensions,
|
||||
remote_backend: self.remote_backend,
|
||||
dht_event_tx: self.dht_event_tx,
|
||||
marker: self.marker,
|
||||
})
|
||||
}
|
||||
@@ -395,7 +391,6 @@ impl<TBl, TRtApi, TCfg, TGen, TCSExt, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TNet
|
||||
transaction_pool: self.transaction_pool,
|
||||
rpc_extensions: self.rpc_extensions,
|
||||
remote_backend: self.remote_backend,
|
||||
dht_event_tx: self.dht_event_tx,
|
||||
marker: self.marker,
|
||||
})
|
||||
}
|
||||
@@ -422,7 +417,6 @@ impl<TBl, TRtApi, TCfg, TGen, TCSExt, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TNet
|
||||
transaction_pool: self.transaction_pool,
|
||||
rpc_extensions: self.rpc_extensions,
|
||||
remote_backend: self.remote_backend,
|
||||
dht_event_tx: self.dht_event_tx,
|
||||
marker: self.marker,
|
||||
})
|
||||
}
|
||||
@@ -464,7 +458,6 @@ impl<TBl, TRtApi, TCfg, TGen, TCSExt, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TNet
|
||||
transaction_pool: self.transaction_pool,
|
||||
rpc_extensions: self.rpc_extensions,
|
||||
remote_backend: self.remote_backend,
|
||||
dht_event_tx: self.dht_event_tx,
|
||||
marker: self.marker,
|
||||
})
|
||||
}
|
||||
@@ -530,7 +523,6 @@ impl<TBl, TRtApi, TCfg, TGen, TCSExt, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TNet
|
||||
transaction_pool: self.transaction_pool,
|
||||
rpc_extensions: self.rpc_extensions,
|
||||
remote_backend: self.remote_backend,
|
||||
dht_event_tx: self.dht_event_tx,
|
||||
marker: self.marker,
|
||||
})
|
||||
}
|
||||
@@ -586,7 +578,6 @@ impl<TBl, TRtApi, TCfg, TGen, TCSExt, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TNet
|
||||
transaction_pool: Arc::new(transaction_pool),
|
||||
rpc_extensions: self.rpc_extensions,
|
||||
remote_backend: self.remote_backend,
|
||||
dht_event_tx: self.dht_event_tx,
|
||||
marker: self.marker,
|
||||
})
|
||||
}
|
||||
@@ -626,33 +617,6 @@ impl<TBl, TRtApi, TCfg, TGen, TCSExt, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TNet
|
||||
transaction_pool: self.transaction_pool,
|
||||
rpc_extensions,
|
||||
remote_backend: self.remote_backend,
|
||||
dht_event_tx: self.dht_event_tx,
|
||||
marker: self.marker,
|
||||
})
|
||||
}
|
||||
|
||||
/// Adds a dht event sender to builder to be used by the network to send dht events to the authority discovery
|
||||
/// module.
|
||||
pub fn with_dht_event_tx(
|
||||
self,
|
||||
dht_event_tx: mpsc::Sender<DhtEvent>,
|
||||
) -> Result<ServiceBuilder<TBl, TRtApi, TCfg, TGen, TCSExt, TCl, TFchr, TSc, TImpQu, TFprb, TFpp,
|
||||
TNetP, TExPool, TRpc, Backend>, Error> {
|
||||
Ok(ServiceBuilder {
|
||||
config: self.config,
|
||||
client: self.client,
|
||||
backend: self.backend,
|
||||
keystore: self.keystore,
|
||||
fetcher: self.fetcher,
|
||||
select_chain: self.select_chain,
|
||||
import_queue: self.import_queue,
|
||||
finality_proof_request_builder: self.finality_proof_request_builder,
|
||||
finality_proof_provider: self.finality_proof_provider,
|
||||
network_protocol: self.network_protocol,
|
||||
transaction_pool: self.transaction_pool,
|
||||
rpc_extensions: self.rpc_extensions,
|
||||
remote_backend: self.remote_backend,
|
||||
dht_event_tx: Some(dht_event_tx),
|
||||
marker: self.marker,
|
||||
})
|
||||
}
|
||||
@@ -761,7 +725,6 @@ ServiceBuilder<
|
||||
transaction_pool,
|
||||
rpc_extensions,
|
||||
remote_backend,
|
||||
dht_event_tx,
|
||||
} = self;
|
||||
|
||||
sp_session::generate_initial_session_keys(
|
||||
@@ -1051,7 +1014,6 @@ ServiceBuilder<
|
||||
network_status_sinks.clone(),
|
||||
system_rpc_rx,
|
||||
has_bootnodes,
|
||||
dht_event_tx,
|
||||
)
|
||||
.map_err(|_| ())
|
||||
.select(exit.clone().map(Ok).compat())
|
||||
|
||||
Reference in New Issue
Block a user