From 6b0d34d70dc08beb3d94cc8e30423883de73646b Mon Sep 17 00:00:00 2001 From: behzad nouri Date: Thu, 17 Mar 2022 19:43:57 +0000 Subject: [PATCH] removes redundant Arcs from Blockstore (#23735) --- ledger/src/blockstore.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 3b0c8bba2..3354ce4f9 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -171,13 +171,13 @@ pub struct Blockstore { block_height_cf: LedgerColumn, program_costs_cf: LedgerColumn, bank_hash_cf: LedgerColumn, - last_root: Arc>, - insert_shreds_lock: Arc>, + last_root: RwLock, + insert_shreds_lock: Mutex<()>, pub new_shreds_signals: Vec>, pub completed_slots_senders: Vec, - pub lowest_cleanup_slot: Arc>, + pub lowest_cleanup_slot: RwLock, no_compaction: bool, - slots_stats: Arc>, + slots_stats: Mutex, advanced_options: BlockstoreAdvancedOptions, } @@ -615,7 +615,7 @@ impl Blockstore { .next() .map(|(slot, _)| slot) .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 let active_transaction_status_index = db @@ -659,11 +659,11 @@ impl Blockstore { bank_hash_cf, new_shreds_signals: vec![], completed_slots_senders: vec![], - insert_shreds_lock: Arc::new(Mutex::new(())), + insert_shreds_lock: Mutex::<()>::default(), last_root, - lowest_cleanup_slot: Arc::new(RwLock::new(0)), + lowest_cleanup_slot: RwLock::::default(), no_compaction: false, - slots_stats: Arc::new(Mutex::new(SlotsStats::default())), + slots_stats: Mutex::::default(), advanced_options, }; if initialize_transaction_status_index { @@ -2109,7 +2109,7 @@ impl Blockstore { ticks_per_slot: u64, parent: Option, is_full_slot: bool, - keypair: &Arc, + keypair: &Keypair, entries: Vec, version: u16, ) -> Result { @@ -3574,7 +3574,7 @@ impl Blockstore { self.db.is_primary_access() } - pub fn scan_and_fix_roots(&self, exit: &Arc) -> Result<()> { + pub fn scan_and_fix_roots(&self, exit: &AtomicBool) -> Result<()> { let ancestor_iterator = AncestorIterator::new(self.last_root(), self) .take_while(|&slot| slot >= self.lowest_cleanup_slot());