Struct solana_runtime::bank_forks::BankForks
source · pub struct BankForks {
banks: HashMap<Slot, Arc<Bank>>,
descendants: HashMap<Slot, HashSet<Slot>>,
root: Arc<AtomicSlot>,
pub snapshot_config: Option<SnapshotConfig>,
pub accounts_hash_interval_slots: Slot,
last_accounts_hash_slot: Slot,
in_vote_only_mode: Arc<AtomicBool>,
}
Fields§
§banks: HashMap<Slot, Arc<Bank>>
§descendants: HashMap<Slot, HashSet<Slot>>
§root: Arc<AtomicSlot>
§snapshot_config: Option<SnapshotConfig>
§accounts_hash_interval_slots: Slot
§last_accounts_hash_slot: Slot
§in_vote_only_mode: Arc<AtomicBool>
Implementations§
source§impl BankForks
impl BankForks
pub fn new(bank: Bank) -> Self
pub fn banks(&self) -> HashMap<Slot, Arc<Bank>>
pub fn get_vote_only_mode_signal(&self) -> Arc<AtomicBool>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
sourcepub fn ancestors(&self) -> HashMap<Slot, HashSet<Slot>>
pub fn ancestors(&self) -> HashMap<Slot, HashSet<Slot>>
Create a map of bank slot id to the set of ancestors for the bank slot.
sourcepub fn descendants(&self) -> HashMap<Slot, HashSet<Slot>>
pub fn descendants(&self) -> HashMap<Slot, HashSet<Slot>>
Create a map of bank slot id to the set of all of its descendants
pub fn frozen_banks(&self) -> HashMap<Slot, Arc<Bank>>
pub fn active_bank_slots(&self) -> Vec<Slot>
pub fn get(&self, bank_slot: Slot) -> Option<Arc<Bank>>
pub fn get_with_checked_hash( &self, (bank_slot, expected_hash): (Slot, Hash) ) -> Option<Arc<Bank>>
pub fn bank_hash(&self, slot: Slot) -> Option<Hash>
pub fn root_bank(&self) -> Arc<Bank>
pub fn new_from_banks(initial_forks: &[Arc<Bank>], root: Slot) -> Self
pub fn insert(&mut self, bank: Bank) -> Arc<Bank>
pub fn remove(&mut self, slot: Slot) -> Option<Arc<Bank>>
pub fn highest_slot(&self) -> Slot
pub fn working_bank(&self) -> Arc<Bank>
fn do_set_root_return_metrics( &mut self, root: Slot, accounts_background_request_sender: &AbsRequestSender, highest_confirmed_root: Option<Slot> ) -> (Vec<Arc<Bank>>, SetRootMetrics)
pub fn set_root( &mut self, root: Slot, accounts_background_request_sender: &AbsRequestSender, highest_confirmed_root: Option<Slot> ) -> Vec<Arc<Bank>>
pub fn root(&self) -> Slot
sourcepub fn get_atomic_root(&self) -> ReadOnlyAtomicSlot
pub fn get_atomic_root(&self) -> ReadOnlyAtomicSlot
Gets a read-only wrapper to an atomic slot holding the root slot.
sourcefn prune_non_rooted(
&mut self,
root: Slot,
highest_confirmed_root: Option<Slot>
) -> (Vec<Arc<Bank>>, u64, u64)
fn prune_non_rooted( &mut self, root: Slot, highest_confirmed_root: Option<Slot> ) -> (Vec<Arc<Bank>>, u64, u64)
After setting a new root, prune the banks that are no longer on rooted paths
Given the following banks and slots…
slot 6 * (G)
/
slot 5 (F) * /
| /
slot 4 (E) * | /
| |/
slot 3 | * (D) <-- root, from set_root()
| |
slot 2 (C) * |
\ |
slot 1 \ * (B)
\ |
slot 0 * (A) <-- highest confirmed root [1]
…where (D) is set as root, clean up (C) and (E), since they are not rooted.
(A) is kept because it is greater-than-or-equal-to the highest confirmed root, and (D) is one of its descendants (B) is kept for the same reason as (A) (C) is pruned since it is a lower slot than (D), but (D) is not one of its descendants (D) is kept since it is the root (E) is pruned since it is not a descendant of (D) (F) is kept since it is a descendant of (D) (G) is kept for the same reason as (F)
and in table form…
| | is root a | is a descendant ||
slot | is root? | descendant? | of root? || keep?
------+----------+-------------+-----------------++-------
(A) | N | Y | N || Y
(B) | N | Y | N || Y
(C) | N | N | N || N
(D) | Y | N | N || Y
(E) | N | N | N || N
(F) | N | N | Y || Y
(G) | N | N | Y || Y
[1] RPC has the concept of commitment level, which is based on the highest confirmed root, i.e. the cluster-confirmed root. This commitment is stronger than the local node’s root. So (A) and (B) are kept to facilitate RPC at different commitment levels. Everything below the highest confirmed root can be pruned.
pub fn set_snapshot_config(&mut self, snapshot_config: Option<SnapshotConfig>)
pub fn set_accounts_hash_interval_slots(&mut self, accounts_interval_slots: u64)
sourcefn should_request_epoch_accounts_hash(&self, bank: &Bank) -> bool
fn should_request_epoch_accounts_hash(&self, bank: &Bank) -> bool
Determine if this bank should request an epoch accounts hash