@@ -89,7 +89,7 @@ impl P2pNetworkYamuxState {
8989 }
9090 }
9191 1 => {
92- let difference = i32 :: from_be_bytes ( b) ;
92+ let difference = u32 :: from_be_bytes ( b) ;
9393 let frame = YamuxFrame {
9494 flags,
9595 stream_id,
@@ -100,7 +100,7 @@ impl P2pNetworkYamuxState {
100100 continue ;
101101 }
102102 2 => {
103- let opaque = i32 :: from_be_bytes ( b) ;
103+ let opaque = u32 :: from_be_bytes ( b) ;
104104 let frame = YamuxFrame {
105105 flags,
106106 stream_id,
@@ -348,16 +348,9 @@ impl P2pNetworkYamuxState {
348348 } ) ;
349349 }
350350 }
351- YamuxFrameInner :: WindowUpdate { difference } => {
352- if * difference < 0 {
353- let error =
354- P2pNetworkConnectionError :: YamuxBadWindowUpdate ( frame. stream_id ) ;
355- dispatcher. push ( P2pNetworkSchedulerAction :: Error { addr, error } ) ;
356- } else {
357- while let Some ( frame) = pending_outgoing. pop_front ( ) {
358- dispatcher
359- . push ( P2pNetworkYamuxAction :: OutgoingFrame { addr, frame } ) ;
360- }
351+ YamuxFrameInner :: WindowUpdate { .. } => {
352+ while let Some ( frame) = pending_outgoing. pop_front ( ) {
353+ dispatcher. push ( P2pNetworkYamuxAction :: OutgoingFrame { addr, frame } ) ;
361354 }
362355 }
363356 _ => { }
@@ -481,22 +474,13 @@ impl P2pNetworkYamuxState {
481474}
482475
483476impl YamuxStreamState {
484- pub fn update_window ( & mut self , ours : bool , difference : i32 ) {
477+ pub fn update_window ( & mut self , ours : bool , difference : u32 ) {
485478 let window = if ours {
486479 & mut self . window_ours
487480 } else {
488481 & mut self . window_theirs
489482 } ;
490- if difference < 0 {
491- let decreasing = ( -difference) as u32 ;
492- if * window < decreasing {
493- * window = 0 ;
494- } else {
495- * window = ( * window) . wrapping_sub ( decreasing) ;
496- }
497- } else {
498- let increasing = difference as u32 ;
499- * window = ( * window) . wrapping_add ( increasing) ;
500- }
483+
484+ * window = ( * window) . wrapping_add ( difference) ;
501485 }
502486}
0 commit comments