-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add "getting started" instructions to the readme (#32)
* docs: add `INSTALL.md` with "getting started" instructions * remove INSTALL.md, move content to README.md * add example from readme as separate example --------- Co-authored-by: “ramfox” <“kasey@n0.computer”> Co-authored-by: Ruediger Klaehn <rklaehn@protonmail.com>
- Loading branch information
1 parent
57340cc
commit dd6673e
Showing
4 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use iroh::{protocol::Router, Endpoint}; | ||
use iroh_blobs::{net_protocol::Blobs, util::local_pool::LocalPool}; | ||
|
||
#[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?; | ||
|
||
// spawn a local pool with one thread per CPU | ||
// for a single threaded pool use `LocalPool::single` | ||
let local_pool = LocalPool::default(); | ||
|
||
// create an in-memory blob store | ||
// use `iroh_blobs::net_protocol::Blobs::persistent` to load or create a | ||
// persistent blob store from a path | ||
let blobs = Blobs::memory().build(local_pool.handle(), &endpoint); | ||
|
||
// turn on the "rpc" feature if you need to create blobs and tags clients | ||
let blobs_client = blobs.client(); | ||
let tags_client = blobs_client.tags(); | ||
|
||
// build the router | ||
let router = Router::builder(endpoint) | ||
.accept(iroh_blobs::ALPN, blobs.clone()) | ||
.spawn() | ||
.await?; | ||
|
||
// do fun stuff with the blobs protocol! | ||
// make sure not to drop the local_pool before you are finished | ||
router.shutdown().await?; | ||
drop(local_pool); | ||
drop(tags_client); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters