diff --git a/examples/random_store.rs b/examples/random_store.rs index 74e18919..771fb411 100644 --- a/examples/random_store.rs +++ b/examples/random_store.rs @@ -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(); diff --git a/src/lib.rs b/src/lib.rs index 3c4b3801..06499b41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; diff --git a/src/net_protocol.rs b/src/net_protocol.rs index 63b50bdb..506e6b72 100644 --- a/src/net_protocol.rs +++ b/src/net_protocol.rs @@ -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?; @@ -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) @@ -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, } -impl Blobs { +impl BlobsProtocol { pub fn new(store: &Store, endpoint: Endpoint, events: Option>) -> Self { Self { inner: Arc::new(BlobsInner { @@ -97,7 +97,7 @@ impl Blobs { } } -impl ProtocolHandler for Blobs { +impl ProtocolHandler for BlobsProtocol { fn accept( &self, conn: Connection, diff --git a/src/provider.rs b/src/provider.rs index ff2d4a0e..61af8f6e 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -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, diff --git a/src/tests.rs b/src/tests.rs index f71b3e61..fccfac52 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -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::{ @@ -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)) } @@ -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)) } @@ -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(); @@ -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(); @@ -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();