Skip to main content

miden_node_store/state/view/
protocol_config.rs

1use miden_protocol::Word;
2use miden_protocol::block::BlockNumber;
3use miden_protocol::protocol_config::ProtocolConfig;
4
5use super::StateView;
6use crate::errors::{DatabaseError, RangeBeyondTip};
7
8impl StateView {
9    /// Returns the configuration commitment active at the specified block.
10    ///
11    /// Returns an error if the block exceeds this view's tip.
12    pub async fn get_protocol_config_commitment_at(
13        &self,
14        block_number: BlockNumber,
15    ) -> Result<Option<Word>, DatabaseError> {
16        let scoped = self.scope_block(block_number).ok_or(RangeBeyondTip {
17            chain_tip: *self.tip(),
18            block_to: block_number,
19        })?;
20        self.db.select_protocol_config_commitment_at(scoped).await
21    }
22
23    /// Returns the protocol configuration with the specified commitment.
24    pub async fn get_protocol_config(
25        &self,
26        commitment: Word,
27    ) -> Result<Option<ProtocolConfig>, DatabaseError> {
28        self.db.select_protocol_config_by_commitment(commitment).await
29    }
30}