@@ -334,12 +334,12 @@ impl ChainSpec {
334
334
}
335
335
336
336
pub fn inactivity_penalty_quotient_for_fork ( & self , fork_name : ForkName ) -> u64 {
337
- match fork_name {
338
- ForkName :: Base => self . inactivity_penalty_quotient ,
339
- ForkName :: Altair => self . inactivity_penalty_quotient_altair ,
340
- ForkName :: Merge => self . inactivity_penalty_quotient_bellatrix ,
341
- ForkName :: Capella => self . inactivity_penalty_quotient_bellatrix ,
342
- ForkName :: Deneb | ForkName :: Electra => self . inactivity_penalty_quotient_bellatrix ,
337
+ if fork_name >= ForkName :: Merge {
338
+ self . inactivity_penalty_quotient_bellatrix
339
+ } else if fork_name >= ForkName :: Altair {
340
+ self . inactivity_penalty_quotient_altair
341
+ } else {
342
+ self . inactivity_penalty_quotient
343
343
}
344
344
}
345
345
@@ -348,13 +348,13 @@ impl ChainSpec {
348
348
& self ,
349
349
state : & BeaconState < E > ,
350
350
) -> u64 {
351
- match state {
352
- BeaconState :: Base ( _ ) => self . proportional_slashing_multiplier ,
353
- BeaconState :: Altair ( _ ) => self . proportional_slashing_multiplier_altair ,
354
- BeaconState :: Merge ( _ ) => self . proportional_slashing_multiplier_bellatrix ,
355
- BeaconState :: Capella ( _ ) => self . proportional_slashing_multiplier_bellatrix ,
356
- BeaconState :: Deneb ( _ ) => self . proportional_slashing_multiplier_bellatrix ,
357
- BeaconState :: Electra ( _ ) => self . proportional_slashing_multiplier_bellatrix ,
351
+ let fork_name = state . fork_name_unchecked ( ) ;
352
+ if fork_name >= ForkName :: Merge {
353
+ self . proportional_slashing_multiplier_bellatrix
354
+ } else if fork_name >= ForkName :: Altair {
355
+ self . proportional_slashing_multiplier_altair
356
+ } else {
357
+ self . proportional_slashing_multiplier
358
358
}
359
359
}
360
360
@@ -363,13 +363,13 @@ impl ChainSpec {
363
363
& self ,
364
364
state : & BeaconState < E > ,
365
365
) -> u64 {
366
- match state {
367
- BeaconState :: Base ( _ ) => self . min_slashing_penalty_quotient ,
368
- BeaconState :: Altair ( _ ) => self . min_slashing_penalty_quotient_altair ,
369
- BeaconState :: Merge ( _ ) => self . min_slashing_penalty_quotient_bellatrix ,
370
- BeaconState :: Capella ( _ ) => self . min_slashing_penalty_quotient_bellatrix ,
371
- BeaconState :: Deneb ( _ ) => self . min_slashing_penalty_quotient_bellatrix ,
372
- BeaconState :: Electra ( _ ) => self . min_slashing_penalty_quotient_bellatrix ,
366
+ let fork_name = state . fork_name_unchecked ( ) ;
367
+ if fork_name >= ForkName :: Merge {
368
+ self . min_slashing_penalty_quotient_bellatrix
369
+ } else if fork_name >= ForkName :: Altair {
370
+ self . min_slashing_penalty_quotient_altair
371
+ } else {
372
+ self . min_slashing_penalty_quotient
373
373
}
374
374
}
375
375
@@ -531,22 +531,19 @@ impl ChainSpec {
531
531
}
532
532
533
533
pub fn max_blocks_by_root_request ( & self , fork_name : ForkName ) -> usize {
534
- match fork_name {
535
- ForkName :: Base | ForkName :: Altair | ForkName :: Merge | ForkName :: Capella => {
536
- self . max_blocks_by_root_request
537
- }
538
- ForkName :: Deneb | ForkName :: Electra => self . max_blocks_by_root_request_deneb ,
534
+ if fork_name >= ForkName :: Deneb {
535
+ self . max_blocks_by_root_request_deneb
536
+ } else {
537
+ self . max_blocks_by_root_request
539
538
}
540
539
}
541
540
542
541
pub fn max_request_blocks ( & self , fork_name : ForkName ) -> usize {
543
- let max_request_blocks = match fork_name {
544
- ForkName :: Base | ForkName :: Altair | ForkName :: Merge | ForkName :: Capella => {
545
- self . max_request_blocks
546
- }
547
- ForkName :: Deneb | ForkName :: Electra => self . max_request_blocks_deneb ,
548
- } ;
549
- max_request_blocks as usize
542
+ if fork_name >= ForkName :: Deneb {
543
+ self . max_request_blocks_deneb as usize
544
+ } else {
545
+ self . max_request_blocks as usize
546
+ }
550
547
}
551
548
552
549
/// Returns a `ChainSpec` compatible with the Ethereum Foundation specification.
0 commit comments