mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 02:42:38 +00:00
Fast path for /eth/v1/beacon/blocks/head/root (#8729)
Closes: - https://github.com/sigp/lighthouse/issues/8667 Use the `early_attester_cache` to serve the head block root (if present). This should be faster than waiting for the head to finish importing. Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
@@ -254,4 +254,12 @@ impl<E: EthSpec> EarlyAttesterCache<E> {
|
||||
.filter(|item| item.beacon_block_root == block_root)
|
||||
.map(|item| item.proto_block.clone())
|
||||
}
|
||||
|
||||
/// Fetch the slot and block root of the current head block.
|
||||
pub fn get_head_block_root(&self) -> Option<(Slot, Hash256)> {
|
||||
self.item
|
||||
.read()
|
||||
.as_ref()
|
||||
.map(|item| (item.block.slot(), item.beacon_block_root))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user