pub(crate) fn relative_position(
height: u64,
epoch_length: u64,
) -> RelativePositionExpand description
Returns the relative position of height in an epoch given epoch_length.
This function is written under the assumption that a height h belongs to
epoch E if (E*epoch_length) <= h <= (E+1)*epoch_length-1. For example,
for epoch_length == 1000, epoch E=0 includes blocks 0 to 999, epoch
E=1 includes 1000 to 1999, and so on.
For epoch length 1000, we have the following cases:
- heights 0 to 499, 1000 to 1499, etc: first half.
- heights 500, 1500, etc: middle.
- heights 501 to 999, 1501 to 1999, etc: second half.
ยงPanics
Panics if epoch_length = 0.