MerkleTree<T>.fromList constructor

MerkleTree<T>.fromList(
  1. List<T> items, {
  2. String hashFunction(
    1. T
    )?,
  3. String salt = '',
})

Creates a Merkle tree from a list of data items

Implementation

factory MerkleTree.fromList(
  List<T> items, {
  String Function(T)? hashFunction,
  String salt = '',
}) {
  if (items.isEmpty) {
    return MerkleTree<T>(hashFunction: hashFunction, salt: salt);
  }

  final tree = MerkleTree<T>(hashFunction: hashFunction, salt: salt);
  return tree._buildTree(items);
}