Add inclusion list sse event

This commit is contained in:
Eitan Seri-Levi
2025-03-20 23:59:32 -06:00
parent 411860fe58
commit 77e86b102d
6 changed files with 39 additions and 10 deletions

View File

@@ -1144,6 +1144,7 @@ pub enum EventKind<E: EthSpec> {
AttesterSlashing(Box<AttesterSlashing<E>>),
BlsToExecutionChange(Box<SignedBlsToExecutionChange>),
BlockGossip(Box<BlockGossip>),
InclusionList(Box<SignedInclusionList<E>>),
}
impl<E: EthSpec> EventKind<E> {
@@ -1168,6 +1169,7 @@ impl<E: EthSpec> EventKind<E> {
EventKind::AttesterSlashing(_) => "attester_slashing",
EventKind::BlsToExecutionChange(_) => "bls_to_execution_change",
EventKind::BlockGossip(_) => "block_gossip",
EventKind::InclusionList(_) => "inclusion_list",
}
}
@@ -1254,6 +1256,11 @@ impl<E: EthSpec> EventKind<E> {
"block_gossip" => Ok(EventKind::BlockGossip(serde_json::from_str(data).map_err(
|e| ServerError::InvalidServerSentEvent(format!("Block Gossip: {:?}", e)),
)?)),
"inclusion_list" => Ok(EventKind::InclusionList(
serde_json::from_str(data).map_err(|e| {
ServerError::InvalidServerSentEvent(format!("Inclusion List {:?}", e))
})?,
)),
_ => Err(ServerError::InvalidServerSentEvent(
"Could not parse event tag".to_string(),
)),
@@ -1290,6 +1297,7 @@ pub enum EventTopic {
ProposerSlashing,
BlsToExecutionChange,
BlockGossip,
InclusionList,
}
impl FromStr for EventTopic {
@@ -1316,6 +1324,7 @@ impl FromStr for EventTopic {
"proposer_slashing" => Ok(EventTopic::ProposerSlashing),
"bls_to_execution_change" => Ok(EventTopic::BlsToExecutionChange),
"block_gossip" => Ok(EventTopic::BlockGossip),
"inclusion_list" => Ok(EventTopic::InclusionList),
_ => Err("event topic cannot be parsed.".to_string()),
}
}
@@ -1343,6 +1352,7 @@ impl fmt::Display for EventTopic {
EventTopic::ProposerSlashing => write!(f, "proposer_slashing"),
EventTopic::BlsToExecutionChange => write!(f, "bls_to_execution_change"),
EventTopic::BlockGossip => write!(f, "block_gossip"),
EventTopic::InclusionList => write!(f, "inclusion_list",),
}
}
}