pub fn certificates_weight<C, I>(&self, certs: I) -> Option<Weight>
    where
        C: Borrow<Certificate>,
        I: IntoIterator<Item = C>,
    {
        let mut certs = certs.into_iter().peekable();
        // if there are no certificates for the given public key, there is no info about this public key
        // or some elements of possible certificate chains was revoked
        certs.peek()?;

        let mut weight = std::u32::MAX;

        for cert in certs {
            let cert = cert.borrow();

            let root_weight = *self
                .root_weights
                .get(cert.chain.first()?.issued_for.as_ref())
                // This panic shouldn't happen // TODO: why?
                .expect("first trust in chain must be in root_weights");

            // certificate weight = root weight + 1 * every other element in the chain
            // (except root, so the formula is `root weight + chain length - 1`)
            weight = std::cmp::min(weight, root_weight + cert.chain.len() as u32 - 1)
        }

        Some(weight)
    }
/// Calculate weight from given certificates
/// Returns None if there is no such public key
/// or some trust between this key and a root key is revoked.
/// TODO handle non-direct revocations
Calculate weight from given certificates
Returns None if there is no such public key
or some trust between this key and a root key is revoked.
TODO handle non-direct revocations
Calculate weight from given certificates Returns None if there is no such public key or some trust between this key and a root key is revoked . TODO handle non - direct revocations
pub fn certificates_weight<C, I>(&self, certs: I) -> Option<Weight>
    where
        C: Borrow<Certificate>,
        I: IntoIterator<Item = C>,
    {
        let mut certs = certs.into_iter().peekable();
        // if there are no certificates for the given public key, there is no info about this public key
        // or some elements of possible certificate chains was revoked
        certs.peek()?;
        let mut weight = std::u32::MAX;
        for cert in certs {
            let cert = cert.borrow();
            let root_weight = *self
                .root_weights
                .get(cert.chain.first()?.issued_for.as_ref())
                // This panic shouldn't happen // TODO: why?
                .expect("first trust in chain must be in root_weights");
            // certificate weight = root weight + 1 * every other element in the chain
            // (except root, so the formula is `root weight + chain length - 1`)
            weight = std::cmp::min(weight, root_weight + cert.chain.len() as u32 - 1)
        }
        Some(weight)
    }
pub fn certificates_weight < C , I > ( & self , certs : I ) -> Option < Weight > where C : Borrow < Certificate > , I : IntoIterator < Item = C > , { let mut certs = certs . into_iter ( ) . peekable ( ) ; // if there are no certificates for the given public key, there is no info about this public key // or some elements of possible certificate chains was revoked certs . peek ( ) ? ; let mut weight = std :: u32 :: MAX ; for cert in certs { let cert = cert . borrow ( ) ; let root_weight = * self . root_weights . get ( cert . chain . first ( ) ? . issued_for . as_ref ( ) ) // This panic shouldn't happen // TODO: why? . expect ( " " ) ; // certificate weight = root weight + 1 * every other element in the chain // (except root, so the formula is `root weight + chain length - 1`) weight = std :: cmp :: min ( weight , root_weight + cert . chain . len ( ) as u32 - 1 ) } Some ( weight ) }
Calculate weight from given certificates
Returns None if there is no such public key
or some trust between this key and a root key is revoked.
Calculate weight from given certificates Returns None if there is no such public key or some trust between this key and a root key is revoked .
&self
certs
I