Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions rs/moq-net/src/route/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ enum SentState<A> {
struct SentOffer<A> {
offer: Offer,
/// The prefix of the view its claims were presented from, or `None` once an edit
/// rekeyed it: the next batch is diffed against all it holds.
/// rekeyed it or it was held or kept, missing batches: the next batch is diffed
/// against all it holds.
from: Option<Path>,
view: View<A>,
}
Expand Down Expand Up @@ -378,6 +379,14 @@ impl<A> Sent<A> {
};
self.state = SentState::Held(sent);
}
self.behind();
}

/// It is sent nothing for now, so its next batch is diffed against all it holds.
fn behind(&mut self) {
if let SentState::Live(sent) | SentState::Held(sent) = &mut self.state {
sent.from = None;
}
}

fn end(&mut self) {
Expand Down Expand Up @@ -3006,7 +3015,11 @@ impl<N: Key, A: Item> Router<N, A> {
let sent = self.answering[&peer].tx.get(&key);
let on = sent.is_some_and(|sent| sent.offer().is_some());
match want {
Want::Keep => {}
Want::Keep => {
if let Some(sent) = self.answering.get_mut(&peer).expect("answering").tx.get_mut(&key) {
sent.behind();
}
}
Want::Hold => {
if on && !sent.expect("sent").held() {
self.answering
Expand Down Expand Up @@ -3141,16 +3154,7 @@ impl<N: Key, A: Item> Router<N, A> {
let changes: Vec<(Path, Option<A>)> = match (sent, dirty.all || fresh) {
(Some(sent), false) => {
let old = &sent.active().expect("offered").view;
let mut claims: BTreeSet<&Path> = dirty.claims.iter().collect();
// A held stream may have missed withdrawals the local reader already
// consumed. When its region changes, include its own previous claims.
for region in &dirty.regions {
if let Some(region) = meet(prefix, region) {
claims.extend(below(&old.items, &region).map(|(claim, _)| claim));
}
}
let mut changes: Vec<(&Path, Option<A>)> = claims
.into_iter()
let mut changes: Vec<(&Path, Option<A>)> = (dirty.claims.iter())
.filter(|claim| within(claim, prefix) && *claim != prefix)
.map(|claim| (claim, view.items.get(claim).cloned()))
.collect();
Expand Down