Function cuprate_helper::map::u64_to_timelock

source ·
pub const fn u64_to_timelock(u: u64) -> Timelock
Expand description

Map a u64 to a Timelock.

Height/time is not differentiated via type, but rather: “height is any value less than 500_000_000 and timestamp is any value above” so the u64/usize is stored without any tag.

See timelock_to_u64 for the inverse function.

assert_eq!(u64_to_timelock(0), Timelock::None);
assert_eq!(u64_to_timelock(499_999_999), Timelock::Block(499_999_999));
assert_eq!(u64_to_timelock(500_000_000), Timelock::Time(500_000_000));