From 0f498e6265cb85a700275a4dd21328ba0e93b405 Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Tue, 14 May 2019 10:44:29 -0700 Subject: [PATCH] remove unused filter_zero_balance (#4279) --- core/src/staking_utils.rs | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/core/src/staking_utils.rs b/core/src/staking_utils.rs index 17416c396c..0ae538bce4 100644 --- a/core/src/staking_utils.rs +++ b/core/src/staking_utils.rs @@ -55,22 +55,18 @@ pub fn delegated_stakes_at_epoch(bank: &Bank, epoch_height: u64) -> Option impl Iterator { bank.vote_accounts() .into_iter() - .filter_map(|(account_id, account)| { - filter_zero_balances(&account).map(|stake| (account_id, stake, account)) - }) + .map(|(account_id, account)| (account_id, Bank::read_balance(&account), account)) } pub fn node_staked_accounts_at_epoch( bank: &Bank, epoch_height: u64, ) -> Option> { - bank.epoch_vote_accounts(epoch_height).map(|epoch_state| { - epoch_state + bank.epoch_vote_accounts(epoch_height).map(|vote_accounts| { + vote_accounts .into_iter() - .filter_map(|(account_id, account)| { - filter_zero_balances(account).map(|stake| (account_id, stake, account)) - }) - .filter(|(account_id, _, account)| filter_no_delegate(account_id, account)) + .filter(|(account_id, account)| filter_no_delegate(account_id, account)) + .map(|(account_id, account)| (account_id, Bank::read_balance(&account), account)) }) } @@ -80,15 +76,6 @@ fn filter_no_delegate(account_id: &Pubkey, account: &Account) -> bool { .unwrap_or(false) } -fn filter_zero_balances(account: &Account) -> Option { - let balance = Bank::read_balance(&account); - if balance > 0 { - Some(balance) - } else { - None - } -} - fn to_vote_state( node_staked_accounts: impl Iterator, u64, impl Borrow)>, ) -> impl Iterator {