MCPcopy Create free account
hub / github.com/dfinity/orbit / calculate_minimum_threshold

Function calculate_minimum_threshold

core/station/impl/src/core/utils.rs:77–86  ·  view source on GitHub ↗

Calculates the minimum threshold for a given percentage and total value. This only works for percentages between 0 and 100 (inclusive).

(percentage: &Percentage, total_value: &usize)

Source from the content-addressed store, hash-verified

75///
76/// This only works for percentages between 0 and 100 (inclusive).
77pub fn calculate_minimum_threshold(percentage: &Percentage, total_value: &usize) -> usize {
78 let Percentage(percentage) = percentage;
79 let percentage = *percentage as usize;
80 let scaled_total = percentage * total_value;
81
82 match scaled_total % 100 {
83 0 => scaled_total / 100,
84 _ => (scaled_total / 100) + 1,
85 }
86}
87
88/// Retains items based on the result of a authorization check evaluation.
89///

Callers 1

evaluateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected