Function ckb_merkle_mountain_range::helper::get_peak_map
source · pub fn get_peak_map(mmr_size: u64) -> u64
Expand description
Returns the height of the peaks in the mmr, presented by a bitmap.
for example, for a mmr with 11 leaves, the mmr_size is 19, it will return 0b1011.
0b1011 indicates that the left peaks are at height 0, 1 and 3.
14
/
6 13
/ \ /
2 5 9 12 17
/ \ / \ / \ / \ /
0 1 3 4 7 8 10 11 15 16 18
please note that when the mmr_size is invalid, it will return the bitmap of the last valid mmr.
in the below example, the mmr_size is 6, but it’s not a valid mmr, it will return 0b11.
2 5
/ \ /
0 1 3 4