From d185f35333996142e112699f9709db509d21a53e Mon Sep 17 00:00:00 2001 From: jbesraa Date: Thu, 4 Jul 2024 15:02:35 +0300 Subject: [PATCH] Change `Sv2Frame::get_header` to `header` and .. Remove `Option` from its return type. --- benches/benches/src/sv2/iai_sv2_benchmark.rs | 6 ++--- examples/interop-cpp/src/main.rs | 2 +- protocols/v2/framing-sv2/src/framing.rs | 6 ++--- protocols/v2/sv2-ffi/src/lib.rs | 27 +++++++++---------- roles/jd-client/src/lib/downstream.rs | 4 +-- roles/jd-client/src/lib/job_declarator/mod.rs | 2 +- .../lib/job_declarator/setup_connection.rs | 2 +- .../src/lib/template_receiver/mod.rs | 8 +++--- .../lib/template_receiver/setup_connection.rs | 2 +- .../src/lib/upstream_sv2/upstream.rs | 15 ++--------- roles/jd-server/src/lib/job_declarator/mod.rs | 5 +--- .../mining-proxy/src/lib/downstream_mining.rs | 4 +-- roles/mining-proxy/src/lib/upstream_mining.rs | 8 +++--- roles/pool/src/lib/mining_pool/mod.rs | 5 +--- .../src/lib/mining_pool/setup_connection.rs | 5 +--- roles/pool/src/lib/template_receiver/mod.rs | 5 +--- .../lib/template_receiver/setup_connection.rs | 5 +--- roles/test-utils/mining-device/src/main.rs | 4 +-- .../src/lib/upstream_sv2/upstream.rs | 15 ++--------- utils/message-generator/src/executor.rs | 2 +- utils/message-generator/src/main.rs | 4 +-- 21 files changed, 48 insertions(+), 88 deletions(-) diff --git a/benches/benches/src/sv2/iai_sv2_benchmark.rs b/benches/benches/src/sv2/iai_sv2_benchmark.rs index 9965f9f01e..d052981f2b 100644 --- a/benches/benches/src/sv2/iai_sv2_benchmark.rs +++ b/benches/benches/src/sv2/iai_sv2_benchmark.rs @@ -46,7 +46,7 @@ fn client_sv2_setup_connection_serialize_deserialize() { let mut dst = vec![0; size]; frame.serialize(&mut dst); let mut frame = StdFrame::from_bytes(black_box(dst.clone().into())).unwrap(); - let type_ = frame.get_header().unwrap().msg_type().clone(); + let type_ = frame.header().msg_type().clone(); let payload = frame.payload().unwrap(); black_box(AnyMessage::try_from((type_, payload))); } @@ -77,7 +77,7 @@ fn client_sv2_open_channel_serialize_deserialize() { let mut dst = vec![0; size]; frame.serialize(&mut dst); let mut frame = StdFrame::from_bytes(black_box(dst.clone().into())).unwrap(); - let type_ = frame.get_header().unwrap().msg_type().clone(); + let type_ = frame.header().msg_type().clone(); let payload = frame.payload().unwrap(); black_box(AnyMessage::try_from((type_, payload))); } @@ -127,7 +127,7 @@ fn client_sv2_mining_message_submit_standard_serialize_deserialize() { let mut dst = vec![0; size]; frame.serialize(&mut dst); let mut frame = StdFrame::from_bytes(black_box(dst.clone().into())).unwrap(); - let type_ = frame.get_header().unwrap().msg_type().clone(); + let type_ = frame.header().msg_type().clone(); let payload = frame.payload().unwrap(); black_box(AnyMessage::try_from((type_, payload))); } diff --git a/examples/interop-cpp/src/main.rs b/examples/interop-cpp/src/main.rs index 90fd0e7886..c03f01d382 100644 --- a/examples/interop-cpp/src/main.rs +++ b/examples/interop-cpp/src/main.rs @@ -126,7 +126,7 @@ mod main_ { let buffer = decoder.writable(); stream.read_exact(buffer).unwrap(); if let Ok(mut f) = decoder.next_frame() { - let msg_type = f.get_header().unwrap().msg_type(); + let msg_type = f.header().msg_type(); let payload = f.payload().unwrap(); let message: Sv2Message = (msg_type, payload).try_into().unwrap(); match message { diff --git a/protocols/v2/framing-sv2/src/framing.rs b/protocols/v2/framing-sv2/src/framing.rs index b7e742f9b8..5e6bd0bb65 100644 --- a/protocols/v2/framing-sv2/src/framing.rs +++ b/protocols/v2/framing-sv2/src/framing.rs @@ -92,10 +92,10 @@ impl + AsRef<[u8]>> Sv2Frame { } /// `Sv2Frame` always returns `Some(self.header)`. - pub fn get_header(&self) -> Option { + pub fn header(&self) -> crate::header::Header { match self { - Sv2Frame::Raw { header, .. } => Some(*header), - Sv2Frame::Payload { header, .. } => Some(*header), + Sv2Frame::Raw { header, .. } => *header, + Sv2Frame::Payload { header, .. } => *header, } } diff --git a/protocols/v2/sv2-ffi/src/lib.rs b/protocols/v2/sv2-ffi/src/lib.rs index 02a3a22369..fb1b557778 100644 --- a/protocols/v2/sv2-ffi/src/lib.rs +++ b/protocols/v2/sv2-ffi/src/lib.rs @@ -465,10 +465,7 @@ pub extern "C" fn next_frame(decoder: *mut DecoderWrapper) -> CResult { - let msg_type = match f.get_header() { - Some(header) => header.msg_type(), - None => return CResult::Err(Sv2Error::InvalidSv2Frame), - }; + let msg_type = f.header().msg_type(); let payload = match f.payload() { Some(payload) => payload, None => return CResult::Err(Sv2Error::InvalidSv2Frame), @@ -763,7 +760,7 @@ mod tests { let mut decoded = decoder.next_frame().unwrap(); - let msg_type = decoded.get_header().unwrap().msg_type(); + let msg_type = decoded.header().msg_type(); let payload = decoded.payload().unwrap(); let decoded_message: Sv2Message = (msg_type, payload).try_into().unwrap(); let decoded_message = match decoded_message { @@ -815,7 +812,7 @@ mod tests { let mut decoded = decoder.next_frame().unwrap(); // Extract payload of the frame which is the NewTemplate message - let msg_type = decoded.get_header().unwrap().msg_type(); + let msg_type = decoded.header().msg_type(); let payload = decoded.payload().unwrap(); let decoded_message: Sv2Message = (msg_type, payload).try_into().unwrap(); let decoded_message = match decoded_message { @@ -863,7 +860,7 @@ mod tests { let mut decoded = decoder.next_frame().unwrap(); - let msg_type = decoded.get_header().unwrap().msg_type(); + let msg_type = decoded.header().msg_type(); let payload = decoded.payload().unwrap(); let decoded_message: Sv2Message = (msg_type, payload).try_into().unwrap(); let decoded_message = match decoded_message { @@ -913,7 +910,7 @@ mod tests { let mut decoded = decoder.next_frame().unwrap(); - let msg_type = decoded.get_header().unwrap().msg_type(); + let msg_type = decoded.header().msg_type(); let payload = decoded.payload().unwrap(); let decoded_message: Sv2Message = (msg_type, payload).try_into().unwrap(); let decoded_message = match decoded_message { @@ -963,7 +960,7 @@ mod tests { let mut decoded = decoder.next_frame().unwrap(); - let msg_type = decoded.get_header().unwrap().msg_type(); + let msg_type = decoded.header().msg_type(); let payload = decoded.payload().unwrap(); let decoded_message: Sv2Message = (msg_type, payload).try_into().unwrap(); let decoded_message = match decoded_message { @@ -1008,7 +1005,7 @@ mod tests { let mut decoded = decoder.next_frame().unwrap(); - let msg_type = decoded.get_header().unwrap().msg_type(); + let msg_type = decoded.header().msg_type(); let payload = decoded.payload().unwrap(); let decoded_message: Sv2Message = (msg_type, payload).try_into().unwrap(); let decoded_message = match decoded_message { @@ -1053,7 +1050,7 @@ mod tests { let mut decoded = decoder.next_frame().unwrap(); - let msg_type = decoded.get_header().unwrap().msg_type(); + let msg_type = decoded.header().msg_type(); let payload = decoded.payload().unwrap(); let decoded_message: Sv2Message = (msg_type, payload).try_into().unwrap(); let decoded_message = match decoded_message { @@ -1111,7 +1108,7 @@ mod tests { let mut decoded = decoder.next_frame().unwrap(); - let msg_type = decoded.get_header().unwrap().msg_type(); + let msg_type = decoded.header().msg_type(); let payload = decoded.payload().unwrap(); let decoded_message: Sv2Message = (msg_type, payload).try_into().unwrap(); let decoded_message = match decoded_message { @@ -1147,7 +1144,7 @@ mod tests { let mut decoded = decoder.next_frame().unwrap(); - let msg_type = decoded.get_header().unwrap().msg_type(); + let msg_type = decoded.header().msg_type(); let payload = decoded.payload().unwrap(); let decoded_message: Sv2Message = (msg_type, payload).try_into().unwrap(); let decoded_message = match decoded_message { @@ -1196,7 +1193,7 @@ mod tests { let mut decoded = decoder.next_frame().unwrap(); - let msg_type = decoded.get_header().unwrap().msg_type(); + let msg_type = decoded.header().msg_type(); let payload = decoded.payload().unwrap(); let decoded_message: Sv2Message = (msg_type, payload).try_into().unwrap(); let decoded_message = match decoded_message { @@ -1245,7 +1242,7 @@ mod tests { let mut decoded = decoder.next_frame().unwrap(); - let msg_type = decoded.get_header().unwrap().msg_type(); + let msg_type = decoded.header().msg_type(); let payload = decoded.payload().unwrap(); let decoded_message: Sv2Message = (msg_type, payload).try_into().unwrap(); let decoded_message = match decoded_message { diff --git a/roles/jd-client/src/lib/downstream.rs b/roles/jd-client/src/lib/downstream.rs index 57b1b3bca9..4d8d60fa0c 100644 --- a/roles/jd-client/src/lib/downstream.rs +++ b/roles/jd-client/src/lib/downstream.rs @@ -252,7 +252,7 @@ impl DownstreamMiningNode { /// Parse the received message and relay it to the right upstream pub async fn next(self_mutex: &Arc>, mut incoming: StdFrame) { - let message_type = incoming.get_header().unwrap().msg_type(); + let message_type = incoming.header().msg_type(); let payload = incoming.payload().unwrap(); let routing_logic = roles_logic_sv2::routing_logic::MiningRoutingLogic::None; @@ -697,7 +697,7 @@ pub async fn listen_for_downstream_mining( ); let mut incoming: StdFrame = node.receiver.recv().await.unwrap().try_into().unwrap(); - let message_type = incoming.get_header().unwrap().msg_type(); + let message_type = incoming.header().msg_type(); let payload = incoming.payload().unwrap(); let routing_logic = roles_logic_sv2::routing_logic::CommonRoutingLogic::None; let node = Arc::new(Mutex::new(node)); diff --git a/roles/jd-client/src/lib/job_declarator/mod.rs b/roles/jd-client/src/lib/job_declarator/mod.rs index b76e471ee1..6059750127 100644 --- a/roles/jd-client/src/lib/job_declarator/mod.rs +++ b/roles/jd-client/src/lib/job_declarator/mod.rs @@ -292,7 +292,7 @@ impl JobDeclarator { let receiver = self_mutex.safe_lock(|d| d.receiver.clone()).unwrap(); loop { let mut incoming: StdFrame = receiver.recv().await.unwrap().try_into().unwrap(); - let message_type = incoming.get_header().unwrap().msg_type(); + let message_type = incoming.header().msg_type(); let payload = incoming.payload().unwrap(); let next_message_to_send = ParseServerJobDeclarationMessages::handle_message_job_declaration( diff --git a/roles/jd-client/src/lib/job_declarator/setup_connection.rs b/roles/jd-client/src/lib/job_declarator/setup_connection.rs index a1ddc613c9..c5c86e1027 100644 --- a/roles/jd-client/src/lib/job_declarator/setup_connection.rs +++ b/roles/jd-client/src/lib/job_declarator/setup_connection.rs @@ -57,7 +57,7 @@ impl SetupConnectionHandler { let mut incoming: StdFrame = receiver.recv().await.unwrap().try_into().unwrap(); - let message_type = incoming.get_header().unwrap().msg_type(); + let message_type = incoming.header().msg_type(); let payload = incoming.payload().unwrap(); ParseUpstreamCommonMessages::handle_message_common( Arc::new(Mutex::new(SetupConnectionHandler {})), diff --git a/roles/jd-client/src/lib/template_receiver/mod.rs b/roles/jd-client/src/lib/template_receiver/mod.rs index 51dd8fbd65..6a879aa079 100644 --- a/roles/jd-client/src/lib/template_receiver/mod.rs +++ b/roles/jd-client/src/lib/template_receiver/mod.rs @@ -186,7 +186,7 @@ impl TemplateRx { let received = handle_result!(tx_status.clone(), receiver.recv().await); let mut frame: StdFrame = handle_result!(tx_status.clone(), received.try_into()); - let message_type = frame.get_header().unwrap().msg_type(); + let message_type = frame.header().msg_type(); let payload = frame.payload().expect("No payload set"); let next_message_to_send = @@ -273,7 +273,7 @@ impl TemplateRx { _ => { error!("{:?}", frame); error!("{:?}", frame.payload()); - error!("{:?}", frame.get_header()); + error!("{:?}", frame.header()); std::process::exit(1); } } @@ -282,14 +282,14 @@ impl TemplateRx { error!("{:?}", m); error!("{:?}", frame); error!("{:?}", frame.payload()); - error!("{:?}", frame.get_header()); + error!("{:?}", frame.header()); std::process::exit(1); } Err(e) => { error!("{:?}", e); error!("{:?}", frame); error!("{:?}", frame.payload()); - error!("{:?}", frame.get_header()); + error!("{:?}", frame.header()); std::process::exit(1); } } diff --git a/roles/jd-client/src/lib/template_receiver/setup_connection.rs b/roles/jd-client/src/lib/template_receiver/setup_connection.rs index 81fb0166c2..0101997817 100644 --- a/roles/jd-client/src/lib/template_receiver/setup_connection.rs +++ b/roles/jd-client/src/lib/template_receiver/setup_connection.rs @@ -53,7 +53,7 @@ impl SetupConnectionHandler { .expect("Connection to TP closed!") .try_into() .expect("Failed to parse incoming SetupConnectionResponse"); - let message_type = incoming.get_header().unwrap().msg_type(); + let message_type = incoming.header().msg_type(); let payload = incoming.payload().unwrap(); ParseUpstreamCommonMessages::handle_message_common( Arc::new(Mutex::new(SetupConnectionHandler {})), diff --git a/roles/jd-client/src/lib/upstream_sv2/upstream.rs b/roles/jd-client/src/lib/upstream_sv2/upstream.rs index 2228ae9b01..dd9571a68b 100644 --- a/roles/jd-client/src/lib/upstream_sv2/upstream.rs +++ b/roles/jd-client/src/lib/upstream_sv2/upstream.rs @@ -231,11 +231,7 @@ impl Upstream { }; // Gets the binary frame message type from the message header - let message_type = if let Some(header) = incoming.get_header() { - header.msg_type() - } else { - return Err(framing_sv2::Error::ExpectedHandshakeFrame.into()); - }; + let message_type = incoming.header().msg_type(); // Gets the message payload let payload = match incoming.payload() { Some(payload) => payload, @@ -329,14 +325,7 @@ impl Upstream { let mut incoming: StdFrame = handle_result!(tx_status, incoming.try_into()); // On message receive, get the message type from the message header and get the // message payload - let message_type = - incoming - .get_header() - .ok_or(super::super::error::Error::FramingSv2( - framing_sv2::Error::ExpectedSv2Frame, - )); - - let message_type = handle_result!(tx_status, message_type).msg_type(); + let message_type = incoming.header().msg_type(); let payload = incoming.payload().expect("Payload not found"); diff --git a/roles/jd-server/src/lib/job_declarator/mod.rs b/roles/jd-server/src/lib/job_declarator/mod.rs index 051e1e795f..ef16293801 100644 --- a/roles/jd-server/src/lib/job_declarator/mod.rs +++ b/roles/jd-server/src/lib/job_declarator/mod.rs @@ -201,10 +201,7 @@ impl JobDeclaratorDownstream { match recv.recv().await { Ok(message) => { let mut frame: StdFrame = handle_result!(tx_status, message.try_into()); - let header = frame - .get_header() - .ok_or_else(|| JdsError::Custom(String::from("No header set"))); - let header = handle_result!(tx_status, header); + let header = frame.header(); let message_type = header.msg_type(); let payload = match frame.payload() { Some(p) => p, diff --git a/roles/mining-proxy/src/lib/downstream_mining.rs b/roles/mining-proxy/src/lib/downstream_mining.rs index c810de0e94..243250f814 100644 --- a/roles/mining-proxy/src/lib/downstream_mining.rs +++ b/roles/mining-proxy/src/lib/downstream_mining.rs @@ -228,7 +228,7 @@ impl DownstreamMiningNode { /// Parse the received message and relay it to the right upstream pub async fn next(self_mutex: Arc>, mut incoming: StdFrame) { - let message_type = incoming.get_header().unwrap().msg_type(); + let message_type = incoming.header().msg_type(); let payload = incoming.payload().unwrap(); let routing_logic = super::get_routing_logic(); @@ -499,7 +499,7 @@ pub async fn listen_for_downstream_mining(address: SocketAddr) { task::spawn(async move { let mut incoming: StdFrame = node.receiver.recv().await.unwrap().try_into().unwrap(); - let message_type = incoming.get_header().unwrap().msg_type(); + let message_type = incoming.header().msg_type(); let payload = incoming.payload().unwrap(); let routing_logic = super::get_common_routing_logic(); let node = Arc::new(Mutex::new(node)); diff --git a/roles/mining-proxy/src/lib/upstream_mining.rs b/roles/mining-proxy/src/lib/upstream_mining.rs index 864ea58139..f5b3705673 100644 --- a/roles/mining-proxy/src/lib/upstream_mining.rs +++ b/roles/mining-proxy/src/lib/upstream_mining.rs @@ -411,7 +411,7 @@ impl UpstreamMiningNode { .unwrap() .unwrap(); - let message_type = response.get_header().unwrap().msg_type(); + let message_type = response.header().msg_type(); let payload = response.payload().unwrap(); match (message_type, payload).try_into() { Ok(CommonMessages::SetupConnectionSuccess(_)) => { @@ -577,7 +577,7 @@ impl UpstreamMiningNode { } pub async fn next(self_mutex: Arc>, mut incoming: StdFrame) { - let message_type = incoming.get_header().unwrap().msg_type(); + let message_type = incoming.header().msg_type(); let payload = incoming.payload().unwrap(); let routing_logic = super::get_routing_logic(); @@ -615,7 +615,7 @@ impl UpstreamMiningNode { .unwrap() .unwrap(); - let message_type = response.get_header().unwrap().msg_type(); + let message_type = response.header().msg_type(); let payload = response.payload().unwrap(); match (message_type, payload).try_into() { Ok(CommonMessages::SetupConnectionSuccess(m)) => { @@ -861,7 +861,7 @@ impl UpstreamMiningNode { // #[cfg(test)] // #[allow(unused)] // pub async fn next_faster(&mut self, mut incoming: StdFrame) { - // let message_type = incoming.get_header().unwrap().msg_type(); + // let message_type = incoming.header().msg_type(); // // When a channel is opened we need to setup the channel id in order to relay next messages // // to the right Downstream diff --git a/roles/pool/src/lib/mining_pool/mod.rs b/roles/pool/src/lib/mining_pool/mod.rs index adc2a83d09..e2b526e8ff 100644 --- a/roles/pool/src/lib/mining_pool/mod.rs +++ b/roles/pool/src/lib/mining_pool/mod.rs @@ -200,10 +200,7 @@ impl Downstream { } pub async fn next(self_mutex: Arc>, mut incoming: StdFrame) -> PoolResult<()> { - let message_type = incoming - .get_header() - .ok_or_else(|| PoolError::Custom(String::from("No header set")))? - .msg_type(); + let message_type = incoming.header().msg_type(); let payload = match incoming.payload() { Some(p) => p, None => return Err(PoolError::Custom(String::from("No payload set"))), diff --git a/roles/pool/src/lib/mining_pool/setup_connection.rs b/roles/pool/src/lib/mining_pool/setup_connection.rs index 80babbd578..8710ac5410 100644 --- a/roles/pool/src/lib/mining_pool/setup_connection.rs +++ b/roles/pool/src/lib/mining_pool/setup_connection.rs @@ -58,10 +58,7 @@ impl SetupConnectionHandler { } }; - let message_type = incoming - .get_header() - .ok_or_else(|| PoolError::Custom(String::from("No header set")))? - .msg_type(); + let message_type = incoming.header().msg_type(); let payload = match incoming.payload() { Some(p) => p, None => return Err(PoolError::Custom(String::from("No payload set"))), diff --git a/roles/pool/src/lib/template_receiver/mod.rs b/roles/pool/src/lib/template_receiver/mod.rs index fb3222a3e0..0e086383ae 100644 --- a/roles/pool/src/lib/template_receiver/mod.rs +++ b/roles/pool/src/lib/template_receiver/mod.rs @@ -108,10 +108,7 @@ impl TemplateRx { .try_into() .map_err(|e| PoolError::Codec(codec_sv2::Error::FramingSv2Error(e))) ); - let message_type_res = message_from_tp - .get_header() - .ok_or_else(|| PoolError::Custom(String::from("No header set"))); - let message_type = handle_result!(status_tx, message_type_res).msg_type(); + let message_type = message_from_tp.header().msg_type(); let payload = match message_from_tp.payload() { Some(p) => p, None => { diff --git a/roles/pool/src/lib/template_receiver/setup_connection.rs b/roles/pool/src/lib/template_receiver/setup_connection.rs index 684937d780..5fc6bf97ad 100644 --- a/roles/pool/src/lib/template_receiver/setup_connection.rs +++ b/roles/pool/src/lib/template_receiver/setup_connection.rs @@ -53,10 +53,7 @@ impl SetupConnectionHandler { .await? .try_into() .map_err(|e| PoolError::Codec(codec_sv2::Error::FramingSv2Error(e)))?; - let message_type = incoming - .get_header() - .ok_or_else(|| PoolError::Custom(String::from("No header set")))? - .msg_type(); + let message_type = incoming.header().msg_type(); let payload = match incoming.payload() { Some(p) => p, None => return Err(PoolError::Custom(String::from("No payload set"))), diff --git a/roles/test-utils/mining-device/src/main.rs b/roles/test-utils/mining-device/src/main.rs index 4251d293d9..daf7a4bb81 100644 --- a/roles/test-utils/mining-device/src/main.rs +++ b/roles/test-utils/mining-device/src/main.rs @@ -180,7 +180,7 @@ impl SetupConnectionHandler { info!("Setup connection sent to {}", address); let mut incoming: StdFrame = receiver.recv().await.unwrap().try_into().unwrap(); - let message_type = incoming.get_header().unwrap().msg_type(); + let message_type = incoming.header().msg_type(); let payload = incoming.payload().unwrap(); ParseUpstreamCommonMessages::handle_message_common( self_, @@ -313,7 +313,7 @@ impl Device { loop { let mut incoming: StdFrame = receiver.recv().await.unwrap().try_into().unwrap(); - let message_type = incoming.get_header().unwrap().msg_type(); + let message_type = incoming.header().msg_type(); let payload = incoming.payload().unwrap(); let next = Device::handle_message_mining( self_mutex.clone(), diff --git a/roles/translator/src/lib/upstream_sv2/upstream.rs b/roles/translator/src/lib/upstream_sv2/upstream.rs index 4854682a12..979d8bedad 100644 --- a/roles/translator/src/lib/upstream_sv2/upstream.rs +++ b/roles/translator/src/lib/upstream_sv2/upstream.rs @@ -205,11 +205,7 @@ impl Upstream { }; // Gets the binary frame message type from the message header - let message_type = if let Some(header) = incoming.get_header() { - header.msg_type() - } else { - return Err(framing_sv2::Error::ExpectedHandshakeFrame.into()); - }; + let message_type = incoming.header().msg_type(); // Gets the message payload let payload = match incoming.payload() { Some(payload) => payload, @@ -300,14 +296,7 @@ impl Upstream { let mut incoming: StdFrame = handle_result!(tx_status, incoming.try_into()); // On message receive, get the message type from the message header and get the // message payload - let message_type = - incoming - .get_header() - .ok_or(super::super::error::Error::FramingSv2( - framing_sv2::Error::ExpectedSv2Frame, - )); - - let message_type = handle_result!(tx_status, message_type).msg_type(); + let message_type = incoming.header().msg_type(); let payload = incoming.payload().expect("Payload is None"); diff --git a/utils/message-generator/src/executor.rs b/utils/message-generator/src/executor.rs index 70cd4dae01..1cb38f0ea9 100644 --- a/utils/message-generator/src/executor.rs +++ b/utils/message-generator/src/executor.rs @@ -224,7 +224,7 @@ impl Executor { let mut message: Sv2Frame, _> = message.try_into().unwrap(); debug!("RECV {:#?}", message); - let header = message.get_header().unwrap(); + let header = message.header(); let payload = message.payload().unwrap(); match result { ActionResult::MatchMessageType(message_type) => { diff --git a/utils/message-generator/src/main.rs b/utils/message-generator/src/main.rs index 4353dc91f8..7c2cd8d978 100644 --- a/utils/message-generator/src/main.rs +++ b/utils/message-generator/src/main.rs @@ -657,8 +657,8 @@ mod test { let client_received = client_recv.recv().await.unwrap(); match (server_received, client_received) { (EitherFrame::Sv2(mut frame1), EitherFrame::Sv2(mut frame2)) => { - let mt1 = frame1.get_header().unwrap().msg_type(); - let mt2 = frame2.get_header().unwrap().msg_type(); + let mt1 = frame1.header().msg_type(); + let mt2 = frame2.header().msg_type(); let p1 = frame1.payload().unwrap(); let p2 = frame2.payload().unwrap(); let message1: Mining = (mt1, p1).try_into().unwrap();