Skip to content

Commit b4b51cc

Browse files
refactor(iroh): move blobs protocol to iroh-blobs
Depends on n0-computer/iroh-blobs#6
1 parent 86b494a commit b4b51cc

File tree

11 files changed

+23
-332
lines changed

11 files changed

+23
-332
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ iroh-metrics = { path = "./iroh-metrics" }
5252
iroh-test = { path = "./iroh-test" }
5353
iroh-router = { path = "./iroh-router" }
5454

55-
iroh-blobs = { git = "https://github.com/n0-computer/iroh-blobs", branch = "main" }
55+
iroh-blobs = { git = "https://github.com/n0-computer/iroh-blobs", branch = "refactor-blobs-protocol" }
5656
iroh-gossip = { git = "https://github.com/n0-computer/iroh-gossip", branch = "main" }

iroh/src/client/blobs.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ use futures_lite::{Stream, StreamExt};
7474
use futures_util::SinkExt;
7575
use genawaiter::sync::{Co, Gen};
7676
use iroh_base::{node_addr::AddrInfoOptions, ticket::BlobTicket};
77+
pub use iroh_blobs::net_protocol::DownloadMode;
7778
use iroh_blobs::{
7879
export::ExportProgress as BytesExportProgress,
7980
format::collection::{Collection, SimpleStore},
8081
get::db::DownloadProgress as BytesDownloadProgress,
82+
net_protocol::BlobDownloadRequest,
8183
store::{BaoBlobSize, ConsistencyCheckProgress, ExportFormat, ExportMode, ValidateProgress},
8284
util::SetTagOption,
8385
BlobFormat, Hash, Tag,
@@ -90,6 +92,7 @@ use serde::{Deserialize, Serialize};
9092
use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf};
9193
use tokio_util::io::{ReaderStream, StreamReader};
9294
use tracing::warn;
95+
9396
mod batch;
9497
pub use batch::{AddDirOpts, AddFileOpts, AddReaderOpts, Batch};
9598

@@ -98,8 +101,8 @@ use crate::rpc_protocol::{
98101
blobs::{
99102
AddPathRequest, AddStreamRequest, AddStreamUpdate, BatchCreateRequest, BatchCreateResponse,
100103
BlobStatusRequest, ConsistencyCheckRequest, CreateCollectionRequest,
101-
CreateCollectionResponse, DeleteRequest, DownloadRequest, ExportRequest,
102-
ListIncompleteRequest, ListRequest, ReadAtRequest, ReadAtResponse, ValidateRequest,
104+
CreateCollectionResponse, DeleteRequest, ExportRequest, ListIncompleteRequest, ListRequest,
105+
ReadAtRequest, ReadAtResponse, ValidateRequest,
103106
},
104107
node::StatusRequest,
105108
};
@@ -357,7 +360,7 @@ impl Client {
357360
} = opts;
358361
let stream = self
359362
.rpc
360-
.server_streaming(DownloadRequest {
363+
.server_streaming(BlobDownloadRequest {
361364
hash,
362365
format,
363366
nodes,
@@ -980,20 +983,6 @@ pub struct DownloadOptions {
980983
pub mode: DownloadMode,
981984
}
982985

983-
/// Set the mode for whether to directly start the download or add it to the download queue.
984-
#[derive(Debug, Clone, Serialize, Deserialize)]
985-
pub enum DownloadMode {
986-
/// Start the download right away.
987-
///
988-
/// No concurrency limits or queuing will be applied. It is up to the user to manage download
989-
/// concurrency.
990-
Direct,
991-
/// Queue the download.
992-
///
993-
/// The download queue will be processed in-order, while respecting the downloader concurrency limits.
994-
Queued,
995-
}
996-
997986
#[cfg(test)]
998987
mod tests {
999988
use iroh_blobs::hashseq::HashSeq;

iroh/src/client/blobs/batch.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use futures_lite::StreamExt;
1111
use futures_util::{sink::Buffer, FutureExt, SinkExt, Stream};
1212
use iroh_blobs::{
1313
format::collection::Collection,
14+
net_protocol::BatchId,
1415
provider::BatchAddPathProgress,
1516
store::ImportMode,
1617
util::{SetTagOption, TagDrop},
@@ -27,7 +28,7 @@ use crate::{
2728
rpc_protocol::{
2829
blobs::{
2930
BatchAddPathRequest, BatchAddStreamRequest, BatchAddStreamResponse,
30-
BatchAddStreamUpdate, BatchCreateTempTagRequest, BatchId, BatchUpdate,
31+
BatchAddStreamUpdate, BatchCreateTempTagRequest, BatchUpdate,
3132
},
3233
tags::{self, SyncMode},
3334
},

iroh/src/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ use futures_lite::StreamExt;
5050
use futures_util::future::{MapErr, Shared};
5151
use iroh_base::key::PublicKey;
5252
use iroh_blobs::{
53+
net_protocol::Blobs as BlobsProtocol,
5354
store::Store as BaoStore,
5455
util::local_pool::{LocalPool, LocalPoolHandle},
5556
};
@@ -59,7 +60,6 @@ use iroh_net::{
5960
AddrInfo, Endpoint, NodeAddr,
6061
};
6162
use iroh_router::{ProtocolHandler, Router};
62-
use protocol::blobs::BlobsProtocol;
6363
use quic_rpc::{transport::ServerEndpoint as _, RpcServer};
6464
use tokio::task::{JoinError, JoinSet};
6565
use tokio_util::{sync::CancellationToken, task::AbortOnDropHandle};

iroh/src/node/builder.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use futures_util::{FutureExt as _, TryFutureExt as _};
1111
use iroh_base::key::SecretKey;
1212
use iroh_blobs::{
1313
downloader::Downloader,
14+
net_protocol::Blobs as BlobsProtocol,
1415
provider::EventSender,
1516
store::{Map, Store as BaoStore},
1617
util::local_pool::{self, LocalPool, LocalPoolHandle, PanicMode},
@@ -36,10 +37,7 @@ use tracing::{debug, error_span, trace, Instrument};
3637
use super::{rpc_status::RpcStatus, IrohServerEndpoint, JoinErrToStr, Node, NodeInner};
3738
use crate::{
3839
client::RPC_ALPN,
39-
node::{
40-
nodes_storage::load_node_addrs,
41-
protocol::{blobs::BlobsProtocol, docs::DocsProtocol},
42-
},
40+
node::{nodes_storage::load_node_addrs, protocol::docs::DocsProtocol},
4341
rpc_protocol::RpcService,
4442
util::{fs::load_secret_key, path::IrohPaths},
4543
};

iroh/src/node/protocol.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
pub(crate) mod blobs;
21
pub(crate) mod docs;

0 commit comments

Comments
 (0)