mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 05:44:44 +00:00
API for LightClientBootstrap, LightClientFinalityUpdate, LightClientOptimisticUpdate and light client events (#3954)
* rebase and add comment * conditional test * test * optimistic chould be working now * finality should be working now * try again * try again * clippy fix * add lc bootstrap beacon api * add lc optimistic/finality update to events * fmt * That error isn't occuring on my computer but I think this should fix it * Add missing test file * Update light client types to comply with Altair light client spec. * Fix test compilation * Support deserializing light client structures for the Bellatrix fork * Move `get_light_client_bootstrap` logic to `BeaconChain`. `LightClientBootstrap` API to return `ForkVersionedResponse`. * Misc fixes. - log cleanup - move http_api config mutation to `config::get_config` for consistency - fix light client API responses * Add light client bootstrap API test and fix existing ones. * Fix test for `light-client-server` http api config. * Appease clippy * Efficiency improvement when retrieving beacon state. --------- Co-authored-by: Jimmy Chen <jchen.tc@gmail.com>
This commit is contained in:
@@ -17,6 +17,8 @@ pub struct ServerSentEventHandler<T: EthSpec> {
|
||||
contribution_tx: Sender<EventKind<T>>,
|
||||
payload_attributes_tx: Sender<EventKind<T>>,
|
||||
late_head: Sender<EventKind<T>>,
|
||||
light_client_finality_update_tx: Sender<EventKind<T>>,
|
||||
light_client_optimistic_update_tx: Sender<EventKind<T>>,
|
||||
block_reward_tx: Sender<EventKind<T>>,
|
||||
log: Logger,
|
||||
}
|
||||
@@ -40,6 +42,8 @@ impl<T: EthSpec> ServerSentEventHandler<T> {
|
||||
let (contribution_tx, _) = broadcast::channel(capacity);
|
||||
let (payload_attributes_tx, _) = broadcast::channel(capacity);
|
||||
let (late_head, _) = broadcast::channel(capacity);
|
||||
let (light_client_finality_update_tx, _) = broadcast::channel(capacity);
|
||||
let (light_client_optimistic_update_tx, _) = broadcast::channel(capacity);
|
||||
let (block_reward_tx, _) = broadcast::channel(capacity);
|
||||
|
||||
Self {
|
||||
@@ -53,6 +57,8 @@ impl<T: EthSpec> ServerSentEventHandler<T> {
|
||||
contribution_tx,
|
||||
payload_attributes_tx,
|
||||
late_head,
|
||||
light_client_finality_update_tx,
|
||||
light_client_optimistic_update_tx,
|
||||
block_reward_tx,
|
||||
log,
|
||||
}
|
||||
@@ -108,6 +114,14 @@ impl<T: EthSpec> ServerSentEventHandler<T> {
|
||||
.late_head
|
||||
.send(kind)
|
||||
.map(|count| log_count("late head", count)),
|
||||
EventKind::LightClientFinalityUpdate(_) => self
|
||||
.light_client_finality_update_tx
|
||||
.send(kind)
|
||||
.map(|count| log_count("light client finality update", count)),
|
||||
EventKind::LightClientOptimisticUpdate(_) => self
|
||||
.light_client_optimistic_update_tx
|
||||
.send(kind)
|
||||
.map(|count| log_count("light client optimistic update", count)),
|
||||
EventKind::BlockReward(_) => self
|
||||
.block_reward_tx
|
||||
.send(kind)
|
||||
@@ -158,6 +172,14 @@ impl<T: EthSpec> ServerSentEventHandler<T> {
|
||||
self.late_head.subscribe()
|
||||
}
|
||||
|
||||
pub fn subscribe_light_client_finality_update(&self) -> Receiver<EventKind<T>> {
|
||||
self.light_client_finality_update_tx.subscribe()
|
||||
}
|
||||
|
||||
pub fn subscribe_light_client_optimistic_update(&self) -> Receiver<EventKind<T>> {
|
||||
self.light_client_optimistic_update_tx.subscribe()
|
||||
}
|
||||
|
||||
pub fn subscribe_block_reward(&self) -> Receiver<EventKind<T>> {
|
||||
self.block_reward_tx.subscribe()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user