tendermint/abci/response/
init_chain.rs1use crate::AppHash;
2
3use crate::{consensus, prelude::*, validator};
4
5#[doc = include_str!("../doc/response-initchain.md")]
6#[derive(Clone, PartialEq, Eq, Debug, Default)]
7pub struct InitChain {
8 pub consensus_params: Option<consensus::Params>,
10 pub validators: Vec<validator::Update>,
19 pub app_hash: AppHash,
21}
22
23tendermint_pb_modules! {
28 use super::InitChain;
29
30 impl From<InitChain> for pb::abci::ResponseInitChain {
31 fn from(init_chain: InitChain) -> Self {
32 Self {
33 consensus_params: init_chain.consensus_params.map(Into::into),
34 validators: init_chain.validators.into_iter().map(Into::into).collect(),
35 app_hash: init_chain.app_hash.into(),
36 }
37 }
38 }
39
40 impl TryFrom<pb::abci::ResponseInitChain> for InitChain {
41 type Error = crate::Error;
42
43 fn try_from(init_chain: pb::abci::ResponseInitChain) -> Result<Self, Self::Error> {
44 Ok(Self {
45 consensus_params: init_chain
46 .consensus_params
47 .map(TryInto::try_into)
48 .transpose()?,
49 validators: init_chain
50 .validators
51 .into_iter()
52 .map(TryInto::try_into)
53 .collect::<Result<_, _>>()?,
54 app_hash: init_chain.app_hash.try_into()?,
55 })
56 }
57 }
58
59 impl Protobuf<pb::abci::ResponseInitChain> for InitChain {}
60}