Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(network): drop the [2,…] message tag wrapper from the rejection reason #548

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
17 changes: 6 additions & 11 deletions pallas-network/src/miniprotocols/localtxsubmission/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand All @@ -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),
Expand Down Expand Up @@ -101,7 +91,12 @@ impl Encode<()> for EraTx {

impl<'b> Decode<'b, ()> for RejectReason {
fn decode(d: &mut Decoder<'b>, _ctx: &mut ()) -> Result<Self, decode::Error> {
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))
}
}
Expand Down