File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ use axum::{
1515} ;
1616use bytes:: Bytes ;
1717use futures:: StreamExt ;
18+ pub use lh_types:: ForkName ;
1819use lh_types:: test_utils:: { SeedableRng , TestRandom , XorShiftRng } ;
1920use mediatype:: { MediaType , MediaTypeList , names} ;
2021use rand:: { Rng , distr:: Alphanumeric } ;
@@ -450,29 +451,6 @@ pub fn get_consensus_version_header(req_headers: &HeaderMap) -> Option<ForkName>
450451 . ok ( )
451452}
452453
453- #[ derive( Debug , Clone , Copy , PartialEq ) ]
454- pub enum ForkName {
455- Electra ,
456- }
457-
458- impl std:: fmt:: Display for ForkName {
459- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
460- match self {
461- ForkName :: Electra => write ! ( f, "electra" ) ,
462- }
463- }
464- }
465-
466- impl FromStr for ForkName {
467- type Err = String ;
468- fn from_str ( value : & str ) -> Result < Self , Self :: Err > {
469- match value {
470- "electra" => Ok ( ForkName :: Electra ) ,
471- _ => Err ( format ! ( "Invalid fork name {value}" ) ) ,
472- }
473- }
474- }
475-
476454#[ derive( Debug , Clone , Copy , PartialEq ) ]
477455pub enum ContentType {
478456 Json ,
Original file line number Diff line number Diff line change @@ -148,6 +148,13 @@ async fn handle_get_header(
148148 Accept :: Ssz => response. as_ssz_bytes ( ) ,
149149 }
150150 }
151+ _ => {
152+ return (
153+ StatusCode :: BAD_REQUEST ,
154+ format ! ( "Unsupported fork {consensus_version_header}" ) ,
155+ )
156+ . into_response ( ) ;
157+ }
151158 } ;
152159
153160 let mut response = ( StatusCode :: OK , data) . into_response ( ) ;
@@ -209,6 +216,13 @@ async fn handle_submit_block_v1(
209216 Accept :: Ssz => match consensus_version_header {
210217 // Response isn't versioned for SSZ
211218 ForkName :: Electra => response. as_ssz_bytes ( ) ,
219+ _ => {
220+ return (
221+ StatusCode :: BAD_REQUEST ,
222+ format ! ( "Unsupported fork {consensus_version_header}" ) ,
223+ )
224+ . into_response ( ) ;
225+ }
212226 } ,
213227 }
214228 } ;
You can’t perform that action at this time.
0 commit comments