Skip to content

Commit 9eb371a

Browse files
committed
refactor: move net_protocol::Blobs to top level as BlobsProtocol
also make net_protocol private since it contains nothing else.
1 parent 845e37c commit 9eb371a

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

examples/random_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ async fn provide(args: ProvideArgs) -> anyhow::Result<()> {
237237
.bind()
238238
.await?;
239239
let (dump_task, events_tx) = dump_provider_events(args.allow_push);
240-
let blobs = iroh_blobs::net_protocol::Blobs::new(&store, endpoint.clone(), Some(events_tx));
240+
let blobs = iroh_blobs::BlobsProtocol::new(&store, endpoint.clone(), Some(events_tx));
241241
let router = iroh::protocol::Router::builder(endpoint.clone())
242242
.accept(iroh_blobs::ALPN, blobs)
243243
.spawn();

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ pub mod format;
77
pub mod get;
88
pub mod hashseq;
99
mod metrics;
10-
pub mod net_protocol;
10+
mod net_protocol;
11+
pub use net_protocol::BlobsProtocol;
1112
pub mod protocol;
1213
pub mod provider;
1314
pub mod test;

src/net_protocol.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ pub(crate) struct BlobsInner {
6262

6363
/// A protocol handler for the blobs protocol.
6464
#[derive(Debug, Clone)]
65-
pub struct Blobs {
65+
pub struct BlobsProtocol {
6666
pub(crate) inner: Arc<BlobsInner>,
6767
}
6868

69-
impl Blobs {
69+
impl BlobsProtocol {
7070
pub fn new(store: &Store, endpoint: Endpoint, events: Option<mpsc::Sender<Event>>) -> Self {
7171
Self {
7272
inner: Arc::new(BlobsInner {
@@ -97,7 +97,7 @@ impl Blobs {
9797
}
9898
}
9999

100-
impl ProtocolHandler for Blobs {
100+
impl ProtocolHandler for BlobsProtocol {
101101
fn accept(
102102
&self,
103103
conn: Connection,

src/tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{
1414
api::{blobs::Bitfield, Store},
1515
get,
1616
hashseq::HashSeq,
17-
net_protocol::Blobs,
17+
net_protocol::BlobsProtocol,
1818
protocol::{ChunkRangesSeq, GetManyRequest, ObserveRequest, PushRequest},
1919
provider::Event,
2020
store::{
@@ -490,7 +490,7 @@ pub async fn node_test_setup_with_events_fs(
490490
) -> TestResult<(Router, FsStore, PathBuf)> {
491491
let store = crate::store::fs::FsStore::load(&db_path).await?;
492492
let ep = Endpoint::builder().bind().await?;
493-
let blobs = Blobs::new(&store, ep.clone(), events);
493+
let blobs = BlobsProtocol::new(&store, ep.clone(), events);
494494
let router = Router::builder(ep).accept(crate::ALPN, blobs).spawn();
495495
Ok((router, store, db_path))
496496
}
@@ -504,7 +504,7 @@ pub async fn node_test_setup_with_events_mem(
504504
) -> TestResult<(Router, MemStore)> {
505505
let store = MemStore::new();
506506
let ep = Endpoint::builder().bind().await?;
507-
let blobs = Blobs::new(&store, ep.clone(), events);
507+
let blobs = BlobsProtocol::new(&store, ep.clone(), events);
508508
let router = Router::builder(ep).accept(crate::ALPN, blobs).spawn();
509509
Ok((router, store))
510510
}
@@ -601,7 +601,7 @@ async fn node_serve_hash_seq() -> TestResult<()> {
601601
let root_tt = store.add_bytes(hash_seq).await?;
602602
let root = root_tt.hash;
603603
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
604-
let blobs = crate::net_protocol::Blobs::new(&store, endpoint.clone(), None);
604+
let blobs = crate::net_protocol::BlobsProtocol::new(&store, endpoint.clone(), None);
605605
let r1 = Router::builder(endpoint)
606606
.accept(crate::protocol::ALPN, blobs)
607607
.spawn();
@@ -632,7 +632,7 @@ async fn node_serve_blobs() -> TestResult<()> {
632632
tts.push(store.add_bytes(test_data(size)).await?);
633633
}
634634
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
635-
let blobs = crate::net_protocol::Blobs::new(&store, endpoint.clone(), None);
635+
let blobs = crate::net_protocol::BlobsProtocol::new(&store, endpoint.clone(), None);
636636
let r1 = Router::builder(endpoint)
637637
.accept(crate::protocol::ALPN, blobs)
638638
.spawn();
@@ -674,7 +674,7 @@ async fn node_smoke(store: &Store) -> TestResult<()> {
674674
let tt = store.add_bytes(b"hello world".to_vec()).temp_tag().await?;
675675
let hash = *tt.hash();
676676
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
677-
let blobs = crate::net_protocol::Blobs::new(store, endpoint.clone(), None);
677+
let blobs = crate::net_protocol::BlobsProtocol::new(store, endpoint.clone(), None);
678678
let r1 = Router::builder(endpoint)
679679
.accept(crate::protocol::ALPN, blobs)
680680
.spawn();

0 commit comments

Comments
 (0)