mithril_signer/entities/
signer_epoch_settings.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use mithril_common::entities::{
    CardanoTransactionsSigningConfig, Epoch, ProtocolParameters, Signer,
};

/// SignerEpochSettings represents the settings of an epoch
#[derive(Clone, Debug, PartialEq)]
pub struct SignerEpochSettings {
    /// Current Epoch
    pub epoch: Epoch,

    /// Registration protocol parameters
    pub registration_protocol_parameters: ProtocolParameters,

    /// Current Signers
    pub current_signers: Vec<Signer>,

    /// Signers that will be able to sign on the next epoch
    pub next_signers: Vec<Signer>,

    /// Cardano transactions signing configuration for the current epoch
    pub cardano_transactions_signing_config: Option<CardanoTransactionsSigningConfig>,

    /// Cardano transactions signing configuration for the next epoch
    pub next_cardano_transactions_signing_config: Option<CardanoTransactionsSigningConfig>,
}

impl SignerEpochSettings {
    #[cfg(test)]
    /// Create a dummy SignerEpochSettings
    pub fn dummy() -> SignerEpochSettings {
        use mithril_common::test_utils::fake_data;

        // Beacon
        let beacon = fake_data::beacon();

        // Registration protocol parameters
        let registration_protocol_parameters = fake_data::protocol_parameters();

        // Signers
        let signers = fake_data::signers(5);
        let current_signers = signers[1..3].to_vec();
        let next_signers = signers[2..5].to_vec();

        // Cardano transactions signing configuration
        let cardano_transactions_signing_config = Some(CardanoTransactionsSigningConfig::dummy());
        let next_cardano_transactions_signing_config =
            Some(CardanoTransactionsSigningConfig::dummy());

        // Signer Epoch settings
        SignerEpochSettings {
            epoch: beacon.epoch,
            registration_protocol_parameters,
            current_signers,
            next_signers,
            cardano_transactions_signing_config,
            next_cardano_transactions_signing_config,
        }
    }
}