tendermint/abci/response/
finalize_block.rs1use serde::{Deserialize, Serialize};
2
3use crate::abci::{types::ExecTxResult, Event};
4use crate::prelude::*;
5use crate::{consensus, serializers, validator, AppHash};
6
7#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
8pub struct FinalizeBlock {
9 #[serde(default)]
11 pub events: Vec<Event>,
12 #[serde(default)]
16 pub tx_results: Vec<ExecTxResult>,
17 #[serde(with = "serializers::nullable")]
20 pub validator_updates: Vec<validator::Update>,
21 #[serde(default)]
23 pub consensus_param_updates: Option<consensus::Params>,
24 #[serde(default, with = "serializers::apphash_base64")]
26 pub app_hash: AppHash,
27}
28
29mod v0_38 {
34 use super::FinalizeBlock;
35 use tendermint_proto::v0_38::abci as pb;
36 use tendermint_proto::Protobuf;
37
38 impl From<FinalizeBlock> for pb::ResponseFinalizeBlock {
39 fn from(value: FinalizeBlock) -> Self {
40 Self {
41 events: value.events.into_iter().map(Into::into).collect(),
42 tx_results: value.tx_results.into_iter().map(Into::into).collect(),
43 validator_updates: value
44 .validator_updates
45 .into_iter()
46 .map(Into::into)
47 .collect(),
48 consensus_param_updates: value.consensus_param_updates.map(Into::into),
49 app_hash: value.app_hash.into(),
50 }
51 }
52 }
53
54 impl TryFrom<pb::ResponseFinalizeBlock> for FinalizeBlock {
55 type Error = crate::Error;
56
57 fn try_from(message: pb::ResponseFinalizeBlock) -> Result<Self, Self::Error> {
58 Ok(Self {
59 events: message
60 .events
61 .into_iter()
62 .map(TryInto::try_into)
63 .collect::<Result<_, _>>()?,
64 tx_results: message
65 .tx_results
66 .into_iter()
67 .map(TryInto::try_into)
68 .collect::<Result<_, _>>()?,
69 validator_updates: message
70 .validator_updates
71 .into_iter()
72 .map(TryInto::try_into)
73 .collect::<Result<_, _>>()?,
74 consensus_param_updates: message
75 .consensus_param_updates
76 .map(TryInto::try_into)
77 .transpose()?,
78 app_hash: message.app_hash.try_into()?,
79 })
80 }
81 }
82
83 impl Protobuf<pb::ResponseFinalizeBlock> for FinalizeBlock {}
84}