mithril_aggregator/entities/
signer_registration_message.rs1use mithril_common::entities::{Epoch, PartyId, SignerWithStake, Stake};
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
6pub struct SignerRegistrationsMessage {
7 pub registered_at: Epoch,
9
10 pub signing_at: Epoch,
12
13 pub registrations: Vec<SignerRegistrationsListItemMessage>,
15}
16
17#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
19pub struct SignerRegistrationsListItemMessage {
20 pub party_id: PartyId,
22
23 pub stake: Stake,
25}
26
27impl SignerRegistrationsMessage {
28 pub fn new(registered_at: Epoch, signers_with_stake: Vec<SignerWithStake>) -> Self {
30 let registrations: Vec<SignerRegistrationsListItemMessage> = signers_with_stake
31 .into_iter()
32 .map(|signer| SignerRegistrationsListItemMessage {
33 party_id: signer.party_id,
34 stake: signer.stake,
35 })
36 .collect();
37
38 Self {
39 registered_at,
40 signing_at: registered_at.offset_to_signer_signing_offset(),
41 registrations,
42 }
43 }
44}