Obtain BankForks read lock once to get ancestors and descendants (#35273)

No need to get the read lock twice; instead, hold it and get both items
This commit is contained in:
steviez 2024-02-21 10:07:57 -06:00 committed by GitHub
parent d223a43096
commit 5c04a9731c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -659,8 +659,10 @@ impl ReplayStage {
let mut tpu_has_bank = poh_recorder.read().unwrap().has_bank();
let mut replay_active_banks_time = Measure::start("replay_active_banks_time");
let mut ancestors = bank_forks.read().unwrap().ancestors();
let mut descendants = bank_forks.read().unwrap().descendants();
let (mut ancestors, mut descendants) = {
let r_bank_forks = bank_forks.read().unwrap();
(r_bank_forks.ancestors(), r_bank_forks.descendants())
};
let did_complete_bank = Self::replay_active_banks(
&blockstore,
&bank_forks,