pub fn from_config(config: PeersetConfig) -> (Peerset, PeersetHandle) {
		let (tx, rx) = mpsc::unbounded();

		let data = PeersetData {
			discovered: Default::default(),
			reserved_only: config.reserved_only,
			out_slots: Slots::new(config.out_peers),
			in_slots: Slots::new(config.in_peers),
			scores: LruCache::new(PEERSET_SCORES_CACHE_SIZE),
		};

		let handle = PeersetHandle {
			tx,
		};

		let mut peerset = Peerset {
			data,
			rx,
			message_queue: VecDeque::new(),
		};

		for peer_id in config.reserved_nodes {
			peerset.data.discovered.add_peer(peer_id, SlotType::Reserved);
		}

		for peer_id in config.bootnodes {
			peerset.data.discovered.add_peer(peer_id, SlotType::Common);
		}

		peerset.alloc_slots();
		(peerset, handle)
	}
/// Builds a new peerset from the given configuration.
Builds a new peerset from the given configuration.
Builds a new peerset from the given configuration .
pub fn from_config(config: PeersetConfig) -> (Peerset, PeersetHandle) {
		let (tx, rx) = mpsc::unbounded();
		let data = PeersetData {
			discovered: Default::default(),
			reserved_only: config.reserved_only,
			out_slots: Slots::new(config.out_peers),
			in_slots: Slots::new(config.in_peers),
			scores: LruCache::new(PEERSET_SCORES_CACHE_SIZE),
		};
		let handle = PeersetHandle {
			tx,
		};
		let mut peerset = Peerset {
			data,
			rx,
			message_queue: VecDeque::new(),
		};
		for peer_id in config.reserved_nodes {
			peerset.data.discovered.add_peer(peer_id, SlotType::Reserved);
		}
		for peer_id in config.bootnodes {
			peerset.data.discovered.add_peer(peer_id, SlotType::Common);
		}
		peerset.alloc_slots();
		(peerset, handle)
	}
pub fn from_config ( config : PeersetConfig ) -> ( Peerset , PeersetHandle ) { let ( tx , rx ) = mpsc :: unbounded ( ) ; let data = PeersetData { discovered : Default :: default ( ) , reserved_only : config . reserved_only , out_slots : Slots :: new ( config . out_peers ) , in_slots : Slots :: new ( config . in_peers ) , scores : LruCache :: new ( PEERSET_SCORES_CACHE_SIZE ) , } ; let handle = PeersetHandle { tx , } ; let mut peerset = Peerset { data , rx , message_queue : VecDeque :: new ( ) , } ; for peer_id in config . reserved_nodes { peerset . data . discovered . add_peer ( peer_id , SlotType :: Reserved ) ; } for peer_id in config . bootnodes { peerset . data . discovered . add_peer ( peer_id , SlotType :: Common ) ; } peerset . alloc_slots ( ) ; ( peerset , handle ) }
Builds a new peerset from the given configuration.
Builds a new peerset from the given configuration .
config
PeersetConfig
config
PeersetConfig