celestia_core/abci/response/
commit.rs

1use bytes::Bytes;
2
3use crate::{block, prelude::*};
4
5#[doc = include_str!("../doc/response-commit.md")]
6#[derive(Clone, PartialEq, Eq, Debug, Default)]
7pub struct Commit {
8    /// The Merkle root hash of the application state
9    ///
10    /// XXX(hdevalence) - is this different from an app hash?
11    /// XXX(hdevalence) - rename to app_hash ?
12    pub data: Bytes,
13    /// Blocks below this height may be removed.
14    pub retain_height: block::Height,
15}
16
17// =============================================================================
18// Protobuf conversions
19// =============================================================================
20
21tendermint_pb_modules! {
22    use super::Commit;
23
24    impl From<Commit> for pb::abci::ResponseCommit {
25        fn from(commit: Commit) -> Self {
26            Self {
27                data: commit.data,
28                retain_height: commit.retain_height.into(),
29            }
30        }
31    }
32
33    impl TryFrom<pb::abci::ResponseCommit> for Commit {
34        type Error = crate::Error;
35
36        fn try_from(commit: pb::abci::ResponseCommit) -> Result<Self, Self::Error> {
37            Ok(Self {
38                data: commit.data,
39                retain_height: commit.retain_height.try_into()?,
40            })
41        }
42    }
43
44    impl Protobuf<pb::abci::ResponseCommit> for Commit {}
45}