fn apply_changes(&mut self, change_set: ChangeSet) {
        for action in change_set {
            match action {
                ChangeAction::HandleInvalid(hash, _) => {
                    self.unvalidated.remove(&hash);
                }
                ChangeAction::AddToValidated(message) => {
                    self.validated.insert(
                        ic_crypto::crypto_hash(&message),
                        ValidatedArtifact {
                            msg: message,
                            timestamp: current_time(),
                        },
                    );
                }
                ChangeAction::MoveToValidated(message) => {
                    let hash = crypto_hash(&message);
                    self.unvalidated
                        .remove(&hash)
                        .expect("Unvalidated artifact was not found.");
                    self.validated.insert(
                        hash,
                        ValidatedArtifact {
                            msg: message,
                            timestamp: current_time(),
                        },
                    );
                }
                ChangeAction::RemoveFromUnvalidated(message) => {
                    let hash = crypto_hash(&message);
                    self.unvalidated
                        .remove(&hash)
                        .expect("Unvalidated artifact was not found.");
                }
                ChangeAction::Purge(height) => self.purge(height),
            }
        }
    }
/// Applies the provided change set atomically.
///
/// # Panics
///
/// It panics if we pass a hash for an artifact to be moved into the
/// validated section, but it cannot be found in the unvalidated
/// section.
Applies the provided change set atomically.
Applies the provided change set atomically .
fn apply_changes(&mut self, change_set: ChangeSet) {
        for action in change_set {
            match action {
                ChangeAction::HandleInvalid(hash, _) => {
                    self.unvalidated.remove(&hash);
                }
                ChangeAction::AddToValidated(message) => {
                    self.validated.insert(
                        ic_crypto::crypto_hash(&message),
                        ValidatedArtifact {
                            msg: message,
                            timestamp: current_time(),
                        },
                    );
                }
                ChangeAction::MoveToValidated(message) => {
                    let hash = crypto_hash(&message);
                    self.unvalidated
                        .remove(&hash)
                        .expect("Unvalidated artifact was not found.");
                    self.validated.insert(
                        hash,
                        ValidatedArtifact {
                            msg: message,
                            timestamp: current_time(),
                        },
                    );
                }
                ChangeAction::RemoveFromUnvalidated(message) => {
                    let hash = crypto_hash(&message);
                    self.unvalidated
                        .remove(&hash)
                        .expect("Unvalidated artifact was not found.");
                }
                ChangeAction::Purge(height) => self.purge(height),
            }
        }
    }
fn apply_changes ( & mut self , change_set : ChangeSet ) { for action in change_set { match action { ChangeAction :: HandleInvalid ( hash , _ ) => { self . unvalidated . remove ( & hash ) ; } ChangeAction :: AddToValidated ( message ) => { self . validated . insert ( ic_crypto :: crypto_hash ( & message ) , ValidatedArtifact { msg : message , timestamp : current_time ( ) , } , ) ; } ChangeAction :: MoveToValidated ( message ) => { let hash = crypto_hash ( & message ) ; self . unvalidated . remove ( & hash ) . expect ( " " ) ; self . validated . insert ( hash , ValidatedArtifact { msg : message , timestamp : current_time ( ) , } , ) ; } ChangeAction :: RemoveFromUnvalidated ( message ) => { let hash = crypto_hash ( & message ) ; self . unvalidated . remove ( & hash ) . expect ( " " ) ; } ChangeAction :: Purge ( height ) => self . purge ( height ) , } } }
Applies the provided change set atomically.
Applies the provided change set atomically .
&mut self
change_set
ChangeSet
&mut self
change_set
ChangeSet
panics
It panics if we pass a hash for an artifact to be moved into the
validated section, but it cannot be found in the unvalidated
section.
It panics if we pass a hash for an artifact to be moved into the validated section but it cannot be found in the unvalidated section .