Skip to content

Commit

Permalink
deduplicate type definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Feb 26, 2024
1 parent 64b7dfa commit 5d5deb8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/merkletree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ export abstract class MerkleTreeImpl<T> implements MerkleTree<T> {
protected constructor(
protected readonly tree: HexString[],
protected readonly values: MerkleTreeData<T>['values'],
public readonly leafHash: (leaf: T) => HexString,
public readonly leafHash: MerkleTree<T>['leafHash']
) {
this.hashLookup = Object.fromEntries(values.map(({ treeIndex }, valueIndex) => [tree.at(treeIndex), valueIndex]));
}

protected static prepare<T>(
values: T[],
options: MerkleTreeOptions = {},
leafHash: (value: T) => HexString,
leafHash: MerkleTree<T>['leafHash'],
): [tree: HexString[], indexedValues: MerkleTreeData<T>['values']] {
const sortLeaves = options.sortLeaves ?? defaultOptions.sortLeaves;
const hashedValues = values.map((value, valueIndex) => ({ value, valueIndex, hash: leafHash(value) }));
Expand Down

0 comments on commit 5d5deb8

Please sign in to comment.