pub const fn u64_to_timelock(u: u64) -> Timelock
Expand description
Height/time is not differentiated via type, but rather:
“height is any value less than MAX_BLOCK_HEIGHT
and timestamp is any value above”
so the u64/usize
is stored without any tag.
See timelock_to_u64
for the inverse function.
- https://github.com/Cuprate/cuprate/pull/102#discussion_r1558504285
- https://github.com/serai-dex/serai/blob/bc1dec79917d37d326ac3d9bc571a64131b0424a/coins/monero/src/transaction.rs#L139
use cuprate_constants::block::{MAX_BLOCK_HEIGHT, MAX_BLOCK_HEIGHT_USIZE};
assert_eq!(u64_to_timelock(0), Timelock::None);
assert_eq!(u64_to_timelock(MAX_BLOCK_HEIGHT-1), Timelock::Block(MAX_BLOCK_HEIGHT_USIZE-1));
assert_eq!(u64_to_timelock(MAX_BLOCK_HEIGHT), Timelock::Time(MAX_BLOCK_HEIGHT));