Allow fork choice to support multiple versions of a slot (#16266)

This commit is contained in:
carllin
2021-04-12 01:00:59 -07:00
committed by GitHub
parent ef30943c5c
commit dc7030ffaa
12 changed files with 2034 additions and 637 deletions

View File

@ -2127,6 +2127,10 @@ impl Bank {
self.parent_slot
}
pub fn parent_hash(&self) -> Hash {
self.parent_hash
}
fn process_genesis_config(&mut self, genesis_config: &GenesisConfig) {
// Bootstrap validator collects fees until `new_from_parent` is called.
self.fee_rate_governor = genesis_config.fee_rate_governor.clone();

View File

@ -6,7 +6,7 @@ use crate::{
};
use log::*;
use solana_metrics::inc_new_counter_info;
use solana_sdk::{clock::Slot, timing};
use solana_sdk::{clock::Slot, hash::Hash, timing};
use std::{
collections::{hash_map::Entry, HashMap, HashSet},
ops::Index,
@ -106,6 +106,17 @@ impl BankForks {
self.banks.get(&bank_slot)
}
pub fn get_with_checked_hash(
&self,
(bank_slot, expected_hash): (Slot, Hash),
) -> Option<&Arc<Bank>> {
let maybe_bank = self.banks.get(&bank_slot);
if let Some(bank) = maybe_bank {
assert_eq!(bank.hash(), expected_hash);
}
maybe_bank
}
pub fn root_bank(&self) -> Arc<Bank> {
self[self.root()].clone()
}