From 7eefd4fc381c33a283ea89afd4e72bf0a38508e7 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 30 Sep 2020 23:19:00 +0100 Subject: [PATCH] refactor WRC handling Signed-off-by: Ian Jackson --- src/updates.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/updates.rs b/src/updates.rs index 72d792c8..5fe1e590 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -419,14 +419,6 @@ impl<'r> Drop for PrepareUpdatesBuffer<'r> { type WRC = WhatResponseToClientOp; impl PreparedUpdate { - fn is_client(by_client: &IsResponseToClientOp, - ref_client: ClientId) -> Option { - match by_client { - &Some((_,c,cseq)) if c == ref_client => Some(cseq), - _ => None, - } - } - pub fn for_transmit(&self, dest : ClientId) -> TransmitUpdate { type ESVU = ErrorSignaledViaUpdate; type PUE = PreparedUpdateEntry; @@ -442,19 +434,19 @@ impl PreparedUpdate { Exactly(TransmitUpdateEntry<'u>), Piece, }; - let ftg = if let Some(cseq) = Self::is_client(&by_client, dest) { - match by_client.unwrap().0 { - WRC::Predictable => FTG::Recorded(cseq, None), - WRC::UpdateSvg => FTG::Recorded(cseq, ns()), - WRC::Unpredictable => if let Some(ns) = ns() { + let ftg = match by_client { + None => FTG::Piece, + Some((_,u_client,_)) if u_client != dest => FTG::Piece, + Some((WRC::Predictable ,_,cseq)) => FTG::Recorded(cseq, None), + Some((WRC::UpdateSvg ,_,cseq)) => FTG::Recorded(cseq, ns()), + Some((WRC::Unpredictable,_,cseq)) => { + if let Some(ns) = ns() { FTG::Exactly(TUE::RecordedUnpredictable { piece, cseq, ns }) } else { error!("internal error: for_transmit PreparedUpdateEntry::Piece with RecordedUnpredictable but PieceOp no NS"); FTG::Piece } } - } else { - FTG::Piece }; match ftg { FTG::Recorded(cseq, ns) => { -- 2.30.2