Skip to content

Commit

Permalink
use blobs client directly
Browse files Browse the repository at this point in the history
  • Loading branch information
rklaehn committed Nov 21, 2024
1 parent 53c6733 commit 5de0a19
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/rpc/client/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ mod tests {
}

// check that "temp" tags have been deleted
let tags: Vec<_> = node.tags().list().await?.try_collect().await?;
let tags: Vec<_> = node.blobs().tags().list().await?.try_collect().await?;
assert_eq!(tags.len(), 1);
assert_eq!(tags[0].hash, hash);
assert_eq!(tags[0].name, tag);
Expand Down
28 changes: 6 additions & 22 deletions src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,22 @@ use std::{path::Path, sync::Arc};

use iroh_net::{Endpoint, NodeAddr, NodeId};
use iroh_router::Router;
use tokio_util::task::AbortOnDropHandle;

use crate::{
downloader::Downloader,
net_protocol::Blobs,
provider::{CustomEventSender, EventSender},
rpc::{
client::{blobs, tags},
proto::RpcService,
},
rpc::client::blobs,
util::local_pool::LocalPool,
};

type RpcClient = quic_rpc::RpcClient<RpcService>;

/// An iroh node that just has the blobs transport
#[derive(Debug)]

pub struct Node {
router: iroh_router::Router,
client: RpcClient,
client: blobs::MemClient,
_local_pool: LocalPool,
_rpc_task: AbortOnDropHandle<()>,
}

/// An iroh node builder
Expand Down Expand Up @@ -80,15 +74,10 @@ impl<S: crate::store::Store> Builder<S> {
let router = router.spawn().await?;

// Setup RPC
let (internal_rpc, controller) = quic_rpc::transport::flume::channel(32);
let internal_rpc = quic_rpc::RpcServer::new(internal_rpc).boxed();
let _rpc_task = internal_rpc
.spawn_accept_loop(move |msg, chan| blobs.clone().handle_rpc_request(msg, chan));
let client = quic_rpc::RpcClient::new(controller).boxed();
let client = blobs.client();
Ok(Node {
router,
client,
_rpc_task,
_local_pool: local_pool,
})
}
Expand Down Expand Up @@ -136,12 +125,7 @@ impl Node {
}

/// Returns an in-memory blobs client
pub fn blobs(&self) -> blobs::Client {
blobs::Client::new(self.client.clone())
}

/// Returns an in-memory tags client
pub fn tags(&self) -> tags::Client {
tags::Client::new(self.client.clone())
pub fn blobs(&self) -> &blobs::MemClient {
&self.client
}
}

0 comments on commit 5de0a19

Please sign in to comment.