-
Notifications
You must be signed in to change notification settings - Fork 260
Description
In nym-develop/nym-node/src/config/gateway_tasks.rs, the inconsistency among comment, code and assertion cause confusion here, which should be fixed.
The assumption("ASSUMPTION: our validity period is AT LEAST 2 days") indicates that TICKETBOOK_VALIDITY_DAYS >= 2 days, which indicates TICKETBOOK_VALIDITY_DAYS - 1 >= 1 day. So target_secs should be >= 86400.
The comment will cause the confusion("making sure it's no greater than 1 day"). It indicate that it should be <= 86400, which is wrong semantically and should be changed it into "no lower than 1 day".
The assertion message requires target_secs >= 86400("no lower than"), while the predicate is target_secs > 86400, so I changed it into assert!(target_secs >= 86400,"the maximum time between redemption can't be lower than 1 day!");. This issue also appears in other places, I proposed #6238 to fix these problems.
// use min(4/5 of max validity, validity - 1), but making sure it's no greater than 1 day
// ASSUMPTION: our validity period is AT LEAST 2 days
//
// this could have been a constant, but it's more readable as a function
pub const fn default_maximum_time_between_redemption() -> Duration {
let desired_secs = TICKETBOOK_VALIDITY_DAYS * (86400 * 4) / 5;
let desired_secs_alt = (TICKETBOOK_VALIDITY_DAYS - 1) * 86400;
// can't use `min` in const context
let target_secs = if desired_secs < desired_secs_alt {
desired_secs
} else {
desired_secs_alt
};
assert!(
target_secs > 86400,
"the maximum time between redemption can't be lower than 1 day!"
);
Duration::from_secs(target_secs as u64)
}