pub struct IrohBlobStore { /* private fields */ }Expand description
Content-addressed object store backed by iroh-blobs, keyed by canonical CIDs.
See the module docs for the CID → BLAKE3 locator model.
Implementations§
Source§impl IrohBlobStore
impl IrohBlobStore
Sourcepub fn new_memory() -> Self
pub fn new_memory() -> Self
Create an ephemeral, in-memory store (tests, throwaway caches).
Sourcepub async fn open_fs(root: impl AsRef<Path>) -> Result<Self>
pub async fn open_fs(root: impl AsRef<Path>) -> Result<Self>
Open (or create) a persistent store rooted at root.
Blob bytes live in the iroh-blobs FsStore under root; the
CID→blake3 index is an append-only sidecar file next to it.
Sourcepub async fn put_object(&self, data: Vec<u8>) -> Result<Sha256Hash>
pub async fn put_object(&self, data: Vec<u8>) -> Result<Sha256Hash>
Store an object, returning its SHA256 hash (the consumer-facing key).
The bytes are added to the iroh-blobs store (BLAKE3-addressed, tagged so garbage collection cannot reclaim them) and the Git CID→blake3 mapping is recorded.
Sourcepub async fn put_verified_object(
&self,
expected_sha256: Sha256Hash,
data: Vec<u8>,
) -> Result<Sha256Hash>
pub async fn put_verified_object( &self, expected_sha256: Sha256Hash, data: Vec<u8>, ) -> Result<Sha256Hash>
Store bytes under an expected SHA256 key after re-verifying them.
F2 uses this after a remote iroh-blobs transfer: provider hints are untrusted, so fetched bytes are accepted only when they match the consumer-facing SHA256 requested by the facade.
Sourcepub async fn put_object_by_cid(
&self,
cid: ContentCid,
data: Vec<u8>,
) -> Result<()>
pub async fn put_object_by_cid( &self, cid: ContentCid, data: Vec<u8>, ) -> Result<()>
Store bytes under an algorithm-preserving content CID.
Raw Git SHA-256 CIDs are re-verified against the bytes here. An XET Merkle CID addresses the reconstruction DAG rather than the raw file, so its binding is established by the XET clean operation and the LFS SHA-256 remains the end-to-end raw-file integrity check.
Sourcepub async fn get_object(&self, hash: &Sha256Hash) -> Result<Option<Vec<u8>>>
pub async fn get_object(&self, hash: &Sha256Hash) -> Result<Option<Vec<u8>>>
Fetch an object by its SHA256 hash.
Returns Ok(None) when the hash is unknown. Returns an error if the
index resolves but the retrieved bytes do not hash back to the
requested SHA256 (poisoned/corrupt mapping — never served).
Sourcepub async fn get_object_by_cid(
&self,
cid: &ContentCid,
) -> Result<Option<Vec<u8>>>
pub async fn get_object_by_cid( &self, cid: &ContentCid, ) -> Result<Option<Vec<u8>>>
Fetch an object by its self-describing content CID.
Sourcepub async fn blake3_of(&self, hash: &Sha256Hash) -> Option<Blake3Hash>
pub async fn blake3_of(&self, hash: &Sha256Hash) -> Option<Blake3Hash>
Resolve the BLAKE3 hash backing a SHA256 key, if known.
This is the seam F2 (#900) uses to announce/locate providers: the locator plane finds peers, iroh-blobs transfers by BLAKE3.
Sourcepub async fn blake3_of_cid(&self, cid: &ContentCid) -> Option<Blake3Hash>
pub async fn blake3_of_cid(&self, cid: &ContentCid) -> Option<Blake3Hash>
Resolve the raw-byte BLAKE3 hash backing a content CID, if known.
Auto Trait Implementations§
impl !Freeze for IrohBlobStore
impl !RefUnwindSafe for IrohBlobStore
impl Send for IrohBlobStore
impl Sync for IrohBlobStore
impl Unpin for IrohBlobStore
impl UnsafeUnpin for IrohBlobStore
impl !UnwindSafe for IrohBlobStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more