Data column sidecar event (#7587)

N/A


  Implement events for data column sidecar https://github.com/ethereum/beacon-APIs/pull/535
This commit is contained in:
Pawan Dhananjay
2025-06-11 09:39:22 -07:00
committed by GitHub
parent 7416d06dce
commit 076a1c3fae
7 changed files with 188 additions and 12 deletions

View File

@@ -11,6 +11,7 @@ pub struct ServerSentEventHandler<E: EthSpec> {
single_attestation_tx: Sender<EventKind<E>>,
block_tx: Sender<EventKind<E>>,
blob_sidecar_tx: Sender<EventKind<E>>,
data_column_sidecar_tx: Sender<EventKind<E>>,
finalized_tx: Sender<EventKind<E>>,
head_tx: Sender<EventKind<E>>,
exit_tx: Sender<EventKind<E>>,
@@ -37,6 +38,7 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
let (single_attestation_tx, _) = broadcast::channel(capacity);
let (block_tx, _) = broadcast::channel(capacity);
let (blob_sidecar_tx, _) = broadcast::channel(capacity);
let (data_column_sidecar_tx, _) = broadcast::channel(capacity);
let (finalized_tx, _) = broadcast::channel(capacity);
let (head_tx, _) = broadcast::channel(capacity);
let (exit_tx, _) = broadcast::channel(capacity);
@@ -57,6 +59,7 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
single_attestation_tx,
block_tx,
blob_sidecar_tx,
data_column_sidecar_tx,
finalized_tx,
head_tx,
exit_tx,
@@ -99,6 +102,10 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
.blob_sidecar_tx
.send(kind)
.map(|count| log_count("blob sidecar", count)),
EventKind::DataColumnSidecar(_) => self
.data_column_sidecar_tx
.send(kind)
.map(|count| log_count("data_column_sidecar", count)),
EventKind::FinalizedCheckpoint(_) => self
.finalized_tx
.send(kind)
@@ -177,6 +184,10 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
self.blob_sidecar_tx.subscribe()
}
pub fn subscribe_data_column_sidecar(&self) -> Receiver<EventKind<E>> {
self.data_column_sidecar_tx.subscribe()
}
pub fn subscribe_finalized(&self) -> Receiver<EventKind<E>> {
self.finalized_tx.subscribe()
}
@@ -249,6 +260,10 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
self.blob_sidecar_tx.receiver_count() > 0
}
pub fn has_data_column_sidecar_subscribers(&self) -> bool {
self.data_column_sidecar_tx.receiver_count() > 0
}
pub fn has_finalized_subscribers(&self) -> bool {
self.finalized_tx.receiver_count() > 0
}