From de571b1427bc7d519c0e4943461f4311203b299c Mon Sep 17 00:00:00 2001 From: Michal Rus Date: Thu, 21 Nov 2024 15:12:55 +0100 Subject: [PATCH] =?UTF-8?q?fix(network):=20drop=20the=20`[2,=E2=80=A6]`=20?= =?UTF-8?q?message=20tag=20wrapper=20from=20the=20rejection=20reason?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../miniprotocols/localtxsubmission/codec.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pallas-network/src/miniprotocols/localtxsubmission/codec.rs b/pallas-network/src/miniprotocols/localtxsubmission/codec.rs index 1a1fe364..aefc8b9d 100644 --- a/pallas-network/src/miniprotocols/localtxsubmission/codec.rs +++ b/pallas-network/src/miniprotocols/localtxsubmission/codec.rs @@ -42,11 +42,6 @@ impl<'b, Tx: Decode<'b, ()>, Reject: Decode<'b, ()>> Decode<'b, ()> for Message< // if the first element isn't an array, it's a plutus error // the node sends string data let rejection = d.decode()?; - - // skip this data via setting the decoder position, because it doesn't recognize - // it with rejection decode - d.set_position(d.input().len()); - return Ok(Message::RejectTx(rejection)); } @@ -60,11 +55,6 @@ impl<'b, Tx: Decode<'b, ()>, Reject: Decode<'b, ()>> Decode<'b, ()> for Message< 1 => Ok(Message::AcceptTx), 2 => { let rejection = d.decode()?; - - // skip this data via setting the decoder position, because it doesn't recognize - // it with rejection decode - d.set_position(d.input().len()); - Ok(Message::RejectTx(rejection)) } 3 => Ok(Message::Done), @@ -101,7 +91,12 @@ impl Encode<()> for EraTx { impl<'b> Decode<'b, ()> for RejectReason { fn decode(d: &mut Decoder<'b>, _ctx: &mut ()) -> Result { - let remainder = d.input().to_vec(); + // `d.input()` is the entire input; we just want it starting at where we stopped decoding: + let start_pos = d.position(); + let remainder = d.input()[start_pos..].to_vec(); + // skip this data via setting the decoder position, because it doesn't recognize + // it with rejection decode + d.set_position(d.input().len()); Ok(RejectReason(remainder)) } }