Returns the subroots of the MMR.
(&self)
| 45 | |
| 46 | /// Returns the subroots of the MMR. |
| 47 | fn get_subroots(&self) -> Vec<[u8; 32]> { |
| 48 | let mut subroots: Vec<[u8; 32]> = vec![]; |
| 49 | for level in &self.nodes { |
| 50 | if level.len() % 2 == 1 { |
| 51 | subroots.push(level[level.len() - 1]); |
| 52 | } |
| 53 | } |
| 54 | subroots.reverse(); |
| 55 | subroots |
| 56 | } |
| 57 | |
| 58 | /// Generates a proof for a given index. Returns the leaf as well. |
| 59 | pub fn generate_proof(&self, index: u32) -> ([u8; 32], MMRInclusionProof) { |