Merkle Mountain Range (MMR) implementation.
An MMR is an append-only data structure that provides:
- O(1) amortized append
- O(log n) inclusion proofs
- O(log n) consistency proofs
The structure consists of a series of perfect binary trees ("mountains") of decreasing height. When a new leaf is appended, it may trigger merging of equal-height trees.
Example
use ;
use hash;
let mut mmr = new;
// Append some leaves
let pos1 = mmr.append.unwrap;
let pos2 = mmr.append.unwrap;
let pos3 = mmr.append.unwrap;
// Get inclusion proof
let proof = mmr.proof.unwrap;
assert!;
// Get the root
let root = mmr.root;