fix: configure iroh collection parser

we need to let the provider know that we want to support iroh collections
This commit is contained in:
Ruediger Klaehn
2023-07-17 12:33:32 +03:00
committed by dignifiedquire
parent 8fff9ebe10
commit 7245be1b2b
2 changed files with 11 additions and 9 deletions

13
Cargo.lock generated
View File

@@ -1198,9 +1198,9 @@ dependencies = [
[[package]] [[package]]
name = "default-net" name = "default-net"
version = "0.16.1" version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae47401ee27418babbf80e20de5ff240a19c850ec6000326342cdb198b341687" checksum = "cfe553014b8511f63a1324f7cc9b91cf0117289321ad14b4781ef4fed005f30c"
dependencies = [ dependencies = [
"dlopen2", "dlopen2",
"libc", "libc",
@@ -2623,7 +2623,7 @@ checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6"
[[package]] [[package]]
name = "iroh" name = "iroh"
version = "0.4.1" version = "0.4.1"
source = "git+https://github.com/n0-computer/iroh?branch=main#58d42ba7da1f3eca199f4952643d1de6ac812664" source = "git+https://github.com/n0-computer/iroh?branch=main#456f96305954a23299d02ed65b8838ba168232e1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bao-tree", "bao-tree",
@@ -2649,13 +2649,14 @@ dependencies = [
"tokio-stream", "tokio-stream",
"tokio-util", "tokio-util",
"tracing", "tracing",
"url",
"walkdir", "walkdir",
] ]
[[package]] [[package]]
name = "iroh-bytes" name = "iroh-bytes"
version = "0.4.1" version = "0.4.1"
source = "git+https://github.com/n0-computer/iroh?branch=main#58d42ba7da1f3eca199f4952643d1de6ac812664" source = "git+https://github.com/n0-computer/iroh?branch=main#456f96305954a23299d02ed65b8838ba168232e1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bao-tree", "bao-tree",
@@ -2703,7 +2704,7 @@ dependencies = [
[[package]] [[package]]
name = "iroh-metrics" name = "iroh-metrics"
version = "0.4.1" version = "0.4.1"
source = "git+https://github.com/n0-computer/iroh?branch=main#58d42ba7da1f3eca199f4952643d1de6ac812664" source = "git+https://github.com/n0-computer/iroh?branch=main#456f96305954a23299d02ed65b8838ba168232e1"
dependencies = [ dependencies = [
"erased_set", "erased_set",
"hyper", "hyper",
@@ -2717,7 +2718,7 @@ dependencies = [
[[package]] [[package]]
name = "iroh-net" name = "iroh-net"
version = "0.4.1" version = "0.4.1"
source = "git+https://github.com/n0-computer/iroh?branch=main#58d42ba7da1f3eca199f4952643d1de6ac812664" source = "git+https://github.com/n0-computer/iroh?branch=main#456f96305954a23299d02ed65b8838ba168232e1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"backoff", "backoff",

View File

@@ -40,7 +40,7 @@ use iroh::bytes::get::{fsm, Stats};
use iroh::bytes::protocol::{AnyGetRequest, GetRequest, RequestToken}; use iroh::bytes::protocol::{AnyGetRequest, GetRequest, RequestToken};
use iroh::bytes::provider::Event as ProviderEvent; use iroh::bytes::provider::Event as ProviderEvent;
use iroh::bytes::util::runtime; use iroh::bytes::util::runtime;
use iroh::collection::Collection; use iroh::collection::{Collection, IrohCollectionParser};
use iroh::database::flat::DataSource; use iroh::database::flat::DataSource;
use iroh::dial::Ticket; use iroh::dial::Ticket;
use iroh::net::defaults::default_derp_map; use iroh::net::defaults::default_derp_map;
@@ -194,6 +194,7 @@ impl BackupProvider {
let provider = Node::builder(db) let provider = Node::builder(db)
.bind_addr((Ipv4Addr::UNSPECIFIED, 0).into()) .bind_addr((Ipv4Addr::UNSPECIFIED, 0).into())
.custom_auth_handler(Arc::new(auth_token_handler)) .custom_auth_handler(Arc::new(auth_token_handler))
.collection_parser(IrohCollectionParser)
.runtime(&rt) .runtime(&rt)
.spawn() .spawn()
.await?; .await?;
@@ -500,8 +501,8 @@ async fn run_get_request(
ticket: Ticket, ticket: Ticket,
) -> anyhow::Result<Stats> { ) -> anyhow::Result<Stats> {
let opts = ticket.as_get_options(Keypair::generate(), Some(default_derp_map())); let opts = ticket.as_get_options(Keypair::generate(), Some(default_derp_map()));
let request = AnyGetRequest::Get(GetRequest::all(ticket.hash())) let request =
.with_token(ticket.token().cloned()); AnyGetRequest::Get(GetRequest::all(ticket.hash())).with_token(ticket.token().cloned());
let connection = iroh::dial::dial(opts).await?; let connection = iroh::dial::dial(opts).await?;
let initial = fsm::start(connection, request); let initial = fsm::start(connection, request);
use fsm::*; use fsm::*;