Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
jmg-duarte committed Feb 24, 2025
1 parent 610ab73 commit a17b931
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
12 changes: 6 additions & 6 deletions mater/lib/src/file_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ pub(crate) mod blockstore {
}

/// A read-only [`blockstore::Blockstore`] implementation of [`CarExtractor`].
pub struct CarReadOnlyBlockstore<R> {
pub struct ReadOnlyBlockstore<R> {
inner: RwLock<CarExtractor<R>>,
}

impl<R> CarReadOnlyBlockstore<R>
impl<R> ReadOnlyBlockstore<R>
where
R: AsyncRead + AsyncSeek + Unpin + blockstore::cond_send::CondSync,
{
Expand All @@ -236,7 +236,7 @@ pub(crate) mod blockstore {
}
}

impl CarReadOnlyBlockstore<File> {
impl ReadOnlyBlockstore<File> {
/// Create a new [`CarReadOnlyBlockstore<tokio::io::File>`](CarReadOnlyBlockstore) from the given path.
pub async fn from_path<P>(path: P) -> Result<Self, Error>
where
Expand All @@ -246,15 +246,15 @@ pub(crate) mod blockstore {
}
}

impl<R> Deref for CarReadOnlyBlockstore<R> {
impl<R> Deref for ReadOnlyBlockstore<R> {
type Target = RwLock<CarExtractor<R>>;

fn deref(&self) -> &Self::Target {
&self.inner
}
}

impl<R> Blockstore for CarReadOnlyBlockstore<R>
impl<R> Blockstore for ReadOnlyBlockstore<R>
where
R: AsyncRead + AsyncSeek + Unpin + Send + Sync,
{
Expand Down Expand Up @@ -318,7 +318,7 @@ pub(crate) mod blockstore {
multicodec::generate_multihash, test_utils::assert_buffer_eq, IDENTITY_CODE, RAW_CODE,
};

type FileBlockstore = CarReadOnlyBlockstore<File>;
type FileBlockstore = ReadOnlyBlockstore<File>;

#[tokio::test]
async fn test_identity_cid() {
Expand Down
2 changes: 1 addition & 1 deletion mater/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub mod blockstore {
pub use blockstore::Blockstore;
pub use blockstore::Error;

pub use crate::file_reader::blockstore::CarReadOnlyBlockstore;
pub use crate::file_reader::blockstore::ReadOnlyBlockstore;
}

/// CAR handling errors.
Expand Down
8 changes: 3 additions & 5 deletions storage-retrieval/lib/examples/simple_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::sync::Arc;

use anyhow::Result;
use libp2p::Multiaddr;
use mater::blockstore::CarReadOnlyBlockstore;
use mater::blockstore::ReadOnlyBlockstore;
use polka_storage_retrieval::server::Server;

#[tokio::main]
Expand All @@ -16,10 +16,8 @@ async fn main() -> Result<()> {

// Example blockstore providing only a single file.
let blockstore = Arc::new(
CarReadOnlyBlockstore::from_path(
"./mater/lib/tests/fixtures/car_v2/spaceglenda_wrapped.car",
)
.await?,
ReadOnlyBlockstore::from_path("./mater/lib/tests/fixtures/car_v2/spaceglenda_wrapped.car")
.await?,
);

let roots = blockstore.write().await.roots().await?;
Expand Down

0 comments on commit a17b931

Please sign in to comment.