Skip to content

Commit

Permalink
De-replicode Tower constructors (#8153) (#8154)
Browse files Browse the repository at this point in the history
automerge
  • Loading branch information
mergify[bot] authored Feb 7, 2020
1 parent 14e6029 commit 465d71a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions core/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ impl StakeLockout {
}
}

#[derive(Default)]
pub struct Tower {
node_pubkey: Pubkey,
threshold_depth: usize,
Expand All @@ -47,15 +46,24 @@ pub struct Tower {
last_timestamp: BlockTimestamp,
}

impl Tower {
pub fn new(node_pubkey: &Pubkey, vote_account_pubkey: &Pubkey, bank_forks: &BankForks) -> Self {
let mut tower = Self {
node_pubkey: *node_pubkey,
impl Default for Tower {
fn default() -> Self {
Self {
node_pubkey: Pubkey::default(),
threshold_depth: VOTE_THRESHOLD_DEPTH,
threshold_size: VOTE_THRESHOLD_SIZE,
lockouts: VoteState::default(),
last_vote: Vote::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);
Expand Down

0 comments on commit 465d71a

Please sign in to comment.