De-replicode Tower constructors (#8153) (#8154)

automerge
This commit is contained in:
mergify[bot]
2020-02-06 19:38:47 -08:00
committed by GitHub
parent 14e6029fae
commit 465d71a3a3

View File

@ -37,7 +37,6 @@ impl StakeLockout {
} }
} }
#[derive(Default)]
pub struct Tower { pub struct Tower {
node_pubkey: Pubkey, node_pubkey: Pubkey,
threshold_depth: usize, threshold_depth: usize,
@ -47,15 +46,24 @@ pub struct Tower {
last_timestamp: BlockTimestamp, last_timestamp: BlockTimestamp,
} }
impl Tower { impl Default for Tower {
pub fn new(node_pubkey: &Pubkey, vote_account_pubkey: &Pubkey, bank_forks: &BankForks) -> Self { fn default() -> Self {
let mut tower = Self { Self {
node_pubkey: *node_pubkey, node_pubkey: Pubkey::default(),
threshold_depth: VOTE_THRESHOLD_DEPTH, threshold_depth: VOTE_THRESHOLD_DEPTH,
threshold_size: VOTE_THRESHOLD_SIZE, threshold_size: VOTE_THRESHOLD_SIZE,
lockouts: VoteState::default(), lockouts: VoteState::default(),
last_vote: Vote::default(), last_vote: Vote::default(),
last_timestamp: BlockTimestamp::default(), last_timestamp: BlockTimestamp::default(),
}
}
}
impl Tower {
pub fn new(node_pubkey: &Pubkey, vote_account_pubkey: &Pubkey, bank_forks: &BankForks) -> Self {
let mut tower = Self {
node_pubkey: *node_pubkey,
..Tower::default()
}; };
tower.initialize_lockouts_from_bank_forks(&bank_forks, vote_account_pubkey); tower.initialize_lockouts_from_bank_forks(&bank_forks, vote_account_pubkey);