You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.retain(|sent_packet| sent_packet.sent_at > now - SENT_PACKETS_MAX_SIZE);
111
+
.retain(|_,sent_packet| sent_packet.sent_at > now - SENT_PACKETS_MAX_SIZE);
112
112
113
113
self.evaluate();
114
114
}
@@ -121,13 +121,27 @@ impl TwccTxState {
121
121
122
122
letmut lost = 0;
123
123
124
-
for i in1..self.sent_packets.len(){
125
-
let lhs = &self.sent_packets[i];
126
-
let rhs = &self.sent_packets[i - 1];
124
+
let(min_seq, _) = self
125
+
.sent_packets
126
+
.iter()
127
+
.min_by_key(|(_, x)| x.sent_at)
128
+
.unwrap();
127
129
128
-
if rhs.sequence_number != lhs.sequence_number.wrapping_sub(1){
129
-
continue;
130
-
}
130
+
let(max_seq, _) = self
131
+
.sent_packets
132
+
.iter()
133
+
.max_by_key(|(_, x)| x.sent_at)
134
+
.unwrap();
135
+
136
+
letmut seq = *min_seq;
137
+
138
+
while seq != *max_seq {
139
+
let next_seq = seq.wrapping_add(1);
140
+
141
+
let lhs = self.sent_packets.get(&seq).unwrap();
142
+
let rhs = self.sent_packets.get(&next_seq).unwrap();
143
+
144
+
seq = next_seq;
131
145
132
146
let lhs_sent_at = lhs
133
147
.sent_at
@@ -168,14 +182,18 @@ impl TwccTxState {
168
182
let d = lhs_d - rhs_d;
169
183
170
184
{
185
+
//TODO: doesn't really need a loop. The delta can be cached in SentPacket and the lowest delta can be stored globally with an index/seq and updated when needed?
0 commit comments