casper_storage/data_access_layer/
round_seigniorage.rs

1use crate::tracking_copy::TrackingCopyError;
2use casper_types::{Digest, ProtocolVersion, U512};
3use num_rational::Ratio;
4
5/// Request to get the current round seigniorage rate.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub struct RoundSeigniorageRateRequest {
8    state_hash: Digest,
9    protocol_version: ProtocolVersion,
10}
11
12impl RoundSeigniorageRateRequest {
13    /// Create instance of RoundSeigniorageRateRequest.
14    pub fn new(state_hash: Digest, protocol_version: ProtocolVersion) -> Self {
15        RoundSeigniorageRateRequest {
16            state_hash,
17            protocol_version,
18        }
19    }
20
21    /// Returns state root hash.
22    pub fn state_hash(&self) -> Digest {
23        self.state_hash
24    }
25
26    /// Returns the protocol version.
27    pub fn protocol_version(&self) -> ProtocolVersion {
28        self.protocol_version
29    }
30}
31
32/// Represents a result of a `round_seigniorage_rate` request.
33#[derive(Debug)]
34pub enum RoundSeigniorageRateResult {
35    /// Invalid state root hash.
36    RootNotFound,
37    /// The mint is not found.
38    MintNotFound,
39    /// Value not found.
40    ValueNotFound(String),
41    /// The round seigniorage rate at the specified state hash.
42    Success {
43        /// The current rate.
44        rate: Ratio<U512>,
45    },
46    /// Failure.
47    Failure(TrackingCopyError),
48}