pub fn import_interchange_info(
        &self,
        interchange: Interchange,
        genesis_validators_root: Hash256,
    ) -> Result<Vec<InterchangeImportOutcome>, InterchangeError> {
        let version = interchange.metadata.interchange_format_version;
        if version != SUPPORTED_INTERCHANGE_FORMAT_VERSION {
            return Err(InterchangeError::UnsupportedVersion(version));
        }

        if genesis_validators_root != interchange.metadata.genesis_validators_root {
            return Err(InterchangeError::GenesisValidatorsMismatch {
                client: genesis_validators_root,
                interchange_file: interchange.metadata.genesis_validators_root,
            });
        }

        let mut conn = self.conn_pool.get()?;

        let mut import_outcomes = vec![];

        for record in interchange.data {
            let pubkey = record.pubkey;
            let txn = conn.transaction()?;
            match self.import_interchange_record(record, &txn) {
                Ok(summary) => {
                    import_outcomes.push(InterchangeImportOutcome::Success { pubkey, summary });
                    txn.commit()?;
                }
                Err(error) => {
                    import_outcomes.push(InterchangeImportOutcome::Failure { pubkey, error });
                }
            }
        }

        Ok(import_outcomes)
    }
/// Import slashing protection from another client in the interchange format.
///
/// Return a vector of public keys and errors for any validators whose data could not be
/// imported.
Import slashing protection from another client in the interchange format.
Return a vector of public keys and errors for any validators whose data could not be
imported.
Import slashing protection from another client in the interchange format . Return a vector of public keys and errors for any validators whose data could not be imported .
pub fn import_interchange_info(
        &self,
        interchange: Interchange,
        genesis_validators_root: Hash256,
    ) -> Result<Vec<InterchangeImportOutcome>, InterchangeError> {
        let version = interchange.metadata.interchange_format_version;
        if version != SUPPORTED_INTERCHANGE_FORMAT_VERSION {
            return Err(InterchangeError::UnsupportedVersion(version));
        }
        if genesis_validators_root != interchange.metadata.genesis_validators_root {
            return Err(InterchangeError::GenesisValidatorsMismatch {
                client: genesis_validators_root,
                interchange_file: interchange.metadata.genesis_validators_root,
            });
        }
        let mut conn = self.conn_pool.get()?;
        let mut import_outcomes = vec![];
        for record in interchange.data {
            let pubkey = record.pubkey;
            let txn = conn.transaction()?;
            match self.import_interchange_record(record, &txn) {
                Ok(summary) => {
                    import_outcomes.push(InterchangeImportOutcome::Success { pubkey, summary });
                    txn.commit()?;
                }
                Err(error) => {
                    import_outcomes.push(InterchangeImportOutcome::Failure { pubkey, error });
                }
            }
        }
        Ok(import_outcomes)
    }
pub fn import_interchange_info ( & self , interchange : Interchange , genesis_validators_root : Hash256 , ) -> Result < Vec < InterchangeImportOutcome > , InterchangeError > { let version = interchange . metadata . interchange_format_version ; if version != SUPPORTED_INTERCHANGE_FORMAT_VERSION { return Err ( InterchangeError :: UnsupportedVersion ( version ) ) ; } if genesis_validators_root != interchange . metadata . genesis_validators_root { return Err ( InterchangeError :: GenesisValidatorsMismatch { client : genesis_validators_root , interchange_file : interchange . metadata . genesis_validators_root , } ) ; } let mut conn = self . conn_pool . get ( ) ? ; let mut import_outcomes = vec ! [ ] ; for record in interchange . data { let pubkey = record . pubkey ; let txn = conn . transaction ( ) ? ; match self . import_interchange_record ( record , & txn ) { Ok ( summary ) => { import_outcomes . push ( InterchangeImportOutcome :: Success { pubkey , summary } ) ; txn . commit ( ) ? ; } Err ( error ) => { import_outcomes . push ( InterchangeImportOutcome :: Failure { pubkey , error } ) ; } } } Ok ( import_outcomes ) }
Import slashing protection from another client in the interchange format.
Import slashing protection from another client in the interchange format .
&self
interchange
Interchange
genesis_validators_root
Hash256