-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define & add
/signers/registered/{epoch}
to aggregator
- Loading branch information
Showing
8 changed files
with
352 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
mithril-aggregator/src/entities/signer_registration_message.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use mithril_common::entities::{Epoch, PartyId, Stake, StakeDistribution}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Message structure of signer registrations for an epoch. | ||
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)] | ||
pub struct SignerRegistrationsMessage { | ||
/// The epoch at which the registration was sent. | ||
pub registered_at: Epoch, | ||
|
||
/// The epoch at which the registration was able to send signatures. | ||
pub signing_at: Epoch, | ||
|
||
/// The signer registrations | ||
pub registrations: Vec<SignerRegistrationsListItemMessage>, | ||
} | ||
|
||
/// Message structure of a signer registration | ||
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)] | ||
pub struct SignerRegistrationsListItemMessage { | ||
/// The registered signer party id | ||
pub party_id: PartyId, | ||
|
||
/// The registered signer stake | ||
pub stake: Stake, | ||
} | ||
|
||
impl SignerRegistrationsMessage { | ||
/// Build a [SignerRegistrationsMessage] from a [stake distribution][StakeDistribution]. | ||
pub fn new(registered_at: Epoch, stake_distribution: StakeDistribution) -> Self { | ||
let registrations: Vec<SignerRegistrationsListItemMessage> = stake_distribution | ||
.into_iter() | ||
.map(|(party_id, stake)| SignerRegistrationsListItemMessage { party_id, stake }) | ||
.collect(); | ||
|
||
Self { | ||
registered_at, | ||
signing_at: registered_at.offset_to_signer_signing_offset(), | ||
registrations, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.