use mithril_common::entities::{Epoch, PartyId, SignerWithStake, Stake};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct SignerRegistrationsMessage {
pub registered_at: Epoch,
pub signing_at: Epoch,
pub registrations: Vec<SignerRegistrationsListItemMessage>,
}
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct SignerRegistrationsListItemMessage {
pub party_id: PartyId,
pub stake: Stake,
}
impl SignerRegistrationsMessage {
pub fn new(registered_at: Epoch, signers_with_stake: Vec<SignerWithStake>) -> Self {
let registrations: Vec<SignerRegistrationsListItemMessage> = signers_with_stake
.into_iter()
.map(|signer| SignerRegistrationsListItemMessage {
party_id: signer.party_id,
stake: signer.stake,
})
.collect();
Self {
registered_at,
signing_at: registered_at.offset_to_signer_signing_offset(),
registrations,
}
}
}