Function zebra_network::peer_set::initialize::crawl_and_dial
source ยท async fn crawl_and_dial<C, S>(
config: Config,
demand_tx: Sender<MorePeers>,
demand_rx: Receiver<MorePeers>,
candidates: CandidateSet<S>,
outbound_connector: C,
peerset_tx: Sender<(PeerSocketAddr, Client)>,
active_outbound_connections: ActiveConnectionCounter,
address_book_updater: Sender<MetaAddrChange>,
) -> Result<(), BoxError>
Expand description
Given a channel demand_rx
that signals a need for new peers, try to find
and connect to new peers, and send the resulting peer::Client
s through the
peerset_tx
channel.
Crawl for new peers every config.crawl_new_peer_interval
.
Also crawl whenever there is demand, but no new peers in candidates
.
After crawling, try to connect to one new peer using outbound_connector
.
If a handshake fails, restore the unused demand signal by sending it to
demand_tx
.
The crawler terminates when candidates.update()
or peerset_tx
returns a
permanent internal error. Transient errors and individual peer errors should
be handled within the crawler.
Uses active_outbound_connections
to limit the number of active outbound connections
across both the initial peers and crawler. The limit is based on config
.