Skip to content

Commit

Permalink
fix: add max selective act generation size
Browse files Browse the repository at this point in the history
  • Loading branch information
KolbyML committed Jan 30, 2025
1 parent 3e5d331 commit c94c80c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/recv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ use crate::seq::CircularRangeInclusive;

type Bytes = Vec<u8>;

// https://github.com/ethereum/utp/issues/139
// Maximum number of selective ACKs that can fit within the length of 8 bits
const MAX_SELECTIVE_ACK_COUNT: usize = 32 * 63;

#[derive(Clone, Debug)]
pub struct ReceiveBuffer<const N: usize> {
buf: Box<[u8; N]>,
Expand Down Expand Up @@ -112,7 +116,7 @@ impl<const N: usize> ReceiveBuffer<N> {
let mut pending_packets = self.pending.keys().copied().collect::<HashSet<_>>();

let mut acked = vec![];
while !pending_packets.is_empty() {
while !pending_packets.is_empty() && acked.len() < MAX_SELECTIVE_ACK_COUNT {
if pending_packets.remove(&last_ack) {
acked.push(true);
} else {
Expand Down

0 comments on commit c94c80c

Please sign in to comment.