updateLeaf method
Updates a leaf and recalculates affected hashes
Implementation
MerkleTree<T> updateLeaf(int index, T newData) {
if (index < 0 || index >= leafCount) {
throw ArgumentError('Invalid leaf index: $index');
}
final newLeaves = List<T>.from(_leaves);
newLeaves[index] = newData;
return MerkleTree.fromList(
newLeaves,
hashFunction: hashFunction,
salt: _salt,
);
}