use crate::{ consensus::{SwitchForkDecision, Tower}, latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks, progress_map::ProgressMap, replay_stage::HeaviestForkFailures, }; use solana_runtime::{bank::Bank, bank_forks::BankForks}; use std::{ collections::{HashMap, HashSet}, sync::{Arc, RwLock}, }; pub struct SelectVoteAndResetForkResult { pub vote_bank: Option<(Arc, SwitchForkDecision)>, pub reset_bank: Option>, pub heaviest_fork_failures: Vec, } pub trait ForkChoice { type ForkChoiceKey; fn compute_bank_stats( &mut self, bank: &Bank, tower: &Tower, latest_validator_votes_for_frozen_banks: &mut LatestValidatorVotesForFrozenBanks, ); // Returns: // 1) The heaviest overall bank // 2) The heaviest bank on the same fork as the last vote (doesn't require a // switching proof to vote for) fn select_forks( &self, frozen_banks: &[Arc], tower: &Tower, progress: &ProgressMap, ancestors: &HashMap>, bank_forks: &RwLock, ) -> (Arc, Option>); fn mark_fork_invalid_candidate(&mut self, invalid_slot: &Self::ForkChoiceKey); fn mark_fork_valid_candidate(&mut self, valid_slot: &Self::ForkChoiceKey); }