Skip to content

Commit 152b5e7

Browse files
committed
Add back old .gitignore and README.md
1 parent 46e7265 commit 152b5e7

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/target
2-
/tmp
3-
/.sendme*
2+
iroh.config.toml
3+
.vscode/*

.img/iroh_wordmark.svg

Lines changed: 1 addition & 0 deletions
Loading

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# iroh-blobs
2+
3+
This crate provides blob and blob sequence transfer support for iroh. It implements a simple request-response protocol based on BLAKE3 verified streaming.
4+
5+
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.
6+
7+
The requester opens a QUIC stream to the provider and sends the request. The provider answers with the requested data, encoded as [BLAKE3](https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf) verified streams, on the same QUIC stream.
8+
9+
This crate is used together with [iroh](https://crates.io/crates/iroh). Connection establishment is left up to the user or higher level APIs.
10+
11+
## Concepts
12+
13+
- **Blob:** a sequence of bytes of arbitrary size, without any metadata.
14+
15+
- **Link:** a 32 byte BLAKE3 hash of a blob.
16+
17+
- **HashSeq:** a blob that contains a sequence of links. Its size is a multiple of 32.
18+
19+
- **Provider:** The side that provides data and answers requests. Providers wait for incoming requests from Requests.
20+
21+
- **Requester:** The side that asks for data. It is initiating requests to one or many providers.
22+
23+
24+
## Getting started
25+
26+
The `iroh-blobs` protocol was designed to be used in conjunction with `iroh`. [Iroh](https://docs.rs/iroh) is a networking library for making direct connections, these connections are what power the data transfers in `iroh-blobs`.
27+
28+
Iroh provides a [`Router`](https://docs.rs/iroh/latest/iroh/protocol/struct.Router.html) that takes an [`Endpoint`](https://docs.rs/iroh/latest/iroh/endpoint/struct.Endpoint.html) 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`.
29+
30+
Here is a basic example of how to set up `iroh-blobs` with `iroh`:
31+
32+
```rust
33+
use iroh::{protocol::Router, Endpoint};
34+
use iroh_blobs::{store::Store, net_protocol::Blobs};
35+
36+
#[tokio::main]
37+
async fn main() -> anyhow::Result<()> {
38+
// create an iroh endpoint that includes the standard discovery mechanisms
39+
// we've built at number0
40+
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
41+
42+
// create an in-memory blob store
43+
// use `iroh_blobs::net_protocol::Blobs::persistent` to load or create a
44+
// persistent blob store from a path
45+
let blobs = Blobs::memory().build(&endpoint);
46+
47+
// turn on the "rpc" feature if you need to create blobs and tags clients
48+
let blobs_client = blobs.client();
49+
let tags_client = blobs_client.tags();
50+
51+
// build the router
52+
let router = Router::builder(endpoint)
53+
.accept(iroh_blobs::ALPN, blobs.clone())
54+
.spawn();
55+
56+
// do fun stuff with the blobs protocol!
57+
router.shutdown().await?;
58+
drop(tags_client);
59+
Ok(())
60+
}
61+
```
62+
63+
## Examples
64+
65+
Examples that use `iroh-blobs` can be found in [this repo](https://github.com/n0-computer/iroh-blobs/tree/main/examples).
66+
67+
# License
68+
69+
This project is licensed under either of
70+
71+
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
72+
<http://www.apache.org/licenses/LICENSE-2.0>)
73+
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
74+
<http://opensource.org/licenses/MIT>)
75+
76+
at your option.
77+
78+
### Contribution
79+
80+
Unless you explicitly state otherwise, any contribution intentionally submitted
81+
for inclusion in this project by you, as defined in the Apache-2.0 license,
82+
shall be dual licensed as above, without any additional terms or conditions.

0 commit comments

Comments
 (0)