mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 04:37:13 +00:00
Merge branch 'gloas-head-block-number' into glamsterdam-devnet-4
This commit is contained in:
@@ -190,12 +190,21 @@ impl<E: EthSpec> CachedHead<E> {
|
|||||||
/// Returns the execution block number of the block at the head of the chain.
|
/// Returns the execution block number of the block at the head of the chain.
|
||||||
///
|
///
|
||||||
/// Returns an error if the chain is prior to Gloas.
|
/// Returns an error if the chain is prior to Gloas.
|
||||||
pub fn head_block_number_gloas(&self) -> Result<u64, BeaconStateError> {
|
pub fn head_block_number_gloas(&self) -> Option<u64> {
|
||||||
self.snapshot
|
if let Some(head_block_number) = self
|
||||||
|
.snapshot
|
||||||
.execution_envelope
|
.execution_envelope
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|envelope| envelope.message.payload.block_number)
|
.map(|envelope| envelope.message.payload.block_number)
|
||||||
.ok()
|
{
|
||||||
|
Some(head_block_number)
|
||||||
|
} else {
|
||||||
|
// This fallback is strictly for the fork boundary case when self.snapshot.execution_envelope is `None`.
|
||||||
|
// Note: If there is a missed/orphaned envelope at the fork boundary we wont be able to get the block number using this fallback.
|
||||||
|
// We could try handling that edge case but it doesn't seem worth it. Returning `None` here just means that we don't
|
||||||
|
// emit a payload attributes SSE event further upstream.
|
||||||
|
self.head_block_number().ok()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the active validator count for the current epoch of the head state.
|
/// Returns the active validator count for the current epoch of the head state.
|
||||||
|
|||||||
Reference in New Issue
Block a user