@@ -70,8 +70,6 @@ async fn handle_submit_block_impl<S: BuilderApiState, A: BuilderApi<S>>(
7070 // Honor caller q-value preference: pick the highest-priority encoding that
7171 // we can actually produce. Server preference for tiebreaks is SSZ first.
7272 let response_encoding = accept_types. preferred ( & [ EncodingType :: Ssz , EncodingType :: Json ] ) ;
73- let accepts_ssz = response_encoding == Some ( EncodingType :: Ssz ) ;
74- let accepts_json = response_encoding == Some ( EncodingType :: Json ) ;
7573
7674 info ! ( ua, ms_into_slot = now. saturating_sub( slot_start_ms) , "new request" ) ;
7775
@@ -126,28 +124,29 @@ async fn handle_submit_block_impl<S: BuilderApiState, A: BuilderApi<S>>(
126124 . with_label_values ( & [ "200" , SUBMIT_BLINDED_BLOCK_ENDPOINT_TAG ] )
127125 . inc ( ) ;
128126
129- // Try SSZ
130- if accepts_ssz {
131- let mut response = payload_and_blobs. data . as_ssz_bytes ( ) . into_response ( ) ;
132-
133- let content_type_header = EncodingType :: Ssz . content_type_header ( ) . clone ( ) ;
134- response. headers_mut ( ) . insert ( CONTENT_TYPE , content_type_header) ;
135- response. headers_mut ( ) . insert (
136- CONSENSUS_VERSION_HEADER ,
137- HeaderValue :: from_str ( & payload_and_blobs. version . to_string ( ) ) . unwrap ( ) ,
138- ) ;
139- info ! ( "sending response as SSZ" ) ;
140- return Ok ( response) ;
141- }
142-
143- // Handle JSON
144- if accepts_json {
145- Ok ( ( StatusCode :: OK , axum:: Json ( payload_and_blobs) ) . into_response ( ) )
146- } else {
147- // This shouldn't ever happen but the compiler needs it
148- Err ( PbsClientError :: DecodeError (
127+ // Three arms: no viable encoding (unreachable in practice —
128+ // `get_accept_types` errors earlier if the caller offers
129+ // nothing we support), SSZ, or JSON.
130+ match response_encoding {
131+ None => Err ( PbsClientError :: DecodeError (
149132 "no viable accept types in request" . to_string ( ) ,
150- ) )
133+ ) ) ,
134+ Some ( EncodingType :: Ssz ) => {
135+ let mut response = payload_and_blobs. data . as_ssz_bytes ( ) . into_response ( ) ;
136+
137+ let content_type_header = EncodingType :: Ssz . content_type_header ( ) . clone ( ) ;
138+ response. headers_mut ( ) . insert ( CONTENT_TYPE , content_type_header) ;
139+ response. headers_mut ( ) . insert (
140+ CONSENSUS_VERSION_HEADER ,
141+ HeaderValue :: from_str ( & payload_and_blobs. version . to_string ( ) ) . unwrap ( ) ,
142+ ) ;
143+ info ! ( "sending response as SSZ" ) ;
144+ Ok ( response)
145+ }
146+ Some ( EncodingType :: Json ) => {
147+ info ! ( "sending response as JSON" ) ;
148+ Ok ( ( StatusCode :: OK , axum:: Json ( payload_and_blobs) ) . into_response ( ) )
149+ }
151150 }
152151 }
153152 } ,
0 commit comments