From 93c57934cb5db7a18c2751698c8ca55155dce559 Mon Sep 17 00:00:00 2001 From: Anatoly Yakovenko Date: Mon, 25 Mar 2019 15:40:54 -0700 Subject: [PATCH] fixup! keep track of locktower slots and stakes --- core/src/locktower.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/locktower.rs b/core/src/locktower.rs index eef3ae69e..941745fb7 100644 --- a/core/src/locktower.rs +++ b/core/src/locktower.rs @@ -34,9 +34,9 @@ pub struct Locktower { } impl EpochStakes { - pub fn new(slot: u64, stakes: HashMap, self_id: Pubkey) -> Self { + pub fn new(slot: u64, stakes: HashMap, self_id: &Pubkey) -> Self { let total_staked = stakes.values().sum(); - let self_staked = *stakes.get(self_id).unwrap_or(&0); + let self_staked = *stakes.get(&self_id).unwrap_or(&0); Self { slot, stakes, @@ -48,18 +48,18 @@ impl EpochStakes { Self::new( 0, vec![(Pubkey::default(), lamports)].into_iter().collect(), - Pubkey::default(), + &Pubkey::default(), ) } pub fn new_from_stake_accounts(slot: u64, accounts: &[(Pubkey, Account)]) -> Self { let stakes = accounts.iter().map(|(k, v)| (*k, v.lamports)).collect(); - Self::new(slot, stakes) + Self::new(slot, stakes, &accounts[0].0) } pub fn new_from_bank(bank: &Bank) -> Self { let bank_epoch = bank.get_epoch_and_slot_index(bank.slot()).0; let stakes = staking_utils::vote_account_balances_at_epoch(bank, bank_epoch) .expect("voting require a bank with stakes"); - Self::new(bank_epoch, stakes, bank.collector_id()) + Self::new(bank_epoch, stakes, &bank.collector_id()) } }