/// The method starts downloading a chunk of the highest-priority
/// artifact in the request queue if sufficient bandwidth is
/// available.
///
/// The method looks at the adverts queue for the given peer i and
/// retrieves the highest-priority advert that is not already
/// being downloaded from other peers more times in parallel than
/// the maximum duplicity and for which there is room to store the
/// corresponding artifact in the unvalidated artifact pool of
/// peer i. If such an advert is found, the node adds a tracker
/// for the advert to the requested queue of peer i, and sends a
/// chunk requests for the corresponding artifact.
///
/// The node also sets a download timeout for this chunk request
/// with a duration that is appropriate for the size of the chunk.
/// Periodically, the node iterates over the requested chunks and
/// checks timed-out requests. The timed-out requests are removed
/// from the requested queue of this peer and a history of such
/// time-outs is retained.  Future download_next(i) calls take the
/// download time-out history into account, de-prioritizing the
/// request for peers that timed out in the past.
///
/// This is a security requirement because in case no duplicity is
/// allowed, a bad peer could otherwise maintain a "monopoly" on
/// providing the node with a particular artifact and prevent the
/// node from ever receiving it.
The method starts downloading a chunk of the highest-priority
artifact in the request queue if sufficient bandwidth is
available.

The method looks at the adverts queue for the given peer i and
retrieves the highest-priority advert that is not already
being downloaded from other peers more times in parallel than
the maximum duplicity and for which there is room to store the
corresponding artifact in the unvalidated artifact pool of
peer i. If such an advert is found, the node adds a tracker
for the advert to the requested queue of peer i, and sends a
chunk requests for the corresponding artifact.

The node also sets a download timeout for this chunk request
with a duration that is appropriate for the size of the chunk.
Periodically, the node iterates over the requested chunks and
checks timed-out requests. The timed-out requests are removed
from the requested queue of this peer and a history of such
time-outs is retained.  Future download_next(i) calls take the
download time-out history into account, de-prioritizing the
request for peers that timed out in the past.

This is a security requirement because in case no duplicity is
allowed, a bad peer could otherwise maintain a "monopoly" on
providing the node with a particular artifact and prevent the
node from ever receiving it.
The method starts downloading a chunk of the highest - priority artifact in the request queue if sufficient bandwidth is available . The method looks at the adverts queue for the given peer i and retrieves the highest - priority advert that is not already being downloaded from other peers more times in parallel than the maximum duplicity and for which there is room to store the corresponding artifact in the unvalidated artifact pool of peer i . If such an advert is found the node adds a tracker for the advert to the requested queue of peer i and sends a chunk requests for the corresponding artifact . The node also sets a download timeout for this chunk request with a duration that is appropriate for the size of the chunk . Periodically the node iterates over the requested chunks and checks timed - out requests . The timed - out requests are removed from the requested queue of this peer and a history of such time - outs is retained . Future download_next ( i ) calls take the download time - out history into account de - prioritizing the request for peers that timed out in the past . This is a security requirement because in case no duplicity is allowed a bad peer could otherwise maintain a " monopoly " on providing the node with a particular artifact and prevent the node from ever receiving it .
fn download_next(&self, peer_id: NodeId) -> Result<(), Box<dyn Error>> {
        self.metrics.download_next_calls.inc();
        let start_time = Instant::now();
        let gossip_requests = self.download_next_compute_work(peer_id)?;
        self.metrics
            .download_next_time
            .set(start_time.elapsed().as_micros() as i64);
        self.send_chunk_requests(gossip_requests, peer_id);
        Ok(())
    }
fn download_next ( & self , peer_id : NodeId ) -> Result < ( ) , Box < dyn Error > > { self . metrics . download_next_calls . inc ( ) ; let start_time = Instant :: now ( ) ; let gossip_requests = self . download_next_compute_work ( peer_id ) ? ; self . metrics . download_next_time . set ( start_time . elapsed ( ) . as_micros ( ) as i64 ) ; self . send_chunk_requests ( gossip_requests , peer_id ) ; Ok ( ( ) ) }
The method starts downloading a chunk of the highest-priority
artifact in the request queue if sufficient bandwidth is
available.
The method starts downloading a chunk of the highest - priority artifact in the request queue if sufficient bandwidth is available .
&self
peer_id
NodeId