Skip to content

Commit 4fc1244

Browse files
feat: import iroh_base::ticket::BlobTicket and iroh_base::hash
1 parent 29f0591 commit 4fc1244

22 files changed

+1005
-249
lines changed

Cargo.lock

Lines changed: 171 additions & 178 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ bao-tree = { version = "0.13", features = [
1919
"tokio_fsm",
2020
"validate",
2121
], default-features = false }
22+
blake3 = { version = "1.4.5", package = "iroh-blake3" }
2223
bytes = { version = "1.7", features = ["serde"] }
2324
chrono = "0.4.31"
2425
clap = { version = "4.5.20", features = ["derive"], optional = true }
26+
data-encoding = { version = "2.3.3" }
2527
derive_more = { version = "1.0.0", features = [
2628
"debug",
2729
"display",
@@ -93,7 +95,7 @@ futures-util = "0.3.30"
9395
testdir = "0.9.1"
9496

9597
[features]
96-
default = ["fs-store", "net_protocol"]
98+
default = ["fs-store", "net_protocol", "cli"]
9799
downloader = ["dep:parking_lot", "tokio-util/time", "dep:hashlink"]
98100
net_protocol = ["downloader", "dep:futures-util"]
99101
fs-store = ["dep:reflink-copy", "redb", "dep:tempfile"]

examples/custom-protocol.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ use iroh::{
4848
protocol::{ProtocolHandler, Router},
4949
Endpoint, NodeId,
5050
};
51-
use iroh_base::hash::Hash;
52-
use iroh_blobs::{net_protocol::Blobs, rpc::client::blobs::MemClient, util::local_pool::LocalPool};
51+
use iroh_blobs::{
52+
net_protocol::Blobs, rpc::client::blobs::MemClient, util::local_pool::LocalPool, Hash,
53+
};
5354
use tracing_subscriber::{prelude::*, EnvFilter};
5455

5556
#[derive(Debug, Parser)]

examples/hello-world-fetch.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ use std::{env, str::FromStr};
77

88
use anyhow::{bail, ensure, Context, Result};
99
use iroh::{protocol::Router, Endpoint};
10-
use iroh_base::ticket::BlobTicket;
11-
use iroh_blobs::{net_protocol::Blobs, util::local_pool::LocalPool, BlobFormat};
10+
use iroh_blobs::{
11+
net_protocol::Blobs, ticket::BlobTicket, util::local_pool::LocalPool, BlobFormat,
12+
};
1213
use tracing_subscriber::{prelude::*, EnvFilter};
1314

1415
// set the RUST_LOG env var to one of {debug,info,warn} to see logging info

examples/hello-world-provide.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
//! run this example from the project root:
55
//! $ cargo run --example hello-world-provide
66
use iroh::{protocol::Router, Endpoint};
7-
use iroh_base::{node_addr::AddrInfoOptions, ticket::BlobTicket};
8-
use iroh_blobs::{net_protocol::Blobs, util::local_pool::LocalPool};
7+
use iroh_blobs::{net_protocol::Blobs, ticket::BlobTicket, util::local_pool::LocalPool};
98
use tracing_subscriber::{prelude::*, EnvFilter};
109

1110
// set the RUST_LOG env var to one of {debug,info,warn} to see logging info
@@ -35,8 +34,7 @@ async fn main() -> anyhow::Result<()> {
3534
let res = blobs_client.add_bytes("Hello, world!").await?;
3635

3736
// create a ticket
38-
let mut addr = node.endpoint().node_addr().await?;
39-
addr.apply_options(AddrInfoOptions::RelayAndAddresses);
37+
let addr = node.endpoint().node_addr().await?;
4038
let ticket = BlobTicket::new(addr, res.hash, res.format)?;
4139

4240
// print some info about the node

examples/local-swarm-discovery.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ use std::path::PathBuf;
1010
use anyhow::ensure;
1111
use clap::{Parser, Subcommand};
1212
use iroh::{
13-
discovery::local_swarm_discovery::LocalSwarmDiscovery, key::PublicKey, protocol::Router,
14-
Endpoint, NodeAddr, RelayMode,
13+
discovery::local_swarm_discovery::LocalSwarmDiscovery, key::PublicKey, key::SecretKey,
14+
protocol::Router, Endpoint, NodeAddr, RelayMode,
1515
};
16-
use iroh_base::{hash::Hash, key::SecretKey};
1716
use iroh_blobs::{
18-
net_protocol::Blobs, rpc::client::blobs::WrapOption, util::local_pool::LocalPool,
17+
net_protocol::Blobs, rpc::client::blobs::WrapOption, util::local_pool::LocalPool, Hash,
1918
};
2019
use tracing_subscriber::{prelude::*, EnvFilter};
2120

examples/transfer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use std::{path::PathBuf, str::FromStr};
22

33
use anyhow::Result;
44
use iroh::{protocol::Router, Endpoint};
5-
use iroh_base::ticket::BlobTicket;
65
use iroh_blobs::{
76
net_protocol::Blobs,
87
rpc::client::blobs::{ReadAtLen, WrapOption},
8+
ticket::BlobTicket,
99
util::{local_pool::LocalPool, SetTagOption},
1010
};
1111

src/cli.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use indicatif::{
1616
ProgressStyle,
1717
};
1818
use iroh::{key::PublicKey, relay::RelayUrl, NodeAddr};
19-
use iroh_base::{node_addr::AddrInfoOptions, ticket::BlobTicket};
2019
use tokio::io::AsyncWriteExt;
2120

2221
use crate::{
@@ -27,6 +26,7 @@ use crate::{
2726
self, BlobInfo, BlobStatus, CollectionInfo, DownloadOptions, IncompleteBlobInfo, WrapOption,
2827
},
2928
store::{ConsistencyCheckProgress, ExportFormat, ExportMode, ReportLevel, ValidateProgress},
29+
ticket::BlobTicket,
3030
util::SetTagOption,
3131
BlobFormat, Hash, HashAndFormat, Tag,
3232
};
@@ -146,11 +146,6 @@ pub enum BlobCommands {
146146
Share {
147147
/// Hash of the blob to share.
148148
hash: Hash,
149-
/// Options to configure the address information in the generated ticket.
150-
///
151-
/// Use `relay-and-addresses` in networks with no internet connectivity.
152-
#[clap(long, default_value_t = AddrInfoOptions::Id)]
153-
addr_options: AddrInfoOptions,
154149
/// If the blob is a collection, the requester will also fetch the listed blobs.
155150
#[clap(long, default_value_t = false)]
156151
recursive: bool,
@@ -203,18 +198,22 @@ impl BlobCommands {
203198

204199
// create the node address with the appropriate overrides
205200
let node_addr = {
206-
let NodeAddr { node_id, info } = node_addr;
201+
let NodeAddr {
202+
node_id,
203+
relay_url: original_relay_url,
204+
direct_addresses,
205+
} = node_addr;
207206
let addresses = if override_addresses {
208207
// use only the cli supplied ones
209208
address
210209
} else {
211210
// use both the cli supplied ones and the ticket ones
212-
address.extend(info.direct_addresses);
211+
address.extend(direct_addresses);
213212
address
214213
};
215214

216215
// prefer direct arg over ticket
217-
let relay_url = relay_url.or(info.relay_url);
216+
let relay_url = relay_url.or(original_relay_url);
218217

219218
NodeAddr::from_parts(node_id, relay_url, addresses)
220219
};
@@ -357,7 +356,6 @@ impl BlobCommands {
357356
} => add_with_opts(blobs, addr, path, options).await,
358357
Self::Share {
359358
hash,
360-
addr_options,
361359
recursive,
362360
debug,
363361
} => {
@@ -367,8 +365,6 @@ impl BlobCommands {
367365
BlobFormat::Raw
368366
};
369367
let status = blobs.status(hash).await?;
370-
let mut addr = addr;
371-
addr.apply_options(addr_options);
372368
let ticket = BlobTicket::new(addr, hash, format)?;
373369

374370
let (blob_status, size) = match (status, format) {

src/downloader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ use anyhow::anyhow;
4646
use futures_lite::{future::BoxedLocal, Stream, StreamExt};
4747
use hashlink::LinkedHashSet;
4848
use iroh::{endpoint, Endpoint, NodeAddr, NodeId};
49-
use iroh_base::hash::{BlobFormat, Hash, HashAndFormat};
5049
use iroh_metrics::inc;
5150
use tokio::{
5251
sync::{mpsc, oneshot},
@@ -60,6 +59,7 @@ use crate::{
6059
metrics::Metrics,
6160
store::Store,
6261
util::{local_pool::LocalPoolHandle, progress::ProgressSender},
62+
BlobFormat, Hash, HashAndFormat,
6363
};
6464

6565
mod get;

src/get/db.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use genawaiter::{
1010
GeneratorState,
1111
};
1212
use iroh::endpoint::Connection;
13-
use iroh_base::hash::Hash;
1413
use iroh_io::AsyncSliceReader;
1514
use serde::{Deserialize, Serialize};
1615
use tokio::sync::oneshot;
@@ -31,7 +30,7 @@ use crate::{
3130
Store as BaoStore,
3231
},
3332
util::progress::{IdGenerator, ProgressSender},
34-
BlobFormat, HashAndFormat,
33+
BlobFormat, Hash, HashAndFormat,
3534
};
3635

3736
type GetGenerator = Gen<Yield, (), Pin<Box<dyn Future<Output = Result<Stats, GetError>>>>>;

0 commit comments

Comments
 (0)