Skip to content

Commit

Permalink
Implemented From for chain_vote::TallyResult => jormungandr_lib::Tall…
Browse files Browse the repository at this point in the history
…yResult
  • Loading branch information
danielsanchezq committed Oct 19, 2020
1 parent 470d3da commit 0029b6e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion jormungandr-lib/src/interfaces/vote/mod.rs
Expand Up @@ -287,7 +287,6 @@ pub enum Tally {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)]
pub struct TallyResult {
results: Vec<u64>,

options: Range<u8>,
}

Expand Down Expand Up @@ -369,6 +368,16 @@ impl From<vote::TallyResult> for TallyResult {
}
}

impl From<chain_vote::TallyResult> for TallyResult {
fn from(this: chain_vote::TallyResult) -> Self {
// TODO: is it safe to unwrap here?
Self {
results: this.votes.iter().map(|w| w.unwrap().into()).collect(),
options: this.options,
}
}
}

impl From<vote::Tally> for Tally {
fn from(this: vote::Tally) -> Self {
match this {
Expand Down

0 comments on commit 0029b6e

Please sign in to comment.