diff --git a/hptp-send/src/main.rs b/hptp-send/src/main.rs index 5461f73..dbd7a98 100644 --- a/hptp-send/src/main.rs +++ b/hptp-send/src/main.rs @@ -119,9 +119,11 @@ where } } - fn ack(&mut self, seg_idx: SegIdx) { - self.unacked_segs.remove(&seg_idx); - // TODO: update bounds + /// `seg_idxs` should be distinct and in increasing order. + fn ack(&mut self, seg_idxs: &[SegIdx]) { + for seg_idx in seg_idxs { + self.unacked_segs.remove(seg_idx); + } } } @@ -149,13 +151,12 @@ where let mut store = SegmentStore::new(inp); let mut deadline = Instant::now(); - const DELAY_MS: u64 = 250; + const DELAY_MS: u64 = 100; let mut to_send = vec![]; loop { let timer = tokio::time::delay_until(deadline); - let evt = tokio::select!( _ = timer => Evt::Timer, Ok(m) = peer.recv() => Evt::Recv(m), @@ -173,15 +174,13 @@ where }); Action::Continue } - None => { - log.completed().await; - Action::Quit - } + None => Action::Quit, } } - Evt::Recv(m) => { - log.debug_msg(format!("{:?}", m)).await; + Evt::Recv(DownMsg::Ack { idxs }) => { + log.debug_msg(format!("got acks: {:?}", idxs)).await; + store.ack(&idxs); Action::Continue } };