pub fn update_methods_authz(methods_authz_change: Vec<MethodAuthzChange>, log_prefix: &str) {
    println!(
        "{}Changing authz. Previous: {:?}. Changes: {:?}",
        log_prefix,
        current_canister_authz(),
        methods_authz_change
    );
    let mut authz = AUTHZ_MAP.write().unwrap();
    for method_authz_change in methods_authz_change {
        // Note that we always expect a principal here.
        // The root canister is responsible for setting the right principal
        // before it gets here, if 'Authorize::add_self' was true.
        let principal = method_authz_change
            .principal
            .expect("Expected to receive a principal.");
        let method_name = method_authz_change.method_name;
        match method_authz_change.operation {
            AuthzChangeOp::Authorize { add_self: _ } => {
                let method_authz = authz.entry(method_name.clone()).or_insert(MethodAuthzInfo {
                    method_name,
                    principal_ids: Vec::new(),
                });
                method_authz.principal_ids.push(principal.to_vec());
            }
            AuthzChangeOp::Deauthorize => {
                // Remove the principal, if it exists.
                // If the method doesn't have any authorized principals, remove the
                // MethodsAuthzInfo
                if let Some(method_authz) = authz.get_mut(&method_name) {
                    method_authz
                        .principal_ids
                        .retain(|p| *p != principal.to_vec());
                }
            }
        }
    }
}
/// Updates this canister's authz.
Updates this canister's authz.
Updates this canister ' s authz .
pub fn update_methods_authz(methods_authz_change: Vec<MethodAuthzChange>, log_prefix: &str) {
    println!(
        "{}Changing authz. Previous: {:?}. Changes: {:?}",
        log_prefix,
        current_canister_authz(),
        methods_authz_change
    );
    let mut authz = AUTHZ_MAP.write().unwrap();
    for method_authz_change in methods_authz_change {
        // Note that we always expect a principal here.
        // The root canister is responsible for setting the right principal
        // before it gets here, if 'Authorize::add_self' was true.
        let principal = method_authz_change
            .principal
            .expect("Expected to receive a principal.");
        let method_name = method_authz_change.method_name;
        match method_authz_change.operation {
            AuthzChangeOp::Authorize { add_self: _ } => {
                let method_authz = authz.entry(method_name.clone()).or_insert(MethodAuthzInfo {
                    method_name,
                    principal_ids: Vec::new(),
                });
                method_authz.principal_ids.push(principal.to_vec());
            }
            AuthzChangeOp::Deauthorize => {
                // Remove the principal, if it exists.
                // If the method doesn't have any authorized principals, remove the
                // MethodsAuthzInfo
                if let Some(method_authz) = authz.get_mut(&method_name) {
                    method_authz
                        .principal_ids
                        .retain(|p| *p != principal.to_vec());
                }
            }
        }
    }
}
pub fn update_methods_authz ( methods_authz_change : Vec < MethodAuthzChange > , log_prefix : & str ) { println ! ( " " log_prefix current_canister_authz ( ) methods_authz_change ) ; let mut authz = AUTHZ_MAP . write ( ) . unwrap ( ) ; for method_authz_change in methods_authz_change { // Note that we always expect a principal here. // The root canister is responsible for setting the right principal // before it gets here, if 'Authorize::add_self' was true. let principal = method_authz_change . principal . expect ( " " ) ; let method_name = method_authz_change . method_name ; match method_authz_change . operation { AuthzChangeOp :: Authorize { add_self : _ } => { let method_authz = authz . entry ( method_name . clone ( ) ) . or_insert ( MethodAuthzInfo { method_name , principal_ids : Vec :: new ( ) , } ) ; method_authz . principal_ids . push ( principal . to_vec ( ) ) ; } AuthzChangeOp :: Deauthorize => { // Remove the principal, if it exists. // If the method doesn't have any authorized principals, remove the // MethodsAuthzInfo if let Some ( method_authz ) = authz . get_mut ( & method_name ) { method_authz . principal_ids . retain ( | p | * p != principal . to_vec ( ) ) ; } } } } }
Updates this canister's authz.
Updates this canister ' s authz .
methods_authz_change
Vec<MethodAuthzChange>
log_prefix
&str
methods_authz_change
Vec<MethodAuthzChange>
log_prefix
&str