pub fn new<H: ExHashT>(
		params: Params<B, S, H>,
		protocol_id: ProtocolId,
		import_queue: Box<ImportQueue<B>>,
	) -> Result<(Arc<Service<B, S>>, NetworkChan<B>), Error> {
		let (network_chan, network_port) = network_channel();
		let status_sinks = Arc::new(Mutex::new(Vec::new()));
		// Start in off-line mode, since we're not connected to any nodes yet.
		let is_offline = Arc::new(AtomicBool::new(true));
		let is_major_syncing = Arc::new(AtomicBool::new(false));
		let peers: Arc<RwLock<HashMap<PeerId, ConnectedPeer<B>>>> = Arc::new(Default::default());
		let (protocol_sender, network_to_protocol_sender) = Protocol::new(
			status_sinks.clone(),
			is_offline.clone(),
			is_major_syncing.clone(),
			peers.clone(),
			network_chan.clone(),
			params.config,
			params.chain,
			import_queue.clone(),
			params.on_demand,
			params.transaction_pool,
			params.specialization,
		)?;
		let versions = [(protocol::CURRENT_VERSION as u8)];
		let registered = RegisteredProtocol::new(protocol_id, &versions[..]);
		let (thread, network, peerset) = start_thread(
			network_to_protocol_sender,
			network_port,
			params.network_config,
			registered,
		)?;

		let service = Arc::new(Service {
			status_sinks,
			is_offline,
			is_major_syncing,
			peers,
			peerset,
			network,
			protocol_sender: protocol_sender.clone(),
			bg_thread: Some(thread),
		});

		// connect the import-queue to the network service.
		let link = NetworkLink {
			protocol_sender,
			network_sender: network_chan.clone(),
		};

		import_queue.start(Box::new(link))?;

		Ok((service, network_chan))
	}
/// Creates and register protocol with the network service
Creates and register protocol with the network service
Creates and register protocol with the network service
pub fn new<H: ExHashT>(
		params: Params<B, S, H>,
		protocol_id: ProtocolId,
		import_queue: Box<ImportQueue<B>>,
	) -> Result<(Arc<Service<B, S>>, NetworkChan<B>), Error> {
		let (network_chan, network_port) = network_channel();
		let status_sinks = Arc::new(Mutex::new(Vec::new()));
		// Start in off-line mode, since we're not connected to any nodes yet.
		let is_offline = Arc::new(AtomicBool::new(true));
		let is_major_syncing = Arc::new(AtomicBool::new(false));
		let peers: Arc<RwLock<HashMap<PeerId, ConnectedPeer<B>>>> = Arc::new(Default::default());
		let (protocol_sender, network_to_protocol_sender) = Protocol::new(
			status_sinks.clone(),
			is_offline.clone(),
			is_major_syncing.clone(),
			peers.clone(),
			network_chan.clone(),
			params.config,
			params.chain,
			import_queue.clone(),
			params.on_demand,
			params.transaction_pool,
			params.specialization,
		)?;
		let versions = [(protocol::CURRENT_VERSION as u8)];
		let registered = RegisteredProtocol::new(protocol_id, &versions[..]);
		let (thread, network, peerset) = start_thread(
			network_to_protocol_sender,
			network_port,
			params.network_config,
			registered,
		)?;
		let service = Arc::new(Service {
			status_sinks,
			is_offline,
			is_major_syncing,
			peers,
			peerset,
			network,
			protocol_sender: protocol_sender.clone(),
			bg_thread: Some(thread),
		});
		// connect the import-queue to the network service.
		let link = NetworkLink {
			protocol_sender,
			network_sender: network_chan.clone(),
		};
		import_queue.start(Box::new(link))?;
		Ok((service, network_chan))
	}
pub fn new < H : ExHashT > ( params : Params < B , S , H > , protocol_id : ProtocolId , import_queue : Box < ImportQueue < B > > , ) -> Result < ( Arc < Service < B , S > > , NetworkChan < B > ) , Error > { let ( network_chan , network_port ) = network_channel ( ) ; let status_sinks = Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ; // Start in off-line mode, since we're not connected to any nodes yet. let is_offline = Arc :: new ( AtomicBool :: new ( true ) ) ; let is_major_syncing = Arc :: new ( AtomicBool :: new ( false ) ) ; let peers : Arc < RwLock < HashMap < PeerId , ConnectedPeer < B > > > > = Arc :: new ( Default :: default ( ) ) ; let ( protocol_sender , network_to_protocol_sender ) = Protocol :: new ( status_sinks . clone ( ) , is_offline . clone ( ) , is_major_syncing . clone ( ) , peers . clone ( ) , network_chan . clone ( ) , params . config , params . chain , import_queue . clone ( ) , params . on_demand , params . transaction_pool , params . specialization , ) ? ; let versions = [ ( protocol :: CURRENT_VERSION as u8 ) ] ; let registered = RegisteredProtocol :: new ( protocol_id , & versions [ .. ] ) ; let ( thread , network , peerset ) = start_thread ( network_to_protocol_sender , network_port , params . network_config , registered , ) ? ; let service = Arc :: new ( Service { status_sinks , is_offline , is_major_syncing , peers , peerset , network , protocol_sender : protocol_sender . clone ( ) , bg_thread : Some ( thread ) , } ) ; // connect the import-queue to the network service. let link = NetworkLink { protocol_sender , network_sender : network_chan . clone ( ) , } ; import_queue . start ( Box :: new ( link ) ) ? ; Ok ( ( service , network_chan ) ) }
Creates and register protocol with the network service
Creates and register protocol with the network service
params
Params<B, S, H>
protocol_id
ProtocolId
import_queue
Box<ImportQueue<B>>
params
Params<B, S, H>
protocol_id
ProtocolId
import_queue
Box<ImportQueue<B>>