/// Removes at most [MAX_TRANSACTIONS_TO_PURGE] transactions older
/// than `now - transaction_window` and returns the number of pruned
/// transactions.
Removes at most [MAX_TRANSACTIONS_TO_PURGE] transactions older
than `now - transaction_window` and returns the number of pruned
transactions.
Removes at most [ MAX_TRANSACTIONS_TO_PURGE ] transactions older than ` now - transaction_window ` and returns the number of pruned transactions .
fn purge_old_transactions(&mut self, now: TimeStamp) -> usize {
        let mut cnt = 0usize;
        while let Some(TransactionInfo {
            block_timestamp,
            transaction_hash,
        }) = self.transactions_by_height.front()
        {
            if *block_timestamp + self.transaction_window > now {
                // Stop at a sufficiently recent block.
                break;
            }
            let removed = self.transactions_by_hash.remove(transaction_hash);
            assert!(removed.is_some());
            // After 24 hours we don't need to store notification state because it isn't
            // accessible. We don't inspect the result because we don't care whether a
            // notification at this block height was made or not.
            match removed {
                Some(bh) => self.blocks_notified.remove(bh),
                None => None,
            };
            self.transactions_by_height.pop_front();
            cnt += 1;
            if cnt >= Self::MAX_TRANSACTIONS_TO_PURGE {
                break;
            }
        }
        cnt
    }
fn purge_old_transactions ( & mut self , now : TimeStamp ) -> usize { let mut cnt = 0usize ; while let Some ( TransactionInfo { block_timestamp , transaction_hash , } ) = self . transactions_by_height . front ( ) { if * block_timestamp + self . transaction_window > now { // Stop at a sufficiently recent block. break ; } let removed = self . transactions_by_hash . remove ( transaction_hash ) ; assert ! ( removed is_some ( ) ) ; // After 24 hours we don't need to store notification state because it isn't // accessible. We don't inspect the result because we don't care whether a // notification at this block height was made or not. match removed { Some ( bh ) => self . blocks_notified . remove ( bh ) , None => None , } ; self . transactions_by_height . pop_front ( ) ; cnt += 1 ; if cnt >= Self :: MAX_TRANSACTIONS_TO_PURGE { break ; } } cnt }
Removes at most [MAX_TRANSACTIONS_TO_PURGE] transactions older
than `now - transaction_window` and returns the number of pruned
transactions.
Removes at most [ MAX_TRANSACTIONS_TO_PURGE ] transactions older than ` now - transaction_window ` and returns the number of pruned transactions .
&mut self
now
TimeStamp