parent
439fd30840
commit
d9919b99d2
|
@ -760,9 +760,10 @@ pub fn fund_keys<T: Client>(client: &T, source: &Keypair, dests: &[Arc<Keypair>]
|
|||
let mut retries = 0;
|
||||
let amount = chunk[0].1[0].1;
|
||||
while !to_fund_txs.is_empty() {
|
||||
let receivers = to_fund_txs
|
||||
let receivers: usize = to_fund_txs
|
||||
.iter()
|
||||
.fold(0, |len, (_, tx)| len + tx.message().instructions.len());
|
||||
.map(|(_, tx)| tx.message().instructions.len())
|
||||
.sum();
|
||||
|
||||
debug!(
|
||||
" {} to {} in {} txs",
|
||||
|
@ -854,9 +855,10 @@ pub fn create_token_accounts<T: Client>(
|
|||
})
|
||||
.collect();
|
||||
|
||||
let accounts = to_create_txs
|
||||
let accounts: usize = to_create_txs
|
||||
.iter()
|
||||
.fold(0, |len, (_, tx)| len + tx.message().instructions.len() / 2);
|
||||
.map(|(_, tx)| tx.message().instructions.len() / 2)
|
||||
.sum();
|
||||
|
||||
debug!(
|
||||
" Creating {} accounts in {} txs",
|
||||
|
|
|
@ -1227,12 +1227,14 @@ pub fn process_show_validators(
|
|||
.current
|
||||
.iter()
|
||||
.chain(vote_accounts.delinquent.iter())
|
||||
.fold(0, |acc, vote_account| acc + vote_account.activated_stake);
|
||||
.map(|vote_account| vote_account.activated_stake)
|
||||
.sum();
|
||||
|
||||
let total_deliquent_stake = vote_accounts
|
||||
.delinquent
|
||||
.iter()
|
||||
.fold(0, |acc, vote_account| acc + vote_account.activated_stake);
|
||||
.map(|vote_account| vote_account.activated_stake)
|
||||
.sum();
|
||||
let total_current_stake = total_active_stake - total_deliquent_stake;
|
||||
|
||||
let mut current = vote_accounts.current;
|
||||
|
|
|
@ -42,7 +42,8 @@ pub fn calculate_non_circulating_supply(bank: Arc<Bank>) -> NonCirculatingSupply
|
|||
|
||||
let lamports = non_circulating_accounts_set
|
||||
.iter()
|
||||
.fold(0, |acc, pubkey| acc + bank.get_balance(&pubkey));
|
||||
.map(|pubkey| bank.get_balance(&pubkey))
|
||||
.sum();
|
||||
|
||||
NonCirculatingSupply {
|
||||
lamports,
|
||||
|
|
|
@ -209,7 +209,8 @@ fn graph_forks(bank_forks: &BankForks, include_all_votes: bool) -> String {
|
|||
let total_stake = bank
|
||||
.vote_accounts()
|
||||
.iter()
|
||||
.fold(0, |acc, (_, (stake, _))| acc + stake);
|
||||
.map(|(_, (stake, _))| stake)
|
||||
.sum();
|
||||
for (_, (stake, vote_account)) in bank.vote_accounts() {
|
||||
let vote_state = VoteState::from(&vote_account).unwrap_or_default();
|
||||
if let Some(last_vote) = vote_state.votes.iter().last() {
|
||||
|
|
|
@ -104,46 +104,36 @@ impl RemoteWalletManager {
|
|||
let devices = usb.device_list();
|
||||
let num_prev_devices = self.devices.read().len();
|
||||
|
||||
let (detected_devices, errors) = devices
|
||||
.filter(|&device_info| {
|
||||
is_valid_hid_device(device_info.usage_page(), device_info.interface_number())
|
||||
})
|
||||
.fold(
|
||||
(Vec::new(), Vec::new()),
|
||||
|(mut devices, mut errors), device_info| {
|
||||
if is_valid_ledger(device_info.vendor_id(), device_info.product_id()) {
|
||||
match usb.open_path(&device_info.path()) {
|
||||
Ok(device) => {
|
||||
let mut ledger = LedgerWallet::new(device);
|
||||
let result = ledger.read_device(&device_info);
|
||||
match result {
|
||||
Ok(info) => {
|
||||
ledger.pretty_path = info.get_pretty_path();
|
||||
let path = device_info.path().to_str().unwrap().to_string();
|
||||
trace!("Found device: {:?}", info);
|
||||
devices.push(Device {
|
||||
path,
|
||||
info,
|
||||
wallet_type: RemoteWalletType::Ledger(Arc::new(ledger)),
|
||||
})
|
||||
}
|
||||
Err(err) => {
|
||||
error!(
|
||||
"Error connecting to ledger device to read info: {}",
|
||||
err
|
||||
);
|
||||
errors.push(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Error connecting to ledger device to read info: {}", err)
|
||||
}
|
||||
let mut detected_devices = vec![];
|
||||
let mut errors = vec![];
|
||||
for device_info in devices.filter(|&device_info| {
|
||||
is_valid_hid_device(device_info.usage_page(), device_info.interface_number())
|
||||
&& is_valid_ledger(device_info.vendor_id(), device_info.product_id())
|
||||
}) {
|
||||
match usb.open_path(&device_info.path()) {
|
||||
Ok(device) => {
|
||||
let mut ledger = LedgerWallet::new(device);
|
||||
let result = ledger.read_device(&device_info);
|
||||
match result {
|
||||
Ok(info) => {
|
||||
ledger.pretty_path = info.get_pretty_path();
|
||||
let path = device_info.path().to_str().unwrap().to_string();
|
||||
trace!("Found device: {:?}", info);
|
||||
detected_devices.push(Device {
|
||||
path,
|
||||
info,
|
||||
wallet_type: RemoteWalletType::Ledger(Arc::new(ledger)),
|
||||
})
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Error connecting to ledger device to read info: {}", err);
|
||||
errors.push(err)
|
||||
}
|
||||
}
|
||||
(devices, errors)
|
||||
},
|
||||
);
|
||||
}
|
||||
Err(err) => error!("Error connecting to ledger device to read info: {}", err),
|
||||
}
|
||||
}
|
||||
|
||||
let num_curr_devices = detected_devices.len();
|
||||
*self.devices.write() = detected_devices;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
use byteorder::{ByteOrder, LittleEndian};
|
||||
use solana_sdk::clock::Slot;
|
||||
use std::ops::Add;
|
||||
|
||||
#[derive(Default, Clone, Deserialize, Serialize)]
|
||||
pub struct HardForks {
|
||||
|
@ -34,16 +33,17 @@ impl HardForks {
|
|||
// The expected number of hard forks in a cluster is small.
|
||||
// If this turns out to be false then a more efficient data
|
||||
// structure may be needed here to avoid this linear search
|
||||
let fork_count = self
|
||||
let fork_count: usize = self
|
||||
.hard_forks
|
||||
.iter()
|
||||
.fold(0, |acc, (fork_slot, fork_count)| {
|
||||
acc.add(if parent_slot < *fork_slot && slot >= *fork_slot {
|
||||
.map(|(fork_slot, fork_count)| {
|
||||
if parent_slot < *fork_slot && slot >= *fork_slot {
|
||||
*fork_count
|
||||
} else {
|
||||
0
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
.sum();
|
||||
|
||||
if fork_count > 0 {
|
||||
let mut buf = [0u8; 8];
|
||||
|
|
|
@ -323,11 +323,13 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
|||
let total_current_stake = vote_accounts
|
||||
.current
|
||||
.iter()
|
||||
.fold(0, |acc, vote_account| acc + vote_account.activated_stake);
|
||||
.map(|vote_account| vote_account.activated_stake)
|
||||
.sum();
|
||||
let total_delinquent_stake = vote_accounts
|
||||
.delinquent
|
||||
.iter()
|
||||
.fold(0, |acc, vote_account| acc + vote_account.activated_stake);
|
||||
.map(|vote_account| vote_account.activated_stake)
|
||||
.sum();
|
||||
|
||||
let total_stake = total_current_stake + total_delinquent_stake;
|
||||
let current_stake_percent = total_current_stake * 100 / total_stake;
|
||||
|
|
Loading…
Reference in New Issue