cuprate_helper::map

Function timelock_to_u64

Source
pub const fn timelock_to_u64(timelock: Timelock) -> u64
Expand description

Map Timelock to a u64.

See u64_to_timelock for the inverse function and more documentation.

use cuprate_constants::block::{MAX_BLOCK_HEIGHT, MAX_BLOCK_HEIGHT_USIZE};
assert_eq!(timelock_to_u64(Timelock::None), 0);
assert_eq!(timelock_to_u64(Timelock::Block(MAX_BLOCK_HEIGHT_USIZE-1)), MAX_BLOCK_HEIGHT-1);
assert_eq!(timelock_to_u64(Timelock::Time(MAX_BLOCK_HEIGHT)), MAX_BLOCK_HEIGHT);