mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-10 13:01:22 +00:00
e8c0d1f19b
## Issue Addressed Resolves #2278 ## Proposed Changes Implements the networking components for the Altair hard fork https://github.com/ethereum/eth2.0-specs/blob/dev/specs/altair/p2p-interface.md ## Additional Info This PR acts as the base branch for networking changes and tracks https://github.com/sigp/lighthouse/pull/2279 . Changes to gossip, rpc and discovery can be separate PRs to be merged here for ease of review. Co-authored-by: realbigsean <seananderson33@gmail.com>
26 lines
982 B
Rust
26 lines
982 B
Rust
use beacon_chain::{BeaconChain, BeaconChainError, BeaconChainTypes};
|
|
|
|
use eth2_libp2p::rpc::StatusMessage;
|
|
/// Trait to produce a `StatusMessage` representing the state of the given `beacon_chain`.
|
|
///
|
|
/// NOTE: The purpose of this is simply to obtain a `StatusMessage` from the `BeaconChain` without
|
|
/// polluting/coupling the type with RPC concepts.
|
|
pub trait ToStatusMessage {
|
|
fn status_message(&self) -> Result<StatusMessage, BeaconChainError>;
|
|
}
|
|
|
|
impl<T: BeaconChainTypes> ToStatusMessage for BeaconChain<T> {
|
|
fn status_message(&self) -> Result<StatusMessage, BeaconChainError> {
|
|
let head_info = self.head_info()?;
|
|
let fork_digest = self.enr_fork_id().fork_digest;
|
|
|
|
Ok(StatusMessage {
|
|
fork_digest,
|
|
finalized_root: head_info.finalized_checkpoint.root,
|
|
finalized_epoch: head_info.finalized_checkpoint.epoch,
|
|
head_root: head_info.block_root,
|
|
head_slot: head_info.slot,
|
|
})
|
|
}
|
|
}
|