pub fn store(&self, time_source: &dyn TimeSource, artifacts: Vec<ConsensusMessage>) {
        // If the queue is full, we will block here.
        if self
            .backup_queue
            .send(BackupRequest::Backup(artifacts))
            .is_err()
        {
            error!(
                self.log,
                "Backup thread exited unexpectedly. This is a bug."
            );
            self.metrics.io_errors.inc();
        }

        // If we didn't purge within the last PURGE_INTERVAL, trigger a new purge.
        // This way we avoid a too frequent purging. We also block if the previous
        // purging has not finished yet, which is not expected with sufficiently
        // large PURGE_INTERVAL.
        let time_of_last_purge = *self.time_of_last_purge.read().unwrap();
        if time_source.get_relative_time() - time_of_last_purge >= self.purge_interval_secs {
            if self.purging_queue.send(PurgingRequest::Purge).is_err() {
                error!(
                    self.log,
                    "Purging thread exited unexpectedly. This is a bug."
                );
                self.metrics.io_errors.inc();
            }

            // Set the time to current
            *self.time_of_last_purge.write().unwrap() = time_source.get_relative_time();
        }
    }
// Filters the new artifacts and asynchronously writes the relevant artifacts
// to the disk.
Filters the new artifacts and asynchronously writes the relevant artifacts
to the disk.
Filters the new artifacts and asynchronously writes the relevant artifacts to the disk .
pub fn store(&self, time_source: &dyn TimeSource, artifacts: Vec<ConsensusMessage>) {
        // If the queue is full, we will block here.
        if self
            .backup_queue
            .send(BackupRequest::Backup(artifacts))
            .is_err()
        {
            error!(
                self.log,
                "Backup thread exited unexpectedly. This is a bug."
            );
            self.metrics.io_errors.inc();
        }
        // If we didn't purge within the last PURGE_INTERVAL, trigger a new purge.
        // This way we avoid a too frequent purging. We also block if the previous
        // purging has not finished yet, which is not expected with sufficiently
        // large PURGE_INTERVAL.
        let time_of_last_purge = *self.time_of_last_purge.read().unwrap();
        if time_source.get_relative_time() - time_of_last_purge >= self.purge_interval_secs {
            if self.purging_queue.send(PurgingRequest::Purge).is_err() {
                error!(
                    self.log,
                    "Purging thread exited unexpectedly. This is a bug."
                );
                self.metrics.io_errors.inc();
            }
            // Set the time to current
            *self.time_of_last_purge.write().unwrap() = time_source.get_relative_time();
        }
    }
pub fn store ( & self , time_source : & dyn TimeSource , artifacts : Vec < ConsensusMessage > ) { // If the queue is full, we will block here. if self . backup_queue . send ( BackupRequest :: Backup ( artifacts ) ) . is_err ( ) { error ! ( self log " " ) ; self . metrics . io_errors . inc ( ) ; } // If we didn't purge within the last PURGE_INTERVAL, trigger a new purge. // This way we avoid a too frequent purging. We also block if the previous // purging has not finished yet, which is not expected with sufficiently // large PURGE_INTERVAL. let time_of_last_purge = * self . time_of_last_purge . read ( ) . unwrap ( ) ; if time_source . get_relative_time ( ) - time_of_last_purge >= self . purge_interval_secs { if self . purging_queue . send ( PurgingRequest :: Purge ) . is_err ( ) { error ! ( self log " " ) ; self . metrics . io_errors . inc ( ) ; } // Set the time to current * self . time_of_last_purge . write ( ) . unwrap ( ) = time_source . get_relative_time ( ) ; } }
Filters the new artifacts and asynchronously writes the relevant artifacts
to the disk.
Filters the new artifacts and asynchronously writes the relevant artifacts to the disk .
&self
time_source
&dyn TimeSource
artifacts
Vec<ConsensusMessage>
&self
time_source
&dyn TimeSource
artifacts
Vec<ConsensusMessage>