1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use crate::liveness::proposer_election::ProposerElection;
use consensus_types::common::{Author, Round};
use std::collections::HashMap;
pub struct RoundProposer {
proposers: HashMap<Round, Author>,
default_proposer: Author,
}
impl RoundProposer {
pub fn new(proposers: HashMap<Round, Author>, default_proposer: Author) -> Self {
Self {
proposers,
default_proposer,
}
}
}
impl ProposerElection for RoundProposer {
fn get_valid_proposer(&self, round: Round) -> Author {
match self.proposers.get(&round) {
None => self.default_proposer,
Some(round_proposer) => *round_proposer,
}
}
}