More generic accounts purge functions (#14595)
Co-authored-by: Carl Lin <carl@solana.com>
This commit is contained in:
@ -5,7 +5,6 @@ use crate::{
|
||||
cluster_info_vote_listener::VerifiedVoteReceiver,
|
||||
cluster_slots::ClusterSlots,
|
||||
repair_weight::RepairWeight,
|
||||
repair_weighted_traversal::Contains,
|
||||
result::Result,
|
||||
serve_repair::{RepairType, ServeRepair, DEFAULT_NONCE},
|
||||
};
|
||||
@ -15,7 +14,9 @@ use solana_ledger::{
|
||||
shred::Nonce,
|
||||
};
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_runtime::{bank::Bank, bank_forks::BankForks, commitment::VOTE_THRESHOLD_SIZE};
|
||||
use solana_runtime::{
|
||||
bank::Bank, bank_forks::BankForks, commitment::VOTE_THRESHOLD_SIZE, contains::Contains,
|
||||
};
|
||||
use solana_sdk::{clock::Slot, epoch_schedule::EpochSchedule, pubkey::Pubkey, timing::timestamp};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
@ -402,12 +403,12 @@ impl RepairService {
|
||||
}
|
||||
|
||||
/// Repairs any fork starting at the input slot
|
||||
pub fn generate_repairs_for_fork(
|
||||
pub fn generate_repairs_for_fork<'a>(
|
||||
blockstore: &Blockstore,
|
||||
repairs: &mut Vec<RepairType>,
|
||||
max_repairs: usize,
|
||||
slot: Slot,
|
||||
duplicate_slot_repair_statuses: &dyn Contains<Slot>,
|
||||
duplicate_slot_repair_statuses: &impl Contains<'a, Slot>,
|
||||
) {
|
||||
let mut pending_slots = vec![slot];
|
||||
while repairs.len() < max_repairs && !pending_slots.is_empty() {
|
||||
|
@ -1,13 +1,10 @@
|
||||
use crate::{
|
||||
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
|
||||
repair_service::RepairTiming,
|
||||
repair_weighted_traversal::{self, Contains},
|
||||
serve_repair::RepairType,
|
||||
tree_diff::TreeDiff,
|
||||
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairTiming,
|
||||
repair_weighted_traversal, serve_repair::RepairType, tree_diff::TreeDiff,
|
||||
};
|
||||
use solana_ledger::{ancestor_iterator::AncestorIterator, blockstore::Blockstore};
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_runtime::epoch_stakes::EpochStakes;
|
||||
use solana_runtime::{contains::Contains, epoch_stakes::EpochStakes};
|
||||
use solana_sdk::{
|
||||
clock::Slot,
|
||||
epoch_schedule::{Epoch, EpochSchedule},
|
||||
@ -129,14 +126,14 @@ impl RepairWeight {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_best_weighted_repairs(
|
||||
pub fn get_best_weighted_repairs<'a>(
|
||||
&mut self,
|
||||
blockstore: &Blockstore,
|
||||
epoch_stakes: &HashMap<Epoch, EpochStakes>,
|
||||
epoch_schedule: &EpochSchedule,
|
||||
max_new_orphans: usize,
|
||||
max_new_shreds: usize,
|
||||
ignore_slots: &dyn Contains<Slot>,
|
||||
ignore_slots: &impl Contains<'a, Slot>,
|
||||
repair_timing: Option<&mut RepairTiming>,
|
||||
) -> Vec<RepairType> {
|
||||
let mut repairs = vec![];
|
||||
@ -228,12 +225,12 @@ impl RepairWeight {
|
||||
}
|
||||
|
||||
// Generate shred repairs for main subtree rooted at `self.slot`
|
||||
fn get_best_shreds(
|
||||
fn get_best_shreds<'a>(
|
||||
&mut self,
|
||||
blockstore: &Blockstore,
|
||||
repairs: &mut Vec<RepairType>,
|
||||
max_new_shreds: usize,
|
||||
ignore_slots: &dyn Contains<Slot>,
|
||||
ignore_slots: &impl Contains<'a, Slot>,
|
||||
) {
|
||||
let root_tree = self.trees.get(&self.root).expect("Root tree must exist");
|
||||
repair_weighted_traversal::get_best_repair_shreds(
|
||||
|
@ -3,27 +3,9 @@ use crate::{
|
||||
serve_repair::RepairType, tree_diff::TreeDiff,
|
||||
};
|
||||
use solana_ledger::blockstore::Blockstore;
|
||||
use solana_runtime::contains::Contains;
|
||||
use solana_sdk::clock::Slot;
|
||||
use std::{
|
||||
cmp::Eq,
|
||||
collections::{HashMap, HashSet},
|
||||
hash::Hash,
|
||||
};
|
||||
|
||||
pub trait Contains<T: Eq + Hash> {
|
||||
fn contains(&self, key: &T) -> bool;
|
||||
}
|
||||
|
||||
impl<T: Eq + Hash, U> Contains<T> for HashMap<T, U> {
|
||||
fn contains(&self, key: &T) -> bool {
|
||||
self.contains_key(key)
|
||||
}
|
||||
}
|
||||
impl<T: Eq + Hash> Contains<T> for HashSet<T> {
|
||||
fn contains(&self, key: &T) -> bool {
|
||||
self.contains(key)
|
||||
}
|
||||
}
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
enum Visit {
|
||||
@ -84,12 +66,12 @@ impl<'a> Iterator for RepairWeightTraversal<'a> {
|
||||
}
|
||||
|
||||
// Generate shred repairs for main subtree rooted at `self.slot`
|
||||
pub fn get_best_repair_shreds(
|
||||
pub fn get_best_repair_shreds<'a>(
|
||||
tree: &HeaviestSubtreeForkChoice,
|
||||
blockstore: &Blockstore,
|
||||
repairs: &mut Vec<RepairType>,
|
||||
max_new_shreds: usize,
|
||||
ignore_slots: &dyn Contains<Slot>,
|
||||
ignore_slots: &impl Contains<'a, Slot>,
|
||||
) {
|
||||
let initial_len = repairs.len();
|
||||
let max_repairs = initial_len + max_new_shreds;
|
||||
|
Reference in New Issue
Block a user