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
9 changes: 5 additions & 4 deletions p2p/src/network/yamux/p2p_network_yamux_reducer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ impl P2pNetworkYamuxState {
if let Some(stream) = yamux_state.streams.get_mut(&frame.stream_id) {
// must not underflow
// TODO: check it and disconnect peer that violates flow rules
stream.window_ours -= data.len() as u32;
stream.window_ours =
stream.window_ours.wrapping_sub(data.len() as u32);
}
}
YamuxFrameInner::WindowUpdate { difference } => {
Expand Down Expand Up @@ -334,7 +335,7 @@ impl P2pNetworkYamuxState {
// must not underflow
// the action must not dispatch if it doesn't fit in the window
// TODO: add pending queue, where frames will wait for window increase
stream.window_theirs -= data.len() as u32;
stream.window_theirs = stream.window_theirs.wrapping_sub(data.len() as u32);
}
YamuxFrameInner::WindowUpdate { difference } => {
stream.update_window(true, *difference);
Expand Down Expand Up @@ -417,11 +418,11 @@ impl YamuxStreamState {
if *window < decreasing {
*window = 0;
} else {
*window -= decreasing;
*window = (*window).wrapping_sub(decreasing);
}
} else {
let increasing = difference as u32;
*window += increasing;
*window = (*window).wrapping_add(increasing);
}
}
}
Loading