mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 21:34:46 +00:00
Impl ForkVersionDecode for beacon state (#7954)
This commit is contained in:
@@ -170,7 +170,7 @@ impl<'a, E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockBodyRef<'a, E,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn body_merkle_leaves(&self) -> Vec<Hash256> {
|
||||
pub fn body_merkle_leaves(&self) -> Vec<Hash256> {
|
||||
let mut leaves = vec![];
|
||||
match self {
|
||||
Self::Base(body) => {
|
||||
|
||||
@@ -2632,6 +2632,12 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> ForkVersionDecode for BeaconState<E> {
|
||||
fn from_ssz_bytes_by_fork(bytes: &[u8], fork_name: ForkName) -> Result<Self, ssz::DecodeError> {
|
||||
Ok(map_fork_name!(fork_name, Self, <_>::from_ssz_bytes(bytes)?))
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> BeaconState<E> {
|
||||
/// The number of fields of the `BeaconState` rounded up to the nearest power of two.
|
||||
///
|
||||
@@ -2760,7 +2766,7 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
Ok(proof)
|
||||
}
|
||||
|
||||
fn generate_proof(
|
||||
pub fn generate_proof(
|
||||
&self,
|
||||
field_index: usize,
|
||||
leaves: &[Hash256],
|
||||
@@ -2775,7 +2781,7 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
Ok(proof)
|
||||
}
|
||||
|
||||
fn get_beacon_state_leaves(&self) -> Vec<Hash256> {
|
||||
pub fn get_beacon_state_leaves(&self) -> Vec<Hash256> {
|
||||
let mut leaves = vec![];
|
||||
#[allow(clippy::arithmetic_side_effects)]
|
||||
match self {
|
||||
|
||||
Reference in New Issue
Block a user