use crate::Config; use crate::{block_cache::BlockCache, deposit_cache::DepositCache}; use parking_lot::RwLock; #[derive(Default)] pub struct DepositUpdater { pub cache: DepositCache, pub last_processed_block: Option, } impl DepositUpdater { pub fn new(deposit_contract_deploy_block: u64) -> Self { let cache = DepositCache::new(deposit_contract_deploy_block); DepositUpdater { cache, last_processed_block: None, } } } #[derive(Default)] pub struct Inner { pub block_cache: RwLock, pub deposit_cache: RwLock, pub config: RwLock, } impl Inner { /// Prunes the block cache to `self.target_block_cache_len`. /// /// Is a no-op if `self.target_block_cache_len` is `None`. pub fn prune_blocks(&self) { if let Some(block_cache_truncation) = self.config.read().block_cache_truncation { self.block_cache.write().truncate(block_cache_truncation); } } }