Skip to content

Commit

Permalink
Simplify processing of incoming requests with payload by checking if …
Browse files Browse the repository at this point in the history
…it is non-ficticious every time
  • Loading branch information
marc-casperlabs committed Dec 18, 2023
1 parent 90a8c8e commit e3c4ff6
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,11 +895,8 @@ impl<const N: usize> JulietProtocol<N> {
}
}
Kind::ResponsePl => {
let is_new_response =
channel.current_multiframe_receiver.is_new_transfer(header);

// Ensure it is not a bogus response.
if is_new_response && !channel.outgoing_requests.contains(&header.id()) {
if !channel.outgoing_requests.contains(&header.id()) {
return err_msg(header, ErrorKind::FictitiousRequest);
}

Expand All @@ -912,13 +909,10 @@ impl<const N: usize> JulietProtocol<N> {
ErrorKind::ResponseTooLarge
));

// If we made it to this point, we have consumed the frame.
if is_new_response && !channel.outgoing_requests.remove(&header.id()) {
return err_msg(header, ErrorKind::FictitiousRequest);
}

if let Some(payload) = multiframe_outcome {
// Message is complete.
// Message is complete. Remove it from the outgoing requests.
channel.outgoing_requests.remove(&header.id());

let payload = payload.freeze();

return Success(CompletedRead::ReceivedResponse {
Expand Down

0 comments on commit e3c4ff6

Please sign in to comment.