Skip to content

Commit

Permalink
Add nits
Browse files Browse the repository at this point in the history
  • Loading branch information
Shourya742 committed Jul 18, 2024
1 parent 5abba8f commit f25da58
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
44 changes: 20 additions & 24 deletions roles/jd-server/src/lib/job_declarator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,37 +481,18 @@ impl JobDeclarator {
1,
);

let sv2_frame: StdFrame = if is_valid {
if is_valid {
let success_message = SetupConnectionSuccess {
used_version: 2,
flags: 0b_0000_0000_0000_0000_0000_0000_0000_0001,
};
info!("Sending success message for proxy");
JdsMessages::Common(success_message.into())
.try_into()
.expect(
"Failed to convert setup connection response message to standard frame"
)
} else {
let error_message = SetupConnectionError {
flags: flag,
error_code: "unsupported-feature-flags"
.to_string()
.into_bytes()
.try_into()
.unwrap(),
};
info!("Sending error message for proxy");
JdsMessages::Common(error_message.into())
.try_into()
.expect(
"Failed to convert setup connection response message to standard frame"
)
};
let sv2_frame: StdFrame = JdsMessages::Common(success_message.into())
.try_into()
.expect("Failed to convert setup connection response message to standard frame");

sender.send(sv2_frame.into()).await.unwrap();
sender.send(sv2_frame.into()).await.unwrap();

if is_valid {
let jddownstream =
Arc::new(Mutex::new(JobDeclaratorDownstream::new(
receiver.clone(),
Expand All @@ -526,6 +507,21 @@ impl JobDeclarator {
status_tx.clone(),
new_block_sender.clone(),
);
} else {
let error_message = SetupConnectionError {
flags: flag,
error_code: "unsupported-feature-flags"
.to_string()
.into_bytes()
.try_into()
.unwrap(),
};
info!("Sending error message for proxy");
let sv2_frame: StdFrame = JdsMessages::Common(error_message.into())
.try_into()
.expect("Failed to convert setup connection response message to standard frame");

sender.send(sv2_frame.into()).await.unwrap();
}
} else {
error!("Error parsing SetupConnection message");
Expand Down
2 changes: 1 addition & 1 deletion test/message-generator/messages/common_messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"protocol": 1,
"min_version": 2,
"max_version": 2,
"flags": 6,
"flags": 0,
"endpoint_host": "",
"endpoint_port": 0,
"vendor": "",
Expand Down

0 comments on commit f25da58

Please sign in to comment.