Skip to content

Commit 6449930

Browse files
committed
clippy
1 parent 1e4a581 commit 6449930

File tree

6 files changed

+192
-264
lines changed

6 files changed

+192
-264
lines changed

src/api/blobs.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ use super::{
5757
};
5858
use crate::{
5959
api::proto::{BatchRequest, ImportByteStreamUpdate},
60-
provider::WriterContext,
6160
store::IROH_BLOCK_SIZE,
6261
util::temp_tag::TempTag,
6362
BlobFormat, Hash, HashAndFormat,
@@ -1167,19 +1166,3 @@ pub(crate) trait WriteProgress {
11671166
/// Notify the progress writer that a transfer has started.
11681167
async fn send_transfer_started(&mut self, index: u64, hash: &Hash, size: u64);
11691168
}
1170-
1171-
impl WriteProgress for WriterContext {
1172-
async fn notify_payload_write(&mut self, _index: u64, offset: u64, len: usize) {
1173-
let end_offset = offset + len as u64;
1174-
self.payload_bytes_written += len as u64;
1175-
self.tracker.transfer_progress(end_offset).await.ok();
1176-
}
1177-
1178-
fn log_other_write(&mut self, len: usize) {
1179-
self.other_bytes_written += len as u64;
1180-
}
1181-
1182-
async fn send_transfer_started(&mut self, index: u64, hash: &Hash, size: u64) {
1183-
self.tracker.transfer_started(index, hash, size).await.ok();
1184-
}
1185-
}

src/net_protocol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl BlobsProtocol {
7474
inner: Arc::new(BlobsInner {
7575
store: store.clone(),
7676
endpoint,
77-
events: events.unwrap_or(EventSender::NONE),
77+
events: events.unwrap_or(EventSender::DEFAULT),
7878
}),
7979
}
8080
}

src/protocol.rs

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ pub use range_spec::{ChunkRangesSeq, NonEmptyRequestRangeSpecIter, RangeSpec};
392392
use snafu::{GenerateImplicitData, Snafu};
393393
use tokio::io::AsyncReadExt;
394394

395-
use crate::{api::blobs::Bitfield, provider::CountingReader, BlobFormat, Hash, HashAndFormat};
395+
use crate::{api::blobs::Bitfield, provider::RecvStreamExt, BlobFormat, Hash, HashAndFormat};
396396

397397
/// Maximum message size is limited to 100MiB for now.
398398
pub const MAX_MESSAGE_SIZE: usize = 1024 * 1024;
@@ -441,9 +441,7 @@ pub enum RequestType {
441441
}
442442

443443
impl Request {
444-
pub async fn read_async(
445-
reader: &mut CountingReader<&mut iroh::endpoint::RecvStream>,
446-
) -> io::Result<Self> {
444+
pub async fn read_async(reader: &mut iroh::endpoint::RecvStream) -> io::Result<(Self, usize)> {
447445
let request_type = reader.read_u8().await?;
448446
let request_type: RequestType = postcard::from_bytes(std::slice::from_ref(&request_type))
449447
.map_err(|_| {
@@ -453,22 +451,31 @@ impl Request {
453451
)
454452
})?;
455453
Ok(match request_type {
456-
RequestType::Get => reader
457-
.read_to_end_as::<GetRequest>(MAX_MESSAGE_SIZE)
458-
.await?
459-
.into(),
460-
RequestType::GetMany => reader
461-
.read_to_end_as::<GetManyRequest>(MAX_MESSAGE_SIZE)
462-
.await?
463-
.into(),
464-
RequestType::Observe => reader
465-
.read_to_end_as::<ObserveRequest>(MAX_MESSAGE_SIZE)
466-
.await?
467-
.into(),
468-
RequestType::Push => reader
469-
.read_length_prefixed::<PushRequest>(MAX_MESSAGE_SIZE)
470-
.await?
471-
.into(),
454+
RequestType::Get => {
455+
let (r, size) = reader
456+
.read_to_end_as::<GetRequest>(MAX_MESSAGE_SIZE)
457+
.await?;
458+
(r.into(), size)
459+
}
460+
RequestType::GetMany => {
461+
let (r, size) = reader
462+
.read_to_end_as::<GetManyRequest>(MAX_MESSAGE_SIZE)
463+
.await?;
464+
(r.into(), size)
465+
}
466+
RequestType::Observe => {
467+
let (r, size) = reader
468+
.read_to_end_as::<ObserveRequest>(MAX_MESSAGE_SIZE)
469+
.await?;
470+
(r.into(), size)
471+
}
472+
RequestType::Push => {
473+
let r = reader
474+
.read_length_prefixed::<PushRequest>(MAX_MESSAGE_SIZE)
475+
.await?;
476+
let size = postcard::experimental::serialized_size(&r).unwrap();
477+
(r.into(), size)
478+
}
472479
_ => {
473480
return Err(io::Error::new(
474481
io::ErrorKind::InvalidData,

0 commit comments

Comments
 (0)