mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Use ForkName Ord in BeaconBlockBody
This commit is contained in:
@@ -820,6 +820,11 @@ impl<E: EthSpec> From<BeaconBlockBody<E, FullPayload<E>>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<E: EthSpec> BeaconBlockBody<E> {
|
impl<E: EthSpec> BeaconBlockBody<E> {
|
||||||
|
/// Returns the name of the fork pertaining to `self`.
|
||||||
|
pub fn fork_name(&self) -> ForkName {
|
||||||
|
self.to_ref().fork_name()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn block_body_merkle_proof(&self, generalized_index: usize) -> Result<Vec<Hash256>, Error> {
|
pub fn block_body_merkle_proof(&self, generalized_index: usize) -> Result<Vec<Hash256>, Error> {
|
||||||
let field_index = match generalized_index {
|
let field_index = match generalized_index {
|
||||||
light_client_update::EXECUTION_PAYLOAD_INDEX => {
|
light_client_update::EXECUTION_PAYLOAD_INDEX => {
|
||||||
@@ -834,22 +839,16 @@ impl<E: EthSpec> BeaconBlockBody<E> {
|
|||||||
_ => return Err(Error::IndexNotSupported(generalized_index)),
|
_ => return Err(Error::IndexNotSupported(generalized_index)),
|
||||||
};
|
};
|
||||||
|
|
||||||
let attestations_root = match self {
|
let attestations_root = if self.fork_name() > ForkName::Electra {
|
||||||
BeaconBlockBody::Base(_)
|
self.attestations_electra()?.tree_hash_root()
|
||||||
| BeaconBlockBody::Altair(_)
|
} else {
|
||||||
| BeaconBlockBody::Bellatrix(_)
|
self.attestations_base()?.tree_hash_root()
|
||||||
| BeaconBlockBody::Capella(_)
|
|
||||||
| BeaconBlockBody::Deneb(_) => self.attestations_base()?.tree_hash_root(),
|
|
||||||
BeaconBlockBody::Electra(_) => self.attestations_electra()?.tree_hash_root(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let attester_slashings_root = match self {
|
let attester_slashings_root = if self.fork_name() > ForkName::Electra {
|
||||||
BeaconBlockBody::Base(_)
|
self.attester_slashings_electra()?.tree_hash_root()
|
||||||
| BeaconBlockBody::Altair(_)
|
} else {
|
||||||
| BeaconBlockBody::Bellatrix(_)
|
self.attester_slashings_base()?.tree_hash_root()
|
||||||
| BeaconBlockBody::Capella(_)
|
|
||||||
| BeaconBlockBody::Deneb(_) => self.attester_slashings_base()?.tree_hash_root(),
|
|
||||||
BeaconBlockBody::Electra(_) => self.attester_slashings_electra()?.tree_hash_root(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut leaves = vec![
|
let mut leaves = vec![
|
||||||
|
|||||||
Reference in New Issue
Block a user