MerkelTree.build constructor Null safety
- List<
Uint8List> hashes
Builds this Mekel Tree from a list of hashes.
Implementation
MerkelTree.build(this.hashes) {
if (hashes.length == 1) {
Uint8List hash = hashes.single;
proofs[hash] = (BytesBuilder()
..addByte(1)
..add(hash))
.toBytes();
root = Digest("SHA3-256").process((BytesBuilder()
..add(hash)
..add(hash))
.toBytes());
depth = 1;
} else {
root = _calculate([...hashes]);
}
}