Clippy cleanup for all targets and nighly rust (also support 1.44.0) (#10445)
* address warnings from 'rustup run beta cargo clippy --workspace' minor refactoring in: - cli/src/cli.rs - cli/src/offline/blockhash_query.rs - logger/src/lib.rs - runtime/src/accounts_db.rs expect some performance improvement AccountsDB::clean_accounts() * address warnings from 'rustup run beta cargo clippy --workspace --tests' * address warnings from 'rustup run nightly cargo clippy --workspace --all-targets' * rustfmt * fix warning stragglers * properly fix clippy warnings test_vote_subscribe() replace ref-to-arc with ref parameters where arc not cloned * Remove lock around JsonRpcRequestProcessor (#10417) automerge * make ancestors parameter optional to avoid forcing construction of empty hash maps Co-authored-by: Greg Fitzgerald <greg@solana.com>
This commit is contained in:
committed by
GitHub
parent
fa3a6c5584
commit
e23340d89e
@@ -153,12 +153,12 @@ impl Accounts {
|
||||
}
|
||||
let (account, rent) =
|
||||
AccountsDB::load(storage, ancestors, accounts_index, key)
|
||||
.and_then(|(mut account, _)| {
|
||||
.map(|(mut account, _)| {
|
||||
if message.is_writable(i) && !account.executable {
|
||||
let rent_due = rent_collector.update(&key, &mut account);
|
||||
Some((account, rent_due))
|
||||
(account, rent_due)
|
||||
} else {
|
||||
Some((account, 0))
|
||||
(account, 0)
|
||||
}
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
@@ -617,7 +617,6 @@ impl AccountsDB {
|
||||
pub fn clean_accounts(&self) {
|
||||
self.report_store_stats();
|
||||
|
||||
let no_ancestors = HashMap::new();
|
||||
let mut accounts_scan = Measure::start("accounts_scan");
|
||||
let accounts_index = self.accounts_index.read().unwrap();
|
||||
let pubkeys: Vec<Pubkey> = accounts_index.account_maps.keys().cloned().collect();
|
||||
@@ -628,7 +627,7 @@ impl AccountsDB {
|
||||
let mut purges_in_root = Vec::new();
|
||||
let mut purges = HashMap::new();
|
||||
for pubkey in pubkeys {
|
||||
if let Some((list, index)) = accounts_index.get(pubkey, &no_ancestors) {
|
||||
if let Some((list, index)) = accounts_index.get(pubkey, None) {
|
||||
let (slot, account_info) = &list[index];
|
||||
if account_info.lamports == 0 {
|
||||
purges.insert(*pubkey, accounts_index.would_purge(pubkey));
|
||||
@@ -641,16 +640,11 @@ impl AccountsDB {
|
||||
})
|
||||
.reduce(
|
||||
|| (HashMap::new(), Vec::new()),
|
||||
|m1, m2| {
|
||||
|mut m1, m2| {
|
||||
// Collapse down the hashmaps/vecs into one.
|
||||
let x = m2.0.iter().fold(m1.0, |mut acc, (k, vs)| {
|
||||
acc.insert(k.clone(), vs.clone());
|
||||
acc
|
||||
});
|
||||
let mut y = vec![];
|
||||
y.extend(m1.1);
|
||||
y.extend(m2.1);
|
||||
(x, y)
|
||||
m1.0.extend(m2.0);
|
||||
m1.1.extend(m2.1);
|
||||
m1
|
||||
},
|
||||
);
|
||||
|
||||
@@ -806,7 +800,6 @@ impl AccountsDB {
|
||||
}
|
||||
|
||||
let alive_accounts: Vec<_> = {
|
||||
let no_ancestors = HashMap::new();
|
||||
let accounts_index = self.accounts_index.read().unwrap();
|
||||
stored_accounts
|
||||
.iter()
|
||||
@@ -819,7 +812,7 @@ impl AccountsDB {
|
||||
(store_id, offset),
|
||||
_write_version,
|
||||
)| {
|
||||
if let Some((list, _)) = accounts_index.get(pubkey, &no_ancestors) {
|
||||
if let Some((list, _)) = accounts_index.get(pubkey, None) {
|
||||
list.iter()
|
||||
.any(|(_slot, i)| i.store_id == *store_id && i.offset == *offset)
|
||||
} else {
|
||||
@@ -927,7 +920,7 @@ impl AccountsDB {
|
||||
|
||||
pub fn scan_accounts<F, A>(&self, ancestors: &Ancestors, scan_func: F) -> A
|
||||
where
|
||||
F: Fn(&mut A, Option<(&Pubkey, Account, Slot)>) -> (),
|
||||
F: Fn(&mut A, Option<(&Pubkey, Account, Slot)>),
|
||||
A: Default,
|
||||
{
|
||||
let mut collector = A::default();
|
||||
@@ -946,7 +939,7 @@ impl AccountsDB {
|
||||
|
||||
pub fn range_scan_accounts<F, A, R>(&self, ancestors: &Ancestors, range: R, scan_func: F) -> A
|
||||
where
|
||||
F: Fn(&mut A, Option<(&Pubkey, Account, Slot)>) -> (),
|
||||
F: Fn(&mut A, Option<(&Pubkey, Account, Slot)>),
|
||||
A: Default,
|
||||
R: RangeBounds<Pubkey>,
|
||||
{
|
||||
@@ -968,7 +961,7 @@ impl AccountsDB {
|
||||
// PERF: Sequentially read each storage entry in parallel
|
||||
pub fn scan_account_storage<F, B>(&self, slot: Slot, scan_func: F) -> Vec<B>
|
||||
where
|
||||
F: Fn(&StoredAccount, AppendVecId, &mut B) -> () + Send + Sync,
|
||||
F: Fn(&StoredAccount, AppendVecId, &mut B) + Send + Sync,
|
||||
B: Send + Default,
|
||||
{
|
||||
let storage_maps: Vec<Arc<AccountStorageEntry>> = self
|
||||
@@ -1020,7 +1013,7 @@ impl AccountsDB {
|
||||
accounts_index: &AccountsIndex<AccountInfo>,
|
||||
pubkey: &Pubkey,
|
||||
) -> Option<(Account, Slot)> {
|
||||
let (lock, index) = accounts_index.get(pubkey, ancestors)?;
|
||||
let (lock, index) = accounts_index.get(pubkey, Some(ancestors))?;
|
||||
let slot = lock[index].0;
|
||||
//TODO: thread this as a ref
|
||||
if let Some(slot_storage) = storage.0.get(&slot) {
|
||||
@@ -1037,7 +1030,7 @@ impl AccountsDB {
|
||||
#[cfg(test)]
|
||||
fn load_account_hash(&self, ancestors: &Ancestors, pubkey: &Pubkey) -> Hash {
|
||||
let accounts_index = self.accounts_index.read().unwrap();
|
||||
let (lock, index) = accounts_index.get(pubkey, ancestors).unwrap();
|
||||
let (lock, index) = accounts_index.get(pubkey, Some(ancestors)).unwrap();
|
||||
let slot = lock[index].0;
|
||||
let storage = self.storage.read().unwrap();
|
||||
let slot_storage = storage.0.get(&slot).unwrap();
|
||||
@@ -1449,7 +1442,7 @@ impl AccountsDB {
|
||||
let hashes: Vec<_> = keys
|
||||
.par_iter()
|
||||
.filter_map(|pubkey| {
|
||||
if let Some((list, index)) = accounts_index.get(pubkey, ancestors) {
|
||||
if let Some((list, index)) = accounts_index.get(pubkey, Some(ancestors)) {
|
||||
let (slot, account_info) = &list[index];
|
||||
if account_info.lamports != 0 {
|
||||
storage
|
||||
@@ -1839,7 +1832,7 @@ impl AccountsDB {
|
||||
};
|
||||
let entry = accum
|
||||
.entry(stored_account.meta.pubkey)
|
||||
.or_insert_with(|| vec![]);
|
||||
.or_insert_with(Vec::new);
|
||||
entry.push((stored_account.meta.write_version, account_info));
|
||||
},
|
||||
);
|
||||
@@ -1847,7 +1840,7 @@ impl AccountsDB {
|
||||
let mut accounts_map: HashMap<Pubkey, Vec<(u64, AccountInfo)>> = HashMap::new();
|
||||
for accumulator_entry in accumulator.iter() {
|
||||
for (pubkey, storage_entry) in accumulator_entry {
|
||||
let entry = accounts_map.entry(*pubkey).or_insert_with(|| vec![]);
|
||||
let entry = accounts_map.entry(*pubkey).or_insert_with(Vec::new);
|
||||
entry.extend(storage_entry.iter().cloned());
|
||||
}
|
||||
}
|
||||
@@ -2118,7 +2111,7 @@ pub mod tests {
|
||||
.accounts_index
|
||||
.read()
|
||||
.unwrap()
|
||||
.get(&key, &ancestors)
|
||||
.get(&key, Some(&ancestors))
|
||||
.is_some());
|
||||
assert_load_account(&db, unrooted_slot, key, 1);
|
||||
|
||||
@@ -2139,7 +2132,7 @@ pub mod tests {
|
||||
.accounts_index
|
||||
.read()
|
||||
.unwrap()
|
||||
.get(&key, &ancestors)
|
||||
.get(&key, Some(&ancestors))
|
||||
.is_none());
|
||||
|
||||
// Test we can store for the same slot again and get the right information
|
||||
@@ -2188,14 +2181,14 @@ pub mod tests {
|
||||
for t in 0..num {
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let account = Account::new((t + 1) as u64, space, &Account::default().owner);
|
||||
pubkeys.push(pubkey.clone());
|
||||
pubkeys.push(pubkey);
|
||||
assert!(accounts.load_slow(&ancestors, &pubkey).is_none());
|
||||
accounts.store(slot, &[(&pubkey, &account)]);
|
||||
}
|
||||
for t in 0..num_vote {
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let account = Account::new((num + t + 1) as u64, space, &solana_vote_program::id());
|
||||
pubkeys.push(pubkey.clone());
|
||||
pubkeys.push(pubkey);
|
||||
let ancestors = vec![(slot, 0)].into_iter().collect();
|
||||
assert!(accounts.load_slow(&ancestors, &pubkey).is_none());
|
||||
accounts.store(slot, &[(&pubkey, &account)]);
|
||||
@@ -2435,7 +2428,7 @@ pub mod tests {
|
||||
let ancestors = vec![(0, 0)].into_iter().collect();
|
||||
let id = {
|
||||
let index = accounts.accounts_index.read().unwrap();
|
||||
let (list, idx) = index.get(&pubkey, &ancestors).unwrap();
|
||||
let (list, idx) = index.get(&pubkey, Some(&ancestors)).unwrap();
|
||||
list[idx].1.store_id
|
||||
};
|
||||
accounts.add_root(1);
|
||||
|
@@ -24,29 +24,29 @@ pub struct AccountsIndex<T> {
|
||||
impl<'a, T: 'a + Clone> AccountsIndex<T> {
|
||||
fn do_scan_accounts<F, I>(&self, ancestors: &Ancestors, mut func: F, iter: I)
|
||||
where
|
||||
F: FnMut(&Pubkey, (&T, Slot)) -> (),
|
||||
F: FnMut(&Pubkey, (&T, Slot)),
|
||||
I: Iterator<Item = (&'a Pubkey, &'a AccountMapEntry<T>)>,
|
||||
{
|
||||
for (pubkey, list) in iter {
|
||||
let list_r = &list.1.read().unwrap();
|
||||
if let Some(index) = self.latest_slot(ancestors, &list_r) {
|
||||
if let Some(index) = self.latest_slot(Some(ancestors), &list_r) {
|
||||
func(pubkey, (&list_r[index].1, list_r[index].0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// call func with every pubkey and index visible from a given set of ancestors
|
||||
pub fn scan_accounts<F>(&self, ancestors: &Ancestors, func: F)
|
||||
pub(crate) fn scan_accounts<F>(&self, ancestors: &Ancestors, func: F)
|
||||
where
|
||||
F: FnMut(&Pubkey, (&T, Slot)) -> (),
|
||||
F: FnMut(&Pubkey, (&T, Slot)),
|
||||
{
|
||||
self.do_scan_accounts(ancestors, func, self.account_maps.iter());
|
||||
}
|
||||
|
||||
/// call func with every pubkey and index visible from a given set of ancestors with range
|
||||
pub fn range_scan_accounts<F, R>(&self, ancestors: &Ancestors, range: R, func: F)
|
||||
pub(crate) fn range_scan_accounts<F, R>(&self, ancestors: &Ancestors, range: R, func: F)
|
||||
where
|
||||
F: FnMut(&Pubkey, (&T, Slot)) -> (),
|
||||
F: FnMut(&Pubkey, (&T, Slot)),
|
||||
R: RangeBounds<Pubkey>,
|
||||
{
|
||||
self.do_scan_accounts(ancestors, func, self.account_maps.range(range));
|
||||
@@ -76,11 +76,14 @@ impl<'a, T: 'a + Clone> AccountsIndex<T> {
|
||||
|
||||
// find the latest slot and T in a slice for a given ancestor
|
||||
// returns index into 'slice' if found, None if not.
|
||||
fn latest_slot(&self, ancestors: &Ancestors, slice: SlotSlice<T>) -> Option<usize> {
|
||||
fn latest_slot(&self, ancestors: Option<&Ancestors>, slice: SlotSlice<T>) -> Option<usize> {
|
||||
let mut max = 0;
|
||||
let mut rv = None;
|
||||
for (i, (slot, _t)) in slice.iter().rev().enumerate() {
|
||||
if *slot >= max && (ancestors.contains_key(slot) || self.is_root(*slot)) {
|
||||
if *slot >= max
|
||||
&& (ancestors.map_or(false, |ancestors| ancestors.contains_key(slot))
|
||||
|| self.is_root(*slot))
|
||||
{
|
||||
rv = Some((slice.len() - 1) - i);
|
||||
max = *slot;
|
||||
}
|
||||
@@ -90,10 +93,10 @@ impl<'a, T: 'a + Clone> AccountsIndex<T> {
|
||||
|
||||
/// Get an account
|
||||
/// The latest account that appears in `ancestors` or `roots` is returned.
|
||||
pub fn get(
|
||||
pub(crate) fn get(
|
||||
&self,
|
||||
pubkey: &Pubkey,
|
||||
ancestors: &Ancestors,
|
||||
ancestors: Option<&Ancestors>,
|
||||
) -> Option<(RwLockReadGuard<SlotList<T>>, usize)> {
|
||||
self.account_maps.get(pubkey).and_then(|list| {
|
||||
let list_r = list.1.read().unwrap();
|
||||
@@ -245,7 +248,8 @@ mod tests {
|
||||
let key = Keypair::new();
|
||||
let index = AccountsIndex::<bool>::default();
|
||||
let ancestors = HashMap::new();
|
||||
assert!(index.get(&key.pubkey(), &ancestors).is_none());
|
||||
assert!(index.get(&key.pubkey(), Some(&ancestors)).is_none());
|
||||
assert!(index.get(&key.pubkey(), None).is_none());
|
||||
|
||||
let mut num = 0;
|
||||
index.scan_accounts(&ancestors, |_pubkey, _index| num += 1);
|
||||
@@ -261,7 +265,8 @@ mod tests {
|
||||
assert!(gc.is_empty());
|
||||
|
||||
let ancestors = HashMap::new();
|
||||
assert!(index.get(&key.pubkey(), &ancestors).is_none());
|
||||
assert!(index.get(&key.pubkey(), Some(&ancestors)).is_none());
|
||||
assert!(index.get(&key.pubkey(), None).is_none());
|
||||
|
||||
let mut num = 0;
|
||||
index.scan_accounts(&ancestors, |_pubkey, _index| num += 1);
|
||||
@@ -277,7 +282,7 @@ mod tests {
|
||||
assert!(gc.is_empty());
|
||||
|
||||
let ancestors = vec![(1, 1)].into_iter().collect();
|
||||
assert!(index.get(&key.pubkey(), &ancestors).is_none());
|
||||
assert!(index.get(&key.pubkey(), Some(&ancestors)).is_none());
|
||||
|
||||
let mut num = 0;
|
||||
index.scan_accounts(&ancestors, |_pubkey, _index| num += 1);
|
||||
@@ -293,7 +298,7 @@ mod tests {
|
||||
assert!(gc.is_empty());
|
||||
|
||||
let ancestors = vec![(0, 0)].into_iter().collect();
|
||||
let (list, idx) = index.get(&key.pubkey(), &ancestors).unwrap();
|
||||
let (list, idx) = index.get(&key.pubkey(), Some(&ancestors)).unwrap();
|
||||
assert_eq!(list[idx], (0, true));
|
||||
|
||||
let mut num = 0;
|
||||
@@ -324,9 +329,8 @@ mod tests {
|
||||
index.insert(0, &key.pubkey(), true, &mut gc);
|
||||
assert!(gc.is_empty());
|
||||
|
||||
let ancestors = vec![].into_iter().collect();
|
||||
index.add_root(0);
|
||||
let (list, idx) = index.get(&key.pubkey(), &ancestors).unwrap();
|
||||
let (list, idx) = index.get(&key.pubkey(), None).unwrap();
|
||||
assert_eq!(list[idx], (0, true));
|
||||
}
|
||||
|
||||
@@ -369,14 +373,14 @@ mod tests {
|
||||
let mut gc = Vec::new();
|
||||
index.insert(0, &key.pubkey(), true, &mut gc);
|
||||
assert!(gc.is_empty());
|
||||
let (list, idx) = index.get(&key.pubkey(), &ancestors).unwrap();
|
||||
let (list, idx) = index.get(&key.pubkey(), Some(&ancestors)).unwrap();
|
||||
assert_eq!(list[idx], (0, true));
|
||||
drop(list);
|
||||
|
||||
let mut gc = Vec::new();
|
||||
index.insert(0, &key.pubkey(), false, &mut gc);
|
||||
assert_eq!(gc, vec![(0, true)]);
|
||||
let (list, idx) = index.get(&key.pubkey(), &ancestors).unwrap();
|
||||
let (list, idx) = index.get(&key.pubkey(), Some(&ancestors)).unwrap();
|
||||
assert_eq!(list[idx], (0, false));
|
||||
}
|
||||
|
||||
@@ -391,10 +395,10 @@ mod tests {
|
||||
assert!(gc.is_empty());
|
||||
index.insert(1, &key.pubkey(), false, &mut gc);
|
||||
assert!(gc.is_empty());
|
||||
let (list, idx) = index.get(&key.pubkey(), &ancestors).unwrap();
|
||||
let (list, idx) = index.get(&key.pubkey(), Some(&ancestors)).unwrap();
|
||||
assert_eq!(list[idx], (0, true));
|
||||
let ancestors = vec![(1, 0)].into_iter().collect();
|
||||
let (list, idx) = index.get(&key.pubkey(), &ancestors).unwrap();
|
||||
let (list, idx) = index.get(&key.pubkey(), Some(&ancestors)).unwrap();
|
||||
assert_eq!(list[idx], (1, false));
|
||||
}
|
||||
|
||||
@@ -413,13 +417,12 @@ mod tests {
|
||||
index.add_root(3);
|
||||
index.insert(4, &key.pubkey(), true, &mut gc);
|
||||
assert_eq!(gc, vec![(0, true), (1, false), (2, true)]);
|
||||
let ancestors = vec![].into_iter().collect();
|
||||
let (list, idx) = index.get(&key.pubkey(), &ancestors).unwrap();
|
||||
let (list, idx) = index.get(&key.pubkey(), None).unwrap();
|
||||
assert_eq!(list[idx], (3, true));
|
||||
|
||||
let mut num = 0;
|
||||
let mut found_key = false;
|
||||
index.scan_accounts(&ancestors, |pubkey, _index| {
|
||||
index.scan_accounts(&Ancestors::new(), |pubkey, _index| {
|
||||
if pubkey == &key.pubkey() {
|
||||
found_key = true;
|
||||
assert_eq!(_index, (&true, 3));
|
||||
|
@@ -150,7 +150,7 @@ impl StatusCacheRc {
|
||||
}
|
||||
}
|
||||
|
||||
pub type EnteredEpochCallback = Box<dyn Fn(&mut Bank) -> () + Sync + Send>;
|
||||
pub type EnteredEpochCallback = Box<dyn Fn(&mut Bank) + Sync + Send>;
|
||||
|
||||
pub type TransactionProcessResult = (Result<()>, Option<HashAgeKind>);
|
||||
pub struct TransactionResults {
|
||||
@@ -3854,7 +3854,7 @@ mod tests {
|
||||
impl Bank {
|
||||
fn slots_by_pubkey(&self, pubkey: &Pubkey, ancestors: &Ancestors) -> Vec<Slot> {
|
||||
let accounts_index = self.rc.accounts.accounts_db.accounts_index.read().unwrap();
|
||||
let (accounts, _) = accounts_index.get(&pubkey, &ancestors).unwrap();
|
||||
let (accounts, _) = accounts_index.get(&pubkey, Some(&ancestors)).unwrap();
|
||||
accounts
|
||||
.iter()
|
||||
.map(|(slot, _)| *slot)
|
||||
@@ -4988,7 +4988,7 @@ mod tests {
|
||||
let (genesis_config, mint_keypair) = create_genesis_config(2_000);
|
||||
let bank0 = Arc::new(Bank::new(&genesis_config));
|
||||
let initial_state = bank0.hash_internal_state();
|
||||
let bank1 = Bank::new_from_parent(&bank0.clone(), &Pubkey::default(), 1);
|
||||
let bank1 = Bank::new_from_parent(&bank0, &Pubkey::default(), 1);
|
||||
assert_ne!(bank1.hash_internal_state(), initial_state);
|
||||
|
||||
info!("transfer bank1");
|
||||
|
@@ -42,15 +42,20 @@ impl<T: BloomHashIndex> Bloom<T> {
|
||||
let keys: Vec<u64> = (0..num_keys).map(|_| rand::thread_rng().gen()).collect();
|
||||
Self::new(num_bits, keys)
|
||||
}
|
||||
pub fn num_bits(num_items: f64, false_rate: f64) -> f64 {
|
||||
fn num_bits(num_items: f64, false_rate: f64) -> f64 {
|
||||
let n = num_items;
|
||||
let p = false_rate;
|
||||
((n * p.ln()) / (1f64 / 2f64.powf(2f64.ln())).ln()).ceil()
|
||||
}
|
||||
pub fn num_keys(num_bits: f64, num_items: f64) -> f64 {
|
||||
fn num_keys(num_bits: f64, num_items: f64) -> f64 {
|
||||
let n = num_items;
|
||||
let m = num_bits;
|
||||
1f64.max(((m / n) * 2f64.ln()).round())
|
||||
// infinity as usize is zero in rust 1.43 but 2^64-1 in rust 1.45; ensure it's zero here
|
||||
if n == 0.0 {
|
||||
0.0
|
||||
} else {
|
||||
1f64.max(((m / n) * 2f64.ln()).round())
|
||||
}
|
||||
}
|
||||
fn pos(&self, key: &T, k: u64) -> u64 {
|
||||
key.hash_at_index(k) % self.bits.len()
|
||||
|
@@ -930,7 +930,7 @@ mod tests {
|
||||
|
||||
fn with_create_zero_lamport<F>(callback: F)
|
||||
where
|
||||
F: Fn(&Bank) -> (),
|
||||
F: Fn(&Bank),
|
||||
{
|
||||
solana_logger::setup();
|
||||
|
||||
|
@@ -206,7 +206,7 @@ mod tests {
|
||||
fn verify_nonce_ok() {
|
||||
with_test_keyed_account(42, true, |nonce_account| {
|
||||
let mut signers = HashSet::new();
|
||||
signers.insert(nonce_account.signer_key().unwrap().clone());
|
||||
signers.insert(nonce_account.signer_key().unwrap());
|
||||
let state: State = nonce_account.state().unwrap();
|
||||
// New is in Uninitialzed state
|
||||
assert_eq!(state, State::Uninitialized);
|
||||
@@ -236,7 +236,7 @@ mod tests {
|
||||
fn verify_nonce_bad_query_hash_fail() {
|
||||
with_test_keyed_account(42, true, |nonce_account| {
|
||||
let mut signers = HashSet::new();
|
||||
signers.insert(nonce_account.signer_key().unwrap().clone());
|
||||
signers.insert(nonce_account.signer_key().unwrap());
|
||||
let state: State = nonce_account.state().unwrap();
|
||||
// New is in Uninitialzed state
|
||||
assert_eq!(state, State::Uninitialized);
|
||||
|
@@ -48,11 +48,16 @@ impl RentCollector {
|
||||
.map(|epoch| self.epoch_schedule.get_slots_in_epoch(epoch + 1))
|
||||
.sum();
|
||||
|
||||
let (rent_due, exempt) = self.rent.due(
|
||||
account.lamports,
|
||||
account.data.len(),
|
||||
slots_elapsed as f64 / self.slots_per_year,
|
||||
);
|
||||
// avoid infinite rent in rust 1.45
|
||||
let years_elapsed = if self.slots_per_year != 0.0 {
|
||||
slots_elapsed as f64 / self.slots_per_year
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
let (rent_due, exempt) =
|
||||
self.rent
|
||||
.due(account.lamports, account.data.len(), years_elapsed);
|
||||
|
||||
if exempt || rent_due != 0 {
|
||||
if account.lamports > rent_due {
|
||||
|
@@ -271,7 +271,7 @@ impl<T: Serialize + Clone> StatusCache<T> {
|
||||
.or_insert((slot, sig_index, HashMap::new()));
|
||||
sig_map.0 = std::cmp::max(slot, sig_map.0);
|
||||
|
||||
let sig_forks = sig_map.2.entry(sig_slice).or_insert_with(|| vec![]);
|
||||
let sig_forks = sig_map.2.entry(sig_slice).or_insert_with(Vec::new);
|
||||
sig_forks.push((slot, res.clone()));
|
||||
let slot_deltas = self.slot_deltas.entry(slot).or_default();
|
||||
let mut fork_entry = slot_deltas.lock().unwrap();
|
||||
|
@@ -933,7 +933,7 @@ mod tests {
|
||||
|
||||
fn with_create_zero_lamport<F>(callback: F)
|
||||
where
|
||||
F: Fn(&Bank) -> (),
|
||||
F: Fn(&Bank),
|
||||
{
|
||||
solana_logger::setup();
|
||||
|
||||
|
Reference in New Issue
Block a user