Skip to content

Commit b884a0c

Browse files
ppodolskyFrandorklaehn
committed
merge (#5)
* refactor: downloader * test: add test for concurrent progress reporting * chore: cleanup * refactor: rename some things for clarity * feat: limit concurrent dials per download * chore: cleanup * refactor: respect progress sender IDs to allow reusing the senders in subsequent operations * chore: fmt & clippy * cleanup: shared download progress * feat: handle tags in the downloader * fix: visibility * fixup * fixup * chore: clippy * fixup * refactor: make export a seperate operation from download * fixup after merge * refactor: remove id mapping * refactor: move BlobId up to the progress events * fix tests * cleanup * fix: invariants * fixes and cleanups * fix: nodes_have should only add to queued downloads * chore: fmt * chore: clippy! * fix: do not queue downloads with no providers * feat: set more than one node on download requests (n0-computer#2128) ## Description Based on n0-computer#2085 The downloader already has the feature to try multiple nodes for a single hash or hashseq. With n0-computer#2085 we expose the downloader over the RPC protocol, by adding a `DownloadMode { Queued, Direct }` enum to the `BlobDownloadRequest`. This PR modifies the `BlobDownloadRequest` to include a list of provider nodes for a hash instead of just a single node. For queued requests that go to the downloader, the nodes are just passed to the downloader. For direct requests, the nodes are tried in-order, until one succeeds. ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist - [ ] Self-review. - [ ] Documentation updates if relevant. - [ ] Tests if relevant. * fix: address review by divma * fix: remove now obsolete into_send method from ProgressSender * chore: remove unused code * fix: use Display for DownloadKind * fix: first round of changes after review * docs: downloader next_step * more review * more review * fix: only remove hashes from provider map if they are really not needed * refactor: move TagSet into util * refactor: store intents in request info * cleanup * refactor: no allocation in next_step and simpler code * fix: test after merge * refactor: better method * fix(iroh-bytes): do not log redundant file delete error (n0-computer#2199) ## Description fix(iroh-bytes): do not log when a file can not be deleted... because it is not there. this makes the delete op idempotent, and also helps in case the file was not there in the first place. Fixes n0-computer#2142 ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist - [ ] Self-review. - [ ] Documentation updates if relevant. - [ ] Tests if relevant. * fix(iroh-dns-server): fix bug in pkarr name parsing (n0-computer#2200) ## Description The order of labels when parsing a DNS query as pkarr name was reversed. This means all queries for second-level subdomains under a pkarr pubkey failed. * First commit is the actual fix. * Second commit adds a test for various record name and type variations * Third and forth commit improve the debug and info logging ## Notes & open questions Was discovered by @rklaehn in n0-computer#2188 and fixes the wrong behavior observed there. ## Change checklist - [x] Self-review. - [x] Documentation updates if relevant. - [x] Tests if relevant. --------- Co-authored-by: Franz Heinzmann (Frando) <[email protected]> Co-authored-by: Rüdiger Klaehn <[email protected]>
1 parent 1373b2d commit b884a0c

File tree

25 files changed

+1743
-897
lines changed

25 files changed

+1743
-897
lines changed

Cargo.lock

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

iroh-base/src/hash.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use bao_tree::blake3;
77
use postcard::experimental::max_size::MaxSize;
88
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
99

10-
use crate::base32::{parse_array_hex_or_base32, HexOrBase32ParseError};
10+
use crate::base32::{self, parse_array_hex_or_base32, HexOrBase32ParseError};
1111

1212
/// Hash type used throughout.
1313
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
@@ -54,6 +54,12 @@ impl Hash {
5454
pub fn to_hex(&self) -> String {
5555
self.0.to_hex().to_string()
5656
}
57+
58+
/// Convert to a base32 string limited to the first 10 bytes for a friendly string
59+
/// representation of the hash.
60+
pub fn fmt_short(&self) -> String {
61+
base32::fmt_short(self.as_bytes())
62+
}
5763
}
5864

5965
impl AsRef<[u8]> for Hash {
@@ -173,7 +179,18 @@ impl MaxSize for Hash {
173179

174180
/// A format identifier
175181
#[derive(
176-
Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Default, Debug, MaxSize,
182+
Clone,
183+
Copy,
184+
PartialEq,
185+
Eq,
186+
PartialOrd,
187+
Ord,
188+
Serialize,
189+
Deserialize,
190+
Default,
191+
Debug,
192+
MaxSize,
193+
Hash,
177194
)]
178195
pub enum BlobFormat {
179196
/// Raw blob
@@ -205,7 +222,7 @@ impl BlobFormat {
205222
}
206223

207224
/// A hash and format pair
208-
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, MaxSize)]
225+
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, MaxSize, Hash)]
209226
pub struct HashAndFormat {
210227
/// The hash
211228
pub hash: Hash,
@@ -289,6 +306,11 @@ mod redb_support {
289306
}
290307

291308
impl HashAndFormat {
309+
/// Create a new hash and format pair.
310+
pub fn new(hash: Hash, format: BlobFormat) -> Self {
311+
Self { hash, format }
312+
}
313+
292314
/// Create a new hash and format pair, using the default (raw) format.
293315
pub fn raw(hash: Hash) -> Self {
294316
Self {

iroh-bytes/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ flume = "0.11"
2525
futures = "0.3.25"
2626
futures-buffered = "0.2.4"
2727
genawaiter = { version = "0.99.1", features = ["futures03"] }
28+
hashlink = { version = "0.9.0", optional = true }
2829
hex = "0.4.3"
2930
iroh-base = { version = "0.14.0", features = ["redb"], path = "../iroh-base" }
3031
iroh-io = { version = "0.6.0", features = ["stats"] }
@@ -51,6 +52,7 @@ tracing-futures = "0.2.5"
5152

5253
[dev-dependencies]
5354
http-body = "0.4.5"
55+
iroh-bytes = { path = ".", features = ["downloader"] }
5456
iroh-test = { path = "../iroh-test" }
5557
proptest = "1.0.0"
5658
serde_json = "1.0.107"
@@ -63,8 +65,8 @@ tempfile = "3.10.0"
6365

6466
[features]
6567
default = ["fs-store"]
68+
downloader = ["iroh-net", "parking_lot", "tokio-util/time", "hashlink"]
6669
fs-store = ["reflink-copy", "redb", "redb_v1", "tempfile"]
67-
downloader = ["iroh-net", "parking_lot", "tokio-util/time"]
6870
metrics = ["iroh-metrics"]
6971

7072
[[example]]

0 commit comments

Comments
 (0)