ForkNous ResearchNous Researchpublished Mar 13, 2025seen 5d

NousResearch/iroh-blobs

forked from n0-computer/iroh-blobs

Open original ↗

Captured source

source ↗
published Mar 13, 2025seen 5dcaptured 9hhttp 200method plain

NousResearch/iroh-blobs

Description: Blobs layer for iroh

Language: Rust

License: Apache-2.0

Stars: 5

Forks: 4

Open issues: 0

Created: 2025-03-13T15:46:46Z

Pushed: 2025-10-03T02:40:21Z

Default branch: main

Fork: yes

Parent repository: n0-computer/iroh-blobs

Archived: no

README:

iroh-blobs

NOTE: this version of iroh-blobs is not yet considered production quality. For now, if you need production quality, use iroh-blobs 0.35

This crate provides blob and blob sequence transfer support for iroh. It implements a simple request-response protocol based on BLAKE3 verified streaming.

A request describes data in terms of BLAKE3 hashes and byte ranges. It is possible to request blobs or ranges of blobs, as well as entire sequences of blobs in one request.

The requester opens a QUIC stream to the provider and sends the request. The provider answers with the requested data, encoded as BLAKE3 verified streams, on the same QUIC stream.

This crate is used together with iroh. Connection establishment is left up to the user or higher level APIs.

Concepts

  • Blob: a sequence of bytes of arbitrary size, without any metadata.
  • Link: a 32 byte BLAKE3 hash of a blob.
  • HashSeq: a blob that contains a sequence of links. Its size is a multiple of 32.
  • Provider: The side that provides data and answers requests. Providers wait for incoming requests from Requests.
  • Requester: The side that asks for data. It is initiating requests to one or many providers.

A node can be a provider and a requester at the same time.

Getting started

The iroh-blobs protocol was designed to be used in conjunction with iroh. Iroh is a networking library for making direct connections, these connections are what power the data transfers in iroh-blobs.

Iroh provides a `Router` that takes an `Endpoint` and any protocols needed for the application. Similar to a router in webserver library, it runs a loop accepting incoming connections and routes them to the specific protocol handler, based on ALPN.

Here is a basic example of how to set up iroh-blobs with iroh:

use iroh::{protocol::Router, Endpoint};
use iroh_blobs::{store::mem::MemStore, BlobsProtocol};

#[tokio::main]
async fn main() -> anyhow::Result {
// create an iroh endpoint that includes the standard discovery mechanisms
// we've built at number0
let endpoint = Endpoint::builder().discovery_n0().bind().await?;

// create a protocol handler using an in-memory blob store.
let store = MemStore::new();
let blobs = BlobsProtocol::new(&store, endpoint.clone(), None);

// build the router
let router = Router::builder(endpoint)
.accept(iroh_blobs::ALPN, blobs.clone())
.spawn();

let tag = blobs.add_slice(b"Hello world").await?;
println!("We are now serving {}", blobs.ticket(tag).await?);

// wait for control-c
tokio::signal::ctrl_c().await;

// clean shutdown of router and store
router.shutdown().await?;
Ok(())
}

Examples

Examples that use iroh-blobs can be found in this repo.

License

This project is licensed under either of

  • Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or

)

  • MIT license ([LICENSE-MIT](LICENSE-MIT) or

)

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Notability

notability 1.0/10

Routine fork, very low stars