mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-28 02:03:32 +00:00
SSE and enw endpoint
This commit is contained in:
@@ -26,6 +26,8 @@ pub struct ServerSentEventHandler<E: EthSpec> {
|
||||
attester_slashing_tx: Sender<EventKind<E>>,
|
||||
bls_to_execution_change_tx: Sender<EventKind<E>>,
|
||||
block_gossip_tx: Sender<EventKind<E>>,
|
||||
execution_payload_bid_tx: Sender<EventKind<E>>,
|
||||
execution_payload_available_tx: Sender<EventKind<E>>,
|
||||
}
|
||||
|
||||
impl<E: EthSpec> ServerSentEventHandler<E> {
|
||||
@@ -53,6 +55,8 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
|
||||
let (attester_slashing_tx, _) = broadcast::channel(capacity);
|
||||
let (bls_to_execution_change_tx, _) = broadcast::channel(capacity);
|
||||
let (block_gossip_tx, _) = broadcast::channel(capacity);
|
||||
let (execution_payload_bid_tx, _) = broadcast::channel(capacity);
|
||||
let (execution_payload_available_tx, _) = broadcast::channel(capacity);
|
||||
|
||||
Self {
|
||||
attestation_tx,
|
||||
@@ -74,6 +78,8 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
|
||||
attester_slashing_tx,
|
||||
bls_to_execution_change_tx,
|
||||
block_gossip_tx,
|
||||
execution_payload_bid_tx,
|
||||
execution_payload_available_tx,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +168,14 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
|
||||
.block_gossip_tx
|
||||
.send(kind)
|
||||
.map(|count| log_count("block gossip", count)),
|
||||
EventKind::ExecutionPayloadBid(_) => self
|
||||
.execution_payload_bid_tx
|
||||
.send(kind)
|
||||
.map(|count| log_count("execution payload bid", count)),
|
||||
EventKind::ExecutionPayloadAvailable(_) => self
|
||||
.execution_payload_available_tx
|
||||
.send(kind)
|
||||
.map(|count| log_count("execution payload available", count)),
|
||||
};
|
||||
if let Err(SendError(event)) = result {
|
||||
trace!(?event, "No receivers registered to listen for event");
|
||||
@@ -311,4 +325,20 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
|
||||
pub fn has_block_gossip_subscribers(&self) -> bool {
|
||||
self.block_gossip_tx.receiver_count() > 0
|
||||
}
|
||||
|
||||
pub fn subscribe_execution_payload_bid(&self) -> Receiver<EventKind<E>> {
|
||||
self.execution_payload_bid_tx.subscribe()
|
||||
}
|
||||
|
||||
pub fn subscribe_execution_payload_available(&self) -> Receiver<EventKind<E>> {
|
||||
self.execution_payload_available_tx.subscribe()
|
||||
}
|
||||
|
||||
pub fn has_execution_payload_bid_subscribers(&self) -> bool {
|
||||
self.execution_payload_bid_tx.receiver_count() > 0
|
||||
}
|
||||
|
||||
pub fn has_execution_payload_available_subscribers(&self) -> bool {
|
||||
self.execution_payload_available_tx.receiver_count() > 0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user