/// Applies the requested settings on the canister.
/// Note: Called only after validating the settings.
Applies the requested settings on the canister.
Note: Called only after validating the settings.
Applies the requested settings on the canister . Note : Called only after validating the settings .
fn do_update_settings(
        &self,
        settings: ValidatedCanisterSettings,
        canister: &mut CanisterState,
    ) {
        // Note: At this point, the settings are validated.
        if let Some(controller) = settings.controller {
            // Remove all the other controllers and add the new one.
            canister.system_state.controllers.clear();
            canister.system_state.controllers.insert(controller);
        }
        if let Some(controllers) = settings.controllers {
            canister.system_state.controllers.clear();
            for principal in controllers {
                canister.system_state.controllers.insert(principal);
            }
        }
        if let Some(compute_allocation) = settings.compute_allocation {
            canister.scheduler_state.compute_allocation = compute_allocation;
        }
        if let Some(memory_allocation) = settings.memory_allocation {
            // This should not happen normally because:
            //   1. `do_update_settings` is called during canister creation when the
            //       canister is empty and it should hold that memory usage of the
            //       canister is 0 and thus any number for memory allocation is bigger.
            //   2. When updating settings we have validated this holds.
            //
            // However, log an error in case it happens for visibility.
            if let MemoryAllocation::Reserved(bytes) = memory_allocation {
                if bytes < canister.memory_usage(self.config.own_subnet_type) {
                    error!(
                        self.log,
                        "Requested memory allocation of {} which is smaller than current canister memory usage {}",
                        bytes,
                        canister.memory_usage(self.config.own_subnet_type),
                    );
                }
            }
            canister.system_state.memory_allocation = memory_allocation;
        }
        if let Some(freezing_threshold) = settings.freezing_threshold {
            canister.system_state.freeze_threshold = freezing_threshold;
        }
    }
fn do_update_settings ( & self , settings : ValidatedCanisterSettings , canister : & mut CanisterState , ) { // Note: At this point, the settings are validated. if let Some ( controller ) = settings . controller { // Remove all the other controllers and add the new one. canister . system_state . controllers . clear ( ) ; canister . system_state . controllers . insert ( controller ) ; } if let Some ( controllers ) = settings . controllers { canister . system_state . controllers . clear ( ) ; for principal in controllers { canister . system_state . controllers . insert ( principal ) ; } } if let Some ( compute_allocation ) = settings . compute_allocation { canister . scheduler_state . compute_allocation = compute_allocation ; } if let Some ( memory_allocation ) = settings . memory_allocation { // This should not happen normally because: //   1. `do_update_settings` is called during canister creation when the //       canister is empty and it should hold that memory usage of the //       canister is 0 and thus any number for memory allocation is bigger. //   2. When updating settings we have validated this holds. // // However, log an error in case it happens for visibility. if let MemoryAllocation :: Reserved ( bytes ) = memory_allocation { if bytes < canister . memory_usage ( self . config . own_subnet_type ) { error ! ( self log " " bytes canister memory_usage ( self config own_subnet_type ) ) ; } } canister . system_state . memory_allocation = memory_allocation ; } if let Some ( freezing_threshold ) = settings . freezing_threshold { canister . system_state . freeze_threshold = freezing_threshold ; } }
Applies the requested settings on the canister.
Applies the requested settings on the canister .
&self
settings
ValidatedCanisterSettings
canister
&mut CanisterState