Skip to content

Commit 430e19a

Browse files
refactor(iroh): remove iroh-blobs
1 parent 4090f38 commit 430e19a

File tree

14 files changed

+48
-1553
lines changed

14 files changed

+48
-1553
lines changed

Cargo.lock

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

iroh-cli/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use clap::Parser;
66
mod commands;
77
mod config;
88
mod logging;
9+
mod progress;
910

1011
use crate::commands::Cli;
1112

File renamed without changes.

iroh/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ genawaiter = { version = "0.99", default-features = false, features = [
3737
"futures03",
3838
] }
3939
hex = { version = "0.4.3" }
40-
iroh-blobs = { version = "0.28.0", features = ["downloader"] }
4140
iroh-base = { version = "0.28.0", features = ["key"] }
4241
iroh-io = { version = "0.6.0", features = ["stats"] }
4342
iroh-metrics = { version = "0.28.0", optional = true }
@@ -81,8 +80,8 @@ serde-error = "0.1.3"
8180

8281
[features]
8382
default = ["metrics", "fs-store"]
84-
metrics = ["iroh-metrics", "iroh-blobs/metrics"]
85-
fs-store = ["iroh-blobs/fs-store"]
83+
metrics = ["iroh-metrics"]
84+
fs-store = []
8685
test = []
8786
examples = ["dep:clap", "dep:indicatif"]
8887
discovery-local-network = [

iroh/src/client.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ pub use crate::rpc_protocol::RpcService;
1414

1515
mod quic;
1616

17-
pub use iroh_blobs::rpc::client::{blobs, tags};
18-
1917
pub use self::net::NodeStatus;
2018
pub(crate) use self::quic::{connect_raw as quic_connect_raw, RPC_ALPN};
2119
pub mod net;
@@ -57,16 +55,6 @@ impl Iroh {
5755
self.rpc.clone()
5856
}
5957

60-
/// Returns the blobs client.
61-
pub fn blobs(&self) -> blobs::Client {
62-
blobs::Client::new(self.rpc.clone().map().boxed())
63-
}
64-
65-
/// Returns the tags client.
66-
pub fn tags(&self) -> tags::Client {
67-
tags::Client::new(self.rpc.clone().map().boxed())
68-
}
69-
7058
/// Returns the net client.
7159
pub fn net(&self) -> &net::Client {
7260
net::Client::ref_cast(&self.rpc)

iroh/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@
9191
#[doc(inline)]
9292
pub use iroh_base as base;
9393
#[doc(inline)]
94-
pub use iroh_blobs as blobs;
95-
#[doc(inline)]
9694
pub use iroh_net as net;
9795
#[doc(inline)]
9896
pub use iroh_router as router;

iroh/src/node.rs

Lines changed: 15 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
use std::{
3939
collections::BTreeSet,
4040
fmt::Debug,
41-
marker::PhantomData,
4241
net::SocketAddr,
4342
path::{Path, PathBuf},
4443
sync::Arc,
@@ -49,11 +48,6 @@ use anyhow::{anyhow, Result};
4948
use futures_lite::StreamExt;
5049
use futures_util::future::{MapErr, Shared};
5150
use iroh_base::key::PublicKey;
52-
use iroh_blobs::{
53-
net_protocol::Blobs as BlobsProtocol,
54-
store::Store as BaoStore,
55-
util::local_pool::{LocalPool, LocalPoolHandle},
56-
};
5751
use iroh_net::{
5852
endpoint::{DirectAddrsStream, RemoteInfo},
5953
AddrInfo, Endpoint, NodeAddr,
@@ -73,9 +67,7 @@ mod rpc_status;
7367

7468
pub(crate) use self::rpc::RpcResult;
7569
pub use self::{
76-
builder::{
77-
Builder, DiscoveryConfig, GcPolicy, ProtocolBuilder, StorageConfig, DEFAULT_RPC_ADDR,
78-
},
70+
builder::{Builder, DiscoveryConfig, ProtocolBuilder, StorageConfig, DEFAULT_RPC_ADDR},
7971
rpc_status::RpcStatus,
8072
};
8173

@@ -101,8 +93,8 @@ pub type IrohServerEndpoint = quic_rpc::transport::boxed::BoxedListener<
10193
/// await the [`Node`] struct directly, it will complete when the task completes. If
10294
/// this is dropped the node task is not stopped but keeps running.
10395
#[derive(Debug, Clone)]
104-
pub struct Node<D> {
105-
inner: Arc<NodeInner<D>>,
96+
pub struct Node {
97+
inner: Arc<NodeInner>,
10698
// `Node` needs to be `Clone + Send`, and we need to `task.await` in its `shutdown()` impl.
10799
// So we need
108100
// - `Shared` so we can `task.await` from all `Node` clones
@@ -116,43 +108,37 @@ pub struct Node<D> {
116108
pub(crate) type JoinErrToStr = Box<dyn Fn(JoinError) -> String + Send + Sync + 'static>;
117109

118110
#[derive(derive_more::Debug)]
119-
struct NodeInner<D> {
120-
db: PhantomData<D>,
111+
struct NodeInner {
121112
rpc_addr: Option<SocketAddr>,
122113
endpoint: Endpoint,
123114
cancel_token: CancellationToken,
124115
client: crate::client::Iroh,
125-
local_pool_handle: LocalPoolHandle,
126116
}
127117

128118
/// In memory node.
129-
pub type MemNode = Node<iroh_blobs::store::mem::Store>;
119+
#[deprecated]
120+
pub type MemNode = Node;
130121

131122
/// Persistent node.
132-
pub type FsNode = Node<iroh_blobs::store::fs::Store>;
123+
#[deprecated]
124+
pub type FsNode = Node;
133125

134-
impl MemNode {
126+
impl Node {
135127
/// Returns a new builder for the [`Node`], by default configured to run in memory.
136128
///
137129
/// Once done with the builder call [`Builder::spawn`] to create the node.
138-
pub fn memory() -> Builder<iroh_blobs::store::mem::Store> {
139-
Builder::default()
130+
pub fn memory() -> Builder {
131+
Builder::memory()
140132
}
141-
}
142133

143-
impl FsNode {
144134
/// Returns a new builder for the [`Node`], configured to persist all data
145135
/// from the given path.
146136
///
147137
/// Once done with the builder call [`Builder::spawn`] to create the node.
148-
pub async fn persistent(
149-
root: impl AsRef<Path>,
150-
) -> Result<Builder<iroh_blobs::store::fs::Store>> {
151-
Builder::default().persist(root).await
138+
pub async fn persistent(root: impl AsRef<Path>) -> Result<Builder> {
139+
Builder::memory().persist(root).await
152140
}
153-
}
154141

155-
impl<D: BaoStore> Node<D> {
156142
/// Returns the [`Endpoint`] of the node.
157143
///
158144
/// This can be used to establish connections to other nodes under any
@@ -196,11 +182,6 @@ impl<D: BaoStore> Node<D> {
196182
&self.inner.client
197183
}
198184

199-
/// Returns a reference to the used `LocalPoolHandle`.
200-
pub fn local_pool_handle(&self) -> &LocalPoolHandle {
201-
&self.inner.local_pool_handle
202-
}
203-
204185
/// Get the relay server we are connected to.
205186
pub fn home_relay(&self) -> Option<iroh_net::RelayUrl> {
206187
self.inner.endpoint.home_relay()
@@ -243,15 +224,15 @@ impl<D: BaoStore> Node<D> {
243224
}
244225
}
245226

246-
impl<D> std::ops::Deref for Node<D> {
227+
impl std::ops::Deref for Node {
247228
type Target = crate::client::Iroh;
248229

249230
fn deref(&self) -> &Self::Target {
250231
&self.inner.client
251232
}
252233
}
253234

254-
impl<D: iroh_blobs::store::Store> NodeInner<D> {
235+
impl NodeInner {
255236
async fn local_endpoint_addresses(&self) -> Result<Vec<SocketAddr>> {
256237
let endpoints = self
257238
.endpoint
@@ -268,10 +249,7 @@ impl<D: iroh_blobs::store::Store> NodeInner<D> {
268249
external_rpc: IrohServerEndpoint,
269250
internal_rpc: IrohServerEndpoint,
270251
router: Router,
271-
gc_policy: GcPolicy,
272-
gc_done_callback: Option<Box<dyn Fn() + Send>>,
273252
nodes_data_path: Option<PathBuf>,
274-
local_pool: LocalPool,
275253
) {
276254
let (ipv4, ipv6) = self.endpoint.bound_sockets();
277255
debug!(
@@ -287,37 +265,6 @@ impl<D: iroh_blobs::store::Store> NodeInner<D> {
287265
let external_rpc = RpcServer::new(external_rpc);
288266
let internal_rpc = RpcServer::new(internal_rpc);
289267

290-
// Spawn a task for the garbage collection.
291-
if let GcPolicy::Interval(gc_period) = gc_policy {
292-
let router = router.clone();
293-
let handle = local_pool.spawn(move || async move {
294-
let blobs = router
295-
.get_protocol::<BlobsProtocol<D>>(iroh_blobs::protocol::ALPN)
296-
.expect("missing blobs");
297-
298-
blobs
299-
.store()
300-
.gc_run(
301-
iroh_blobs::store::GcConfig {
302-
period: gc_period,
303-
done_callback: gc_done_callback,
304-
},
305-
|| async move { BTreeSet::default() },
306-
)
307-
.await;
308-
});
309-
// We cannot spawn tasks that run on the local pool directly into the join set,
310-
// so instead we create a new task that supervises the local task.
311-
join_set.spawn({
312-
async move {
313-
if let Err(err) = handle.await {
314-
return Err(anyhow::Error::from(err));
315-
}
316-
Ok(())
317-
}
318-
});
319-
}
320-
321268
if let Some(nodes_data_path) = nodes_data_path {
322269
let ep = self.endpoint.clone();
323270
let token = self.cancel_token.clone();
@@ -419,7 +366,6 @@ impl<D: iroh_blobs::store::Store> NodeInner<D> {
419366

420367
// Abort remaining local tasks.
421368
tracing::info!("Shutting down local pool");
422-
local_pool.shutdown().await;
423369
}
424370
}
425371

0 commit comments

Comments
 (0)