Skip to content

Commit

Permalink
node-data: add BlockEvent::Accepted event data
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Aug 8, 2024
1 parent 9eb99ff commit 511aaa8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion node-data/src/events/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ impl EventSource for BlockEvent<'_> {
}
fn data(&self) -> EventData {
match self {
Self::Accepted(_) => EventData::None,
Self::Accepted(b) => {
let header = b.header();
let header = serde_json::to_value(header)
.expect("json to be serialized");
let txs: Vec<_> =
b.txs().iter().map(|t| hex::encode(t.id())).collect();
EventData::Json(serde_json::json!({
"header": header,
"transactions": txs,
}))
}
Self::StateChange { state, height, .. } => {
EventData::Json(serde_json::json!({
"state": state,
Expand Down

0 comments on commit 511aaa8

Please sign in to comment.