@@ -28,44 +28,6 @@ use crate::{
2828 HashAndFormat , TempTag ,
2929} ;
3030
31- #[ derive( Debug , PartialEq , Eq , PartialOrd , Serialize , Deserialize , Ord , Clone , Copy , Hash ) ]
32- pub struct BatchId ( u64 ) ;
33-
34- /// A request to the node to download and share the data specified by the hash.
35- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
36- pub struct BlobDownloadRequest {
37- /// This mandatory field contains the hash of the data to download and share.
38- pub hash : Hash ,
39- /// If the format is [`BlobFormat::HashSeq`], all children are downloaded and shared as
40- /// well.
41- pub format : BlobFormat ,
42- /// This mandatory field specifies the nodes to download the data from.
43- ///
44- /// If set to more than a single node, they will all be tried. If `mode` is set to
45- /// [`DownloadMode::Direct`], they will be tried sequentially until a download succeeds.
46- /// If `mode` is set to [`DownloadMode::Queued`], the nodes may be dialed in parallel,
47- /// if the concurrency limits permit.
48- pub nodes : Vec < NodeAddr > ,
49- /// Optional tag to tag the data with.
50- pub tag : SetTagOption ,
51- /// Whether to directly start the download or add it to the download queue.
52- pub mode : DownloadMode ,
53- }
54-
55- /// Set the mode for whether to directly start the download or add it to the download queue.
56- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
57- pub enum DownloadMode {
58- /// Start the download right away.
59- ///
60- /// No concurrency limits or queuing will be applied. It is up to the user to manage download
61- /// concurrency.
62- Direct ,
63- /// Queue the download.
64- ///
65- /// The download queue will be processed in-order, while respecting the downloader concurrency limits.
66- Queued ,
67- }
68-
6931#[ derive( Debug ) ]
7032pub struct Blobs < S > {
7133 rt : LocalPoolHandle ,
@@ -81,7 +43,7 @@ const BLOB_DOWNLOAD_SOURCE_NAME: &str = "blob_download";
8143
8244/// Keeps track of all the currently active batch operations of the blobs api.
8345#[ derive( Debug , Default ) ]
84- pub struct BlobBatches {
46+ pub ( crate ) struct BlobBatches {
8547 /// Currently active batches
8648 batches : BTreeMap < BatchId , BlobBatch > ,
8749 /// Used to generate new batch ids.
@@ -152,19 +114,19 @@ impl<S: crate::store::Store> Blobs<S> {
152114 & self . store
153115 }
154116
155- pub ( crate ) fn rt ( & self ) -> LocalPoolHandle {
156- self . rt . clone ( )
117+ pub fn rt ( & self ) -> & LocalPoolHandle {
118+ & self . rt
157119 }
158120
159- pub ( crate ) fn endpoint ( & self ) -> & Endpoint {
121+ pub fn endpoint ( & self ) -> & Endpoint {
160122 & self . endpoint
161123 }
162124
163- pub async fn batches ( & self ) -> tokio:: sync:: MutexGuard < ' _ , BlobBatches > {
125+ pub ( crate ) async fn batches ( & self ) -> tokio:: sync:: MutexGuard < ' _ , BlobBatches > {
164126 self . batches . lock ( ) . await
165127 }
166128
167- pub async fn download (
129+ pub ( crate ) async fn download (
168130 & self ,
169131 endpoint : Endpoint ,
170132 req : BlobDownloadRequest ,
@@ -318,3 +280,42 @@ impl<S: crate::store::Store> ProtocolHandler for Blobs<S> {
318280 } )
319281 }
320282}
283+
284+ /// A request to the node to download and share the data specified by the hash.
285+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
286+ pub struct BlobDownloadRequest {
287+ /// This mandatory field contains the hash of the data to download and share.
288+ pub hash : Hash ,
289+ /// If the format is [`BlobFormat::HashSeq`], all children are downloaded and shared as
290+ /// well.
291+ pub format : BlobFormat ,
292+ /// This mandatory field specifies the nodes to download the data from.
293+ ///
294+ /// If set to more than a single node, they will all be tried. If `mode` is set to
295+ /// [`DownloadMode::Direct`], they will be tried sequentially until a download succeeds.
296+ /// If `mode` is set to [`DownloadMode::Queued`], the nodes may be dialed in parallel,
297+ /// if the concurrency limits permit.
298+ pub nodes : Vec < NodeAddr > ,
299+ /// Optional tag to tag the data with.
300+ pub tag : SetTagOption ,
301+ /// Whether to directly start the download or add it to the download queue.
302+ pub mode : DownloadMode ,
303+ }
304+
305+ /// Set the mode for whether to directly start the download or add it to the download queue.
306+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
307+ pub enum DownloadMode {
308+ /// Start the download right away.
309+ ///
310+ /// No concurrency limits or queuing will be applied. It is up to the user to manage download
311+ /// concurrency.
312+ Direct ,
313+ /// Queue the download.
314+ ///
315+ /// The download queue will be processed in-order, while respecting the downloader concurrency limits.
316+ Queued ,
317+ }
318+
319+ /// Newtype for a batch id
320+ #[ derive( Debug , PartialEq , Eq , PartialOrd , Serialize , Deserialize , Ord , Clone , Copy , Hash ) ]
321+ pub struct BatchId ( pub u64 ) ;
0 commit comments