pub fn proof(&self, index: usize) -> Vec<H256> {
        let mut proof = Vec::new();
        if index >= self.leaf_num {
            return proof;
        }
        let height = find_height(self.leaf_num);
        let mut cur_index = index;
        let mut sequence = 0;
        for i in 0..height {
            // println!("{:?}", cur_index);
            let group = (cur_index - sequence)/2;
            if cur_index % 2 == 1 {
                proof.push(self.tree[cur_index-1]);
            }
            else {
                proof.push(self.tree[cur_index+1]);
            }
            if i == 0 {
                sequence += self.leaf_num;
            }
            else {
                sequence += 2usize.pow(height - i);
            }
            cur_index = sequence + group;
        }
        return proof;
    }
/// Returns the Merkle Proof of data at index i
Returns the Merkle Proof of data at index i
Returns the Merkle Proof of data at index i
pub fn proof(&self, index: usize) -> Vec<H256> {
        let mut proof = Vec::new();
        if index >= self.leaf_num {
            return proof;
        }
        let height = find_height(self.leaf_num);
        let mut cur_index = index;
        let mut sequence = 0;
        for i in 0..height {
            // println!("{:?}", cur_index);
            let group = (cur_index - sequence)/2;
            if cur_index % 2 == 1 {
                proof.push(self.tree[cur_index-1]);
            }
            else {
                proof.push(self.tree[cur_index+1]);
            }
            if i == 0 {
                sequence += self.leaf_num;
            }
            else {
                sequence += 2usize.pow(height - i);
            }
            cur_index = sequence + group;
        }
        return proof;
    }
pub fn proof ( & self , index : usize ) -> Vec < H256 > { let mut proof = Vec :: new ( ) ; if index >= self . leaf_num { return proof ; } let height = find_height ( self . leaf_num ) ; let mut cur_index = index ; let mut sequence = 0 ; for i in 0 .. height { // println!("{:?}", cur_index); let group = ( cur_index - sequence ) / 2 ; if cur_index % 2 == 1 { proof . push ( self . tree [ cur_index - 1 ] ) ; } else { proof . push ( self . tree [ cur_index + 1 ] ) ; } if i == 0 { sequence += self . leaf_num ; } else { sequence += 2usize . pow ( height - i ) ; } cur_index = sequence + group ; } return proof ; }
Returns the Merkle Proof of data at index i
Returns the Merkle Proof of data at index i
&self
index
usize