-
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.
Merge pull request #1129 from input-output-hk/djo/1097/add-signers-re…
…gistered-route-to-aggregator Add signers registered route to aggregator
- Loading branch information
Showing
14 changed files
with
448 additions
and
41 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Oops, something went wrong.