Function polkadot_ckb_merkle_mountain_range::helper::get_peaks
source · pub fn get_peaks(mmr_size: u64) -> Vec<u64>
Expand description
Returns the pos of the peaks in the mmr.
for example, for a mmr with 11 leaves, the mmr_size is 19, it will return [14, 17, 18].
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 peaks of the last valid mmr.
in the below example, the mmr_size is 6, but it’s not a valid mmr, it will return [2, 3].
2 5
/ \ /
0 1 3 4