public MerkleTreeFomatter(string identifier, int chunkSize, List <MerkleNode> listFullLeaves, String merkleRoot) { List <String> listleaves = new List <String>(); foreach (MerkleNode fullLeaf in listFullLeaves) { ; listleaves.Add(fullLeaf.Hash); } merkleTree = new FormattedTree(identifier, chunkSize, listleaves, merkleRoot); }
public void Build(List <String> data_chunks, int chunk_size, string idenfier) { merkleTree = new List <MerkleNode>(); List <MerkleNode> list_leaves = InitTree(data_chunks); List <MerkleNode> current_nodes = list_leaves; merkleTree.AddRange(current_nodes); int lastIndex = 0; while (current_nodes.Count() != 1) { System.Diagnostics.Debug.WriteLine(lastIndex); System.Diagnostics.Debug.WriteLine(current_nodes.Count()); current_nodes = buildTree(current_nodes, lastIndex); System.Diagnostics.Debug.WriteLine(current_nodes.Count()); lastIndex = merkleTree.Count() - 1; merkleTree.AddRange(current_nodes); } merkleTree.AddRange(current_nodes); merkleRoot = current_nodes[0].Hash; formattedMerkleTree = new MerkleTreeFomatter(idenfier, chunk_size, list_leaves, merkleRoot).merkleTree; }