Module iroh_blobs::downloader
source · Available on crate feature
downloader
only.Expand description
Handle downloading blobs and collections concurrently and from nodes.
The Downloader
interacts with four main components to this end.
Dialer
: Used to queue opening connections to nodes we need to perform downloads.ProviderMap
: Where the downloader obtains information about nodes that could be used to perform a download.Store
: Where data is stored.
Once a download request is received, the logic is as follows:
- The
ProviderMap
is queried for nodes. From these nodes some are selected prioritizing connected nodes with lower number of active requests. If no useful node is connected, or useful connected nodes have no capacity to perform the request, a connection attempt is started using theDialer
. - The download is queued for processing at a later time. Downloads are not performed right away. Instead, they are initially delayed to allow the node to obtain the data itself, and to wait for the new connection to be established if necessary.
- Once a request is ready to be sent after a delay (initial or for a retry), the preferred node is used if available. The request is now considered active.
Concurrency is limited in different ways:
- Total number of active request: This is a way to prevent a self DoS by overwhelming our own bandwidth capacity. This is a best effort heuristic since it doesn’t take into account how much data we are actually requesting or receiving.
- Total number of connected nodes: Peer connections are kept for a longer time than they are strictly needed since it’s likely they will be useful soon again.
- Requests per node: to avoid overwhelming nodes with requests, the number of concurrent requests to a single node is also limited.
Structs§
- Concurrency limits for the
Downloader
. - Handle to interact with a download request.
- The kind of resource to download.
- A download request.
- Handle for the download services.
- Identifier for a download intent.
- Configuration for retry behavior of the
Downloader
.
Enums§
- Error returned when a download could not be completed.
- Signals what should be done with the request when it fails.
- Output returned from
Getter::get
.
Traits§
- Trait modeling a dialer. This allows for IO-less testing.
- Trait modelling performing a single request over a connection. This allows for IO-less testing.
- Trait modelling the intermediary state when a connection is needed to proceed.