diff --git a/Cargo.lock b/Cargo.lock index 58d4b0a..53a3a9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -897,9 +897,9 @@ dependencies = [ [[package]] name = "iroh-io" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d1047ad5ca29ab4ff316b6830d86e7ea52cea54325e4d4a849692e1274b498" +checksum = "e0a5feb781017b983ff1b155cd1faf8174da2acafd807aa482876da2d7e6577a" dependencies = [ "bytes", "futures-lite", diff --git a/Cargo.toml b/Cargo.toml index eba6126..a500e5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ smallvec = "1" bytes = { version = "1" } futures-lite = { version = "2.3", optional = true } self_cell = { version = "1" } -iroh-io = { version = "0.6.0", default-features = false, optional = true } +iroh-io = { version = "0.6.2", default-features = false, optional = true } positioned-io = { version = "0.3.1", default-features = false } genawaiter = { version = "0.99.1", features = ["futures03"], optional = true } tokio = { version = "1", features = ["sync"], default-features = false, optional = true } @@ -42,7 +42,7 @@ proptest = "1.0.0" rand = "0.8.5" criterion = "0.4.0" tempfile = "3.6.0" -iroh-io = { version = "0.6.0" } +iroh-io = { version = "0.6.2" } warp = "0.3.5" proc-macro2 = "1.0.66" test-strategy = "0.3.1" diff --git a/src/io/fsm.rs b/src/io/fsm.rs index 99fd94a..5c64e01 100644 --- a/src/io/fsm.rs +++ b/src/io/fsm.rs @@ -430,7 +430,7 @@ impl ResponseDecoder { let this = &mut self.0; let data = this .encoded - .read_bytes(size) + .read_bytes_exact(size) .await .map_err(|e| DecodeError::maybe_leaf_not_found(e, start_chunk))?; let leaf_hash = this.stack.pop().unwrap(); @@ -482,7 +482,7 @@ where start_chunk, size, .. } => { let start = start_chunk.to_bytes(); - let bytes = data.read_at(start, size).await?; + let bytes = data.read_exact_at(start, size).await?; encoded .write_bytes(bytes) .await @@ -555,7 +555,7 @@ where } => { let expected = stack.pop().unwrap(); let start = start_chunk.to_bytes(); - let bytes = data.read_at(start, size).await?; + let bytes = data.read_exact_at(start, size).await?; let (actual, to_write) = if !ranges.is_all() { // we need to encode just a part of the data // @@ -669,7 +669,7 @@ async fn outboard_impl( start_chunk, .. } => { - let buf = data.read_bytes(size).await?; + let buf = data.read_bytes_exact(size).await?; let hash = hash_subtree(start_chunk.0, &buf, is_root); stack.push(hash); } @@ -722,7 +722,7 @@ async fn outboard_post_order_impl( start_chunk, .. } => { - let buf = data.read_bytes(size).await?; + let buf = data.read_bytes_exact(size).await?; let hash = hash_subtree(start_chunk.0, &buf, is_root); stack.push(hash); } @@ -802,7 +802,9 @@ mod validate { if tree.blocks() == 1 { // special case for a tree that fits in one block / chunk group let mut data = data; - let data = data.read_at(0, tree.size().try_into().unwrap()).await?; + let data = data + .read_exact_at(0, tree.size().try_into().unwrap()) + .await?; let actual = hash_subtree(0, &data, true); if actual == outboard.root() { co.yield_(Ok(ChunkNum(0)..tree.chunks())).await; @@ -831,7 +833,7 @@ mod validate { is_root: bool, ) -> io::Result<()> { let len = (range.end - range.start).try_into().unwrap(); - let data = self.data.read_at(range.start, len).await?; + let data = self.data.read_exact_at(range.start, len).await?; // is_root is always false because the case of a single chunk group is handled before calling this function let actual = hash_subtree(ChunkNum::full_chunks(range.start).0, &data, is_root); if &actual == hash {