penumbra_app/
penumbra_host_chain.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use async_trait::async_trait;
use penumbra_ibc::component::HostInterface;
use penumbra_sct::component::clock::EpochRead;

use crate::app::StateReadExt;

/// The implementation of [`penumbra_ibc::component::HostInterface`] for Penumbra.
/// It encapsulates all of the chain-specific data that the ibc implementation needs.
#[derive(Clone)]
pub struct PenumbraHost {}

#[async_trait]
impl HostInterface for PenumbraHost {
    async fn get_chain_id<S: cnidarium::StateRead>(state: S) -> anyhow::Result<String> {
        state.get_chain_id().await
    }

    async fn get_revision_number<S: cnidarium::StateRead>(state: S) -> anyhow::Result<u64> {
        state.get_revision_number().await
    }

    async fn get_block_height<S: cnidarium::StateRead>(state: S) -> anyhow::Result<u64> {
        state.get_block_height().await
    }

    async fn get_block_timestamp<S: cnidarium::StateRead>(
        state: S,
    ) -> anyhow::Result<tendermint::Time> {
        state.get_current_block_timestamp().await
    }
}