Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/random_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ async fn provide(args: ProvideArgs) -> anyhow::Result<()> {
.bind()
.await?;
let (dump_task, events_tx) = dump_provider_events(args.allow_push);
let blobs = iroh_blobs::net_protocol::Blobs::new(&store, endpoint.clone(), Some(events_tx));
let blobs = iroh_blobs::BlobsProtocol::new(&store, endpoint.clone(), Some(events_tx));
let router = iroh::protocol::Router::builder(endpoint.clone())
.accept(iroh_blobs::ALPN, blobs)
.spawn();
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ pub mod format;
pub mod get;
pub mod hashseq;
mod metrics;
pub mod net_protocol;
mod net_protocol;
pub use net_protocol::BlobsProtocol;
pub mod protocol;
pub mod provider;
pub mod test;
Expand Down
10 changes: 5 additions & 5 deletions src/net_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! ```rust
//! # async fn example() -> anyhow::Result<()> {
//! use iroh::{protocol::Router, Endpoint};
//! use iroh_blobs::{net_protocol::Blobs, store};
//! use iroh_blobs::{store, BlobsProtocol};
//!
//! // create a store
//! let store = store::fs::FsStore::load("blobs").await?;
Expand All @@ -19,7 +19,7 @@
//! let endpoint = Endpoint::builder().discovery_n0().bind().await?;
//!
//! // create a blobs protocol handler
//! let blobs = Blobs::new(&store, endpoint.clone(), None);
//! let blobs = BlobsProtocol::new(&store, endpoint.clone(), None);
//!
//! // create a router and add the blobs protocol handler
//! let router = Router::builder(endpoint)
Expand Down Expand Up @@ -62,11 +62,11 @@ pub(crate) struct BlobsInner {

/// A protocol handler for the blobs protocol.
#[derive(Debug, Clone)]
pub struct Blobs {
pub struct BlobsProtocol {
pub(crate) inner: Arc<BlobsInner>,
}

impl Blobs {
impl BlobsProtocol {
pub fn new(store: &Store, endpoint: Endpoint, events: Option<mpsc::Sender<Event>>) -> Self {
Self {
inner: Arc::new(BlobsInner {
Expand Down Expand Up @@ -97,7 +97,7 @@ impl Blobs {
}
}

impl ProtocolHandler for Blobs {
impl ProtocolHandler for BlobsProtocol {
fn accept(
&self,
conn: Connection,
Expand Down
2 changes: 1 addition & 1 deletion src/provider.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! The low level server side API
//!
//! Note that while using this API directly is fine, the standard way
//! to provide data is to just register a [`crate::net_protocol`] protocol
//! to provide data is to just register a [`crate::BlobsProtocol`] protocol
//! handler with an [`iroh::Endpoint`](iroh::protocol::Router).
use std::{
fmt::Debug,
Expand Down
12 changes: 6 additions & 6 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
api::{blobs::Bitfield, Store},
get,
hashseq::HashSeq,
net_protocol::Blobs,
net_protocol::BlobsProtocol,
protocol::{ChunkRangesSeq, GetManyRequest, ObserveRequest, PushRequest},
provider::Event,
store::{
Expand Down Expand Up @@ -490,7 +490,7 @@ pub async fn node_test_setup_with_events_fs(
) -> TestResult<(Router, FsStore, PathBuf)> {
let store = crate::store::fs::FsStore::load(&db_path).await?;
let ep = Endpoint::builder().bind().await?;
let blobs = Blobs::new(&store, ep.clone(), events);
let blobs = BlobsProtocol::new(&store, ep.clone(), events);
let router = Router::builder(ep).accept(crate::ALPN, blobs).spawn();
Ok((router, store, db_path))
}
Expand All @@ -504,7 +504,7 @@ pub async fn node_test_setup_with_events_mem(
) -> TestResult<(Router, MemStore)> {
let store = MemStore::new();
let ep = Endpoint::builder().bind().await?;
let blobs = Blobs::new(&store, ep.clone(), events);
let blobs = BlobsProtocol::new(&store, ep.clone(), events);
let router = Router::builder(ep).accept(crate::ALPN, blobs).spawn();
Ok((router, store))
}
Expand Down Expand Up @@ -601,7 +601,7 @@ async fn node_serve_hash_seq() -> TestResult<()> {
let root_tt = store.add_bytes(hash_seq).await?;
let root = root_tt.hash;
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
let blobs = crate::net_protocol::Blobs::new(&store, endpoint.clone(), None);
let blobs = crate::net_protocol::BlobsProtocol::new(&store, endpoint.clone(), None);
let r1 = Router::builder(endpoint)
.accept(crate::protocol::ALPN, blobs)
.spawn();
Expand Down Expand Up @@ -632,7 +632,7 @@ async fn node_serve_blobs() -> TestResult<()> {
tts.push(store.add_bytes(test_data(size)).await?);
}
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
let blobs = crate::net_protocol::Blobs::new(&store, endpoint.clone(), None);
let blobs = crate::net_protocol::BlobsProtocol::new(&store, endpoint.clone(), None);
let r1 = Router::builder(endpoint)
.accept(crate::protocol::ALPN, blobs)
.spawn();
Expand Down Expand Up @@ -674,7 +674,7 @@ async fn node_smoke(store: &Store) -> TestResult<()> {
let tt = store.add_bytes(b"hello world".to_vec()).temp_tag().await?;
let hash = *tt.hash();
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
let blobs = crate::net_protocol::Blobs::new(store, endpoint.clone(), None);
let blobs = crate::net_protocol::BlobsProtocol::new(store, endpoint.clone(), None);
let r1 = Router::builder(endpoint)
.accept(crate::protocol::ALPN, blobs)
.spawn();
Expand Down
Loading