removes redundant Arcs from Blockstore (#23735)

This commit is contained in:
behzad nouri
2022-03-17 19:43:57 +00:00
committed by GitHub
parent 342f1ab1cb
commit 6b0d34d70d

View File

@ -171,13 +171,13 @@ pub struct Blockstore {
block_height_cf: LedgerColumn<cf::BlockHeight>, block_height_cf: LedgerColumn<cf::BlockHeight>,
program_costs_cf: LedgerColumn<cf::ProgramCosts>, program_costs_cf: LedgerColumn<cf::ProgramCosts>,
bank_hash_cf: LedgerColumn<cf::BankHash>, bank_hash_cf: LedgerColumn<cf::BankHash>,
last_root: Arc<RwLock<Slot>>, last_root: RwLock<Slot>,
insert_shreds_lock: Arc<Mutex<()>>, insert_shreds_lock: Mutex<()>,
pub new_shreds_signals: Vec<Sender<bool>>, pub new_shreds_signals: Vec<Sender<bool>>,
pub completed_slots_senders: Vec<CompletedSlotsSender>, pub completed_slots_senders: Vec<CompletedSlotsSender>,
pub lowest_cleanup_slot: Arc<RwLock<Slot>>, pub lowest_cleanup_slot: RwLock<Slot>,
no_compaction: bool, no_compaction: bool,
slots_stats: Arc<Mutex<SlotsStats>>, slots_stats: Mutex<SlotsStats>,
advanced_options: BlockstoreAdvancedOptions, advanced_options: BlockstoreAdvancedOptions,
} }
@ -615,7 +615,7 @@ impl Blockstore {
.next() .next()
.map(|(slot, _)| slot) .map(|(slot, _)| slot)
.unwrap_or(0); .unwrap_or(0);
let last_root = Arc::new(RwLock::new(max_root)); let last_root = RwLock::new(max_root);
// Get active transaction-status index or 0 // Get active transaction-status index or 0
let active_transaction_status_index = db let active_transaction_status_index = db
@ -659,11 +659,11 @@ impl Blockstore {
bank_hash_cf, bank_hash_cf,
new_shreds_signals: vec![], new_shreds_signals: vec![],
completed_slots_senders: vec![], completed_slots_senders: vec![],
insert_shreds_lock: Arc::new(Mutex::new(())), insert_shreds_lock: Mutex::<()>::default(),
last_root, last_root,
lowest_cleanup_slot: Arc::new(RwLock::new(0)), lowest_cleanup_slot: RwLock::<Slot>::default(),
no_compaction: false, no_compaction: false,
slots_stats: Arc::new(Mutex::new(SlotsStats::default())), slots_stats: Mutex::<SlotsStats>::default(),
advanced_options, advanced_options,
}; };
if initialize_transaction_status_index { if initialize_transaction_status_index {
@ -2109,7 +2109,7 @@ impl Blockstore {
ticks_per_slot: u64, ticks_per_slot: u64,
parent: Option<u64>, parent: Option<u64>,
is_full_slot: bool, is_full_slot: bool,
keypair: &Arc<Keypair>, keypair: &Keypair,
entries: Vec<Entry>, entries: Vec<Entry>,
version: u16, version: u16,
) -> Result<usize /*num of data shreds*/> { ) -> Result<usize /*num of data shreds*/> {
@ -3574,7 +3574,7 @@ impl Blockstore {
self.db.is_primary_access() self.db.is_primary_access()
} }
pub fn scan_and_fix_roots(&self, exit: &Arc<AtomicBool>) -> Result<()> { pub fn scan_and_fix_roots(&self, exit: &AtomicBool) -> Result<()> {
let ancestor_iterator = AncestorIterator::new(self.last_root(), self) let ancestor_iterator = AncestorIterator::new(self.last_root(), self)
.take_while(|&slot| slot >= self.lowest_cleanup_slot()); .take_while(|&slot| slot >= self.lowest_cleanup_slot());