/// This reconciles the key pair of a validator signer with a given validator set
/// during epoch changes.
/// Current impl of consensus does not expect key reconciliation to panic or fail.
/// Instead, we signal debug messages indicating following error causes:
///     1. Validator not in the set
///     2. Validator in the set, but no matching key found in storage
This reconciles the key pair of a validator signer with a given validator set
during epoch changes.
Current impl of consensus does not expect key reconciliation to panic or fail.
Instead, we signal debug messages indicating following error causes:
1. Validator not in the set
2. Validator in the set, but no matching key found in storage
This reconciles the key pair of a validator signer with a given validator set during epoch changes . Current impl of consensus does not expect key reconciliation to panic or fail . Instead we signal debug messages indicating following error causes : 1 . Validator not in the set 2 . Validator in the set but no matching key found in storage
fn reconcile_key(&mut self, epoch_state: &EpochState) -> Result<(), Error> {
        if let Some(expected_key) = epoch_state.verifier.get_public_key(&self.author) {
            let curr_key = self.signer().ok().map(|s| s.public_key());
            if curr_key != Some(expected_key.clone()) {
                let consensus_key = self
                    .persistent_storage
                    .consensus_key_for_version(expected_key.clone())
                    .ok()
                    .ok_or_else(|| {
                        debug!("Validator key not found!");
                        self.validator_signer = None;
                        Error::InternalError {
                            error: "Validator key not found".into(),
                        }
                    })?;
                debug!(
                    "Reconciled pub key for signer {} [{:#?} -> {}]",
                    self.author, curr_key, expected_key
                );
                self.validator_signer = Some(ValidatorSigner::new(self.author, consensus_key));
            } else {
                debug!("Validator key matches the key in validator set.");
            }
        } else {
            debug!("The validator is not in set!");
            self.validator_signer = None;
        }
        Ok(())
    }
fn reconcile_key ( & mut self , epoch_state : & EpochState ) -> Result < ( ) , Error > { if let Some ( expected_key ) = epoch_state . verifier . get_public_key ( & self . author ) { let curr_key = self . signer ( ) . ok ( ) . map ( | s | s . public_key ( ) ) ; if curr_key != Some ( expected_key . clone ( ) ) { let consensus_key = self . persistent_storage . consensus_key_for_version ( expected_key . clone ( ) ) . ok ( ) . ok_or_else ( | | { debug ! ( " " ) ; self . validator_signer = None ; Error :: InternalError { error : " " . into ( ) , } } ) ? ; debug ! ( " " self author curr_key expected_key ) ; self . validator_signer = Some ( ValidatorSigner :: new ( self . author , consensus_key ) ) ; } else { debug ! ( " " ) ; } } else { debug ! ( " " ) ; self . validator_signer = None ; } Ok ( ( ) ) }
This reconciles the key pair of a validator signer with a given validator set
during epoch changes.
This reconciles the key pair of a validator signer with a given validator set during epoch changes .
&mut self
epoch_state
&EpochState