mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 00:31:07 +00:00
Add ProtocolBehaviour (#2922)
* Add ProtocolBehaviour * Fix tests * Line widths * Address concerns * Apply suggestions from code review Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Remove TODO
This commit is contained in:
committed by
Gavin Wood
parent
48aa32bece
commit
e919d03331
@@ -38,9 +38,13 @@ use futures::sync::mpsc;
|
||||
|
||||
// Type aliases.
|
||||
// These exist mainly to avoid typing `<F as Factory>::Foo` all over the code.
|
||||
/// Network service type for a factory.
|
||||
pub type NetworkService<F> =
|
||||
network::NetworkService<<F as ServiceFactory>::Block, <F as ServiceFactory>::NetworkProtocol>;
|
||||
|
||||
/// Network service type for `Components`.
|
||||
pub type NetworkService<C> = network::NetworkService<
|
||||
ComponentBlock<C>,
|
||||
<<C as Components>::Factory as ServiceFactory>::NetworkProtocol,
|
||||
ComponentExHash<C>
|
||||
>;
|
||||
|
||||
/// Code executor type for a factory.
|
||||
pub type CodeExecutor<F> = NativeExecutor<<F as ServiceFactory>::RuntimeDispatch>;
|
||||
|
||||
@@ -75,7 +75,7 @@ const DEFAULT_PROTOCOL_ID: &str = "sup";
|
||||
pub struct Service<Components: components::Components> {
|
||||
client: Arc<ComponentClient<Components>>,
|
||||
select_chain: Option<<Components as components::Components>::SelectChain>,
|
||||
network: Arc<components::NetworkService<Components::Factory>>,
|
||||
network: Arc<components::NetworkService<Components>>,
|
||||
/// Sinks to propagate network status updates.
|
||||
network_status_sinks: Arc<Mutex<Vec<mpsc::UnboundedSender<NetworkStatus<ComponentBlock<Components>>>>>>,
|
||||
transaction_pool: Arc<TransactionPool<Components::TransactionPoolApi>>,
|
||||
@@ -498,7 +498,7 @@ impl<Components> Service<Components> where Components: components::Components {
|
||||
}
|
||||
|
||||
/// Get shared network instance.
|
||||
pub fn network(&self) -> Arc<components::NetworkService<Components::Factory>> {
|
||||
pub fn network(&self) -> Arc<components::NetworkService<Components>> {
|
||||
self.network.clone()
|
||||
}
|
||||
|
||||
@@ -684,7 +684,7 @@ impl<C: Components> network::TransactionPool<ComponentExHash<C>, ComponentBlock<
|
||||
|
||||
/// Builds a never-ending `Future` that answers the RPC requests coming on the receiver.
|
||||
fn build_system_rpc_handler<Components: components::Components>(
|
||||
network: Arc<NetworkService<Components::Factory>>,
|
||||
network: Arc<NetworkService<Components>>,
|
||||
rx: mpsc::UnboundedReceiver<rpc::apis::system::Request<ComponentBlock<Components>>>,
|
||||
should_have_peers: bool,
|
||||
) -> impl Future<Item = (), Error = ()> {
|
||||
|
||||
Reference in New Issue
Block a user