fn validate_memory_allocation(
        &self,
        memory_allocation_used: NumBytes,
        canister: &CanisterState,
        memory_allocation: Option<MemoryAllocation>,
    ) -> Result<(), CanisterManagerError> {
        if let Some(memory_allocation) = memory_allocation {
            let requested_allocation: NumBytes = memory_allocation.get();
            let canister_current_allocation = canister
                .memory_allocation()
                .unwrap_or_else(|| canister.memory_usage());
            if requested_allocation + memory_allocation_used - canister_current_allocation
                > self.config.subnet_memory_capacity
            {
                return Err(CanisterManagerError::SubnetMemoryCapacityOverSubscribed {
                    requested: requested_allocation,
                    available: self.config.subnet_memory_capacity
                        - memory_allocation_used
                        - canister_current_allocation,
                });
            }
        }
        Ok(())
    }
// Ensures that the subnet has enough memory capacity left to install the
// canister.
Ensures that the subnet has enough memory capacity left to install the
canister.
Ensures that the subnet has enough memory capacity left to install the canister .
fn validate_memory_allocation(
        &self,
        memory_allocation_used: NumBytes,
        canister: &CanisterState,
        memory_allocation: Option<MemoryAllocation>,
    ) -> Result<(), CanisterManagerError> {
        if let Some(memory_allocation) = memory_allocation {
            let requested_allocation: NumBytes = memory_allocation.get();
            let canister_current_allocation = canister
                .memory_allocation()
                .unwrap_or_else(|| canister.memory_usage());
            if requested_allocation + memory_allocation_used - canister_current_allocation
                > self.config.subnet_memory_capacity
            {
                return Err(CanisterManagerError::SubnetMemoryCapacityOverSubscribed {
                    requested: requested_allocation,
                    available: self.config.subnet_memory_capacity
                        - memory_allocation_used
                        - canister_current_allocation,
                });
            }
        }
        Ok(())
    }
fn validate_memory_allocation ( & self , memory_allocation_used : NumBytes , canister : & CanisterState , memory_allocation : Option < MemoryAllocation > , ) -> Result < ( ) , CanisterManagerError > { if let Some ( memory_allocation ) = memory_allocation { let requested_allocation : NumBytes = memory_allocation . get ( ) ; let canister_current_allocation = canister . memory_allocation ( ) . unwrap_or_else ( | | canister . memory_usage ( ) ) ; if requested_allocation + memory_allocation_used - canister_current_allocation > self . config . subnet_memory_capacity { return Err ( CanisterManagerError :: SubnetMemoryCapacityOverSubscribed { requested : requested_allocation , available : self . config . subnet_memory_capacity - memory_allocation_used - canister_current_allocation , } ) ; } } Ok ( ( ) ) }
Ensures that the subnet has enough memory capacity left to install the
canister.
Ensures that the subnet has enough memory capacity left to install the canister .
&self
memory_allocation_used
NumBytes
canister
&CanisterState
memory_allocation
Option<MemoryAllocation>
&self
memory_allocation_used
NumBytes
canister
&CanisterState
memory_allocation
Option<MemoryAllocation>