mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 21:34:46 +00:00
Add bls_to_execution_change topic to eth1/v1/events (#5823)
* Add bls event * Update events and types * Add bls in event * Event bls * tests..rs * change order * another tests.rs * Signed BLS * Revert "another tests.rs" This reverts commit7f54e9c1ce. * Revert "Signed BLS" This reverts commit1146bc734b. * withdrawal_keyparis * Fix genesis
This commit is contained in:
@@ -2589,6 +2589,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
bls_to_execution_change: SigVerifiedOp<SignedBlsToExecutionChange, T::EthSpec>,
|
||||
received_pre_capella: ReceivedPreCapella,
|
||||
) -> bool {
|
||||
if let Some(event_handler) = self.event_handler.as_ref() {
|
||||
if event_handler.has_bls_to_execution_change_subscribers() {
|
||||
event_handler.register(EventKind::BlsToExecutionChange(Box::new(
|
||||
bls_to_execution_change.clone().into_inner(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
if self.eth1_chain.is_some() {
|
||||
self.op_pool
|
||||
.insert_bls_to_execution_change(bls_to_execution_change, received_pre_capella)
|
||||
|
||||
@@ -22,6 +22,7 @@ pub struct ServerSentEventHandler<E: EthSpec> {
|
||||
block_reward_tx: Sender<EventKind<E>>,
|
||||
proposer_slashing_tx: Sender<EventKind<E>>,
|
||||
attester_slashing_tx: Sender<EventKind<E>>,
|
||||
bls_to_execution_change_tx: Sender<EventKind<E>>,
|
||||
log: Logger,
|
||||
}
|
||||
|
||||
@@ -49,6 +50,7 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
|
||||
let (block_reward_tx, _) = broadcast::channel(capacity);
|
||||
let (proposer_slashing_tx, _) = broadcast::channel(capacity);
|
||||
let (attester_slashing_tx, _) = broadcast::channel(capacity);
|
||||
let (bls_to_execution_change_tx, _) = broadcast::channel(capacity);
|
||||
|
||||
Self {
|
||||
attestation_tx,
|
||||
@@ -66,6 +68,7 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
|
||||
block_reward_tx,
|
||||
proposer_slashing_tx,
|
||||
attester_slashing_tx,
|
||||
bls_to_execution_change_tx,
|
||||
log,
|
||||
}
|
||||
}
|
||||
@@ -140,6 +143,10 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
|
||||
.attester_slashing_tx
|
||||
.send(kind)
|
||||
.map(|count| log_count("attester slashing", count)),
|
||||
EventKind::BlsToExecutionChange(_) => self
|
||||
.bls_to_execution_change_tx
|
||||
.send(kind)
|
||||
.map(|count| log_count("bls to execution change", count)),
|
||||
};
|
||||
if let Err(SendError(event)) = result {
|
||||
trace!(self.log, "No receivers registered to listen for event"; "event" => ?event);
|
||||
@@ -206,6 +213,10 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
|
||||
self.proposer_slashing_tx.subscribe()
|
||||
}
|
||||
|
||||
pub fn subscribe_bls_to_execution_change(&self) -> Receiver<EventKind<E>> {
|
||||
self.bls_to_execution_change_tx.subscribe()
|
||||
}
|
||||
|
||||
pub fn has_attestation_subscribers(&self) -> bool {
|
||||
self.attestation_tx.receiver_count() > 0
|
||||
}
|
||||
@@ -257,4 +268,8 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
|
||||
pub fn has_attester_slashing_subscribers(&self) -> bool {
|
||||
self.attester_slashing_tx.receiver_count() > 0
|
||||
}
|
||||
|
||||
pub fn has_bls_to_execution_change_subscribers(&self) -> bool {
|
||||
self.bls_to_execution_change_tx.receiver_count() > 0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user