cometbft_rpc/dialect/
end_block.rs1use serde::{Deserialize, Serialize};
2
3use cometbft::{abci, consensus, validator};
4
5use crate::prelude::*;
6use crate::serializers;
7
8#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
9pub struct EndBlock<Ev> {
10 #[serde(with = "serializers::nullable")]
14 pub validator_updates: Vec<validator::Update>,
15 pub consensus_param_updates: Option<consensus::Params>,
17 #[serde(default = "Default::default")]
19 pub events: Vec<Ev>,
20}
21
22impl<Ev> Default for EndBlock<Ev> {
23 fn default() -> Self {
24 Self {
25 validator_updates: Default::default(),
26 consensus_param_updates: Default::default(),
27 events: Default::default(),
28 }
29 }
30}
31
32impl<Ev> From<EndBlock<Ev>> for abci::response::EndBlock
33where
34 Ev: Into<abci::Event>,
35{
36 fn from(msg: EndBlock<Ev>) -> Self {
37 Self {
38 events: msg.events.into_iter().map(Into::into).collect(),
39 validator_updates: msg.validator_updates,
40 consensus_param_updates: msg.consensus_param_updates,
41 }
42 }
43}
44
45impl<Ev> From<abci::response::EndBlock> for EndBlock<Ev>
46where
47 abci::Event: Into<Ev>,
48{
49 fn from(value: abci::response::EndBlock) -> Self {
50 Self {
51 events: value.events.into_iter().map(Into::into).collect(),
52 validator_updates: value.validator_updates,
53 consensus_param_updates: value.consensus_param_updates,
54 }
55 }
56}