public TreeHash(string algorithm)
{
- BlockHash = algorithm;
- _topHash = new Lazy<byte[]>(() => Signature.CalculateTopHash(_hashes, BlockHash));
-
- _topHash2 = new Lazy<string>(() =>
- {
- var hashString = _hashes.Select(hash => hash.ToHashString())
- .Aggregate(new StringBuilder(),
- (builder, hash) => builder.Append(hash),
- builder => builder.ToString());
-
- return Signature.CalculateTopHash(hashString, BlockHash);
- });
+ BlockHash = algorithm;
+ _topHash = new Lazy<byte[]>(() =>
+ {
+ //
+ //Cast the hashes to an IList or create a new list out of the hashes
+ var hashMap = (_hashes as IList<byte[]>)??_hashes.ToList();
+ return Signature.CalculateTopHash(hashMap, BlockHash);
+ });
}
//Returns a Json representation of the hashes, as required by Pithos