ibc_core_client_context/consensus_state.rs
1//! Defines the trait to be implemented by all concrete consensus state types
2
3use ibc_core_client_types::error::ClientError;
4use ibc_core_commitment_types::commitment::CommitmentRoot;
5use ibc_primitives::prelude::*;
6use ibc_primitives::proto::Any;
7use ibc_primitives::Timestamp;
8
9use crate::Convertible;
10
11/// Defines methods that all `ConsensusState`s should provide.
12///
13/// One can think of a "consensus state" as a pruned header, to be stored on chain. In other words,
14/// a consensus state only contains the header's information needed by IBC message handlers.
15pub trait ConsensusState: Send + Sync + Convertible<Any> {
16 /// Commitment root of the consensus state, which is used for key-value pair verification.
17 fn root(&self) -> &CommitmentRoot;
18
19 /// The timestamp of the consensus state
20 fn timestamp(&self) -> Result<Timestamp, ClientError>;
21}