pub fn new(
        config: &Config,
        discover: D,
        demand_signal: mpsc::Sender<MorePeers>,
        handle_rx: tokio::sync::oneshot::Receiver<Vec<JoinHandle<Result<(), BoxError>>>>,
        inv_stream: broadcast::Receiver<(InventoryHash, SocketAddr)>,
        address_metrics: watch::Receiver<AddressMetrics>,
        minimum_peer_version: MinimumPeerVersion<C>,
    ) -> Self {
        Self {
            // Ready peers
            discover,
            ready_services: HashMap::new(),
            preselected_p2c_peer: None,
            inventory_registry: InventoryRegistry::new(inv_stream),

            // Unready peers
            unready_services: FuturesUnordered::new(),
            cancel_handles: HashMap::new(),
            demand_signal,

            // Background tasks
            handle_rx,
            guards: futures::stream::FuturesUnordered::new(),

            // Metrics
            last_peer_log: None,
            address_metrics,
            peerset_total_connection_limit: config.peerset_total_connection_limit(),

            // Real-time parameters
            minimum_peer_version,
        }
    }
/// Construct a peerset which uses `discover` to manage peer connections.
///
/// Arguments:
/// - `config`: configures the peer set connection limit;
/// - `discover`: handles peer connects and disconnects;
/// - `demand_signal`: requests more peers when all peers are busy (unready);
/// - `handle_rx`: receives background task handles,
///                monitors them to make sure they're still running,
///                and shuts down all the tasks as soon as one task exits;
/// - `inv_stream`: receives inventory advertisements for peers,
///                 allowing the peer set to direct inventory requests;
/// - `address_book`: when peer set is busy, it logs address book diagnostics.
Construct a peerset which uses `discover` to manage peer connections.
Construct a peerset which uses ` discover ` to manage peer connections .
pub fn new(
        config: &Config,
        discover: D,
        demand_signal: mpsc::Sender<MorePeers>,
        handle_rx: tokio::sync::oneshot::Receiver<Vec<JoinHandle<Result<(), BoxError>>>>,
        inv_stream: broadcast::Receiver<(InventoryHash, SocketAddr)>,
        address_metrics: watch::Receiver<AddressMetrics>,
        minimum_peer_version: MinimumPeerVersion<C>,
    ) -> Self {
        Self {
            // Ready peers
            discover,
            ready_services: HashMap::new(),
            preselected_p2c_peer: None,
            inventory_registry: InventoryRegistry::new(inv_stream),
            // Unready peers
            unready_services: FuturesUnordered::new(),
            cancel_handles: HashMap::new(),
            demand_signal,
            // Background tasks
            handle_rx,
            guards: futures::stream::FuturesUnordered::new(),
            // Metrics
            last_peer_log: None,
            address_metrics,
            peerset_total_connection_limit: config.peerset_total_connection_limit(),
            // Real-time parameters
            minimum_peer_version,
        }
    }
pub fn new ( config : & Config , discover : D , demand_signal : mpsc :: Sender < MorePeers > , handle_rx : tokio :: sync :: oneshot :: Receiver < Vec < JoinHandle < Result < ( ) , BoxError > > > > , inv_stream : broadcast :: Receiver < ( InventoryHash , SocketAddr ) > , address_metrics : watch :: Receiver < AddressMetrics > , minimum_peer_version : MinimumPeerVersion < C > , ) -> Self { Self { // Ready peers discover , ready_services : HashMap :: new ( ) , preselected_p2c_peer : None , inventory_registry : InventoryRegistry :: new ( inv_stream ) , // Unready peers unready_services : FuturesUnordered :: new ( ) , cancel_handles : HashMap :: new ( ) , demand_signal , // Background tasks handle_rx , guards : futures :: stream :: FuturesUnordered :: new ( ) , // Metrics last_peer_log : None , address_metrics , peerset_total_connection_limit : config . peerset_total_connection_limit ( ) , // Real-time parameters minimum_peer_version , } }
Construct a peerset which uses `discover` to manage peer connections.
Construct a peerset which uses ` discover ` to manage peer connections .
config
&Config
discover
D
demand_signal
mpsc::Sender<MorePeers>
handle_rx
tokio::sync::oneshot::Receiver<Vec<JoinHandle<Result<(), BoxError>>>>
inv_stream
broadcast::Receiver<(InventoryHash, SocketAddr)>
address_metrics
watch::Receiver<AddressMetrics>
minimum_peer_version
MinimumPeerVersion<C>