Skip to content

Commit

Permalink
feat: fixed types for branches
Browse files Browse the repository at this point in the history
  • Loading branch information
f7f376a1fcd0d0e11a10ed1b6577c9 committed Sep 19, 2023
1 parent 9efda48 commit d07536c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions dag/leaves.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (leaf *DagLeaf) GetBranch(key string) (*ClassicTreeBranch, error) {
t.AddLeaf(k, v)
}

merkleTree, leafs, err := t.Build()
merkleTree, _, err := t.Build()
if err != nil {
log.Println("Failed to build merkle tree")
return nil, err
Expand All @@ -221,10 +221,10 @@ func (leaf *DagLeaf) GetBranch(key string) (*ClassicTreeBranch, error) {
return nil, fmt.Errorf("Unable to find index for given key")
}

branchLeaf := leafs[key]
branchLeaf := leaf.Links[key]

branch := &ClassicTreeBranch{
Leaf: &branchLeaf,
Leaf: branchLeaf,
Proof: merkleTree.Proofs[index],
}

Expand All @@ -235,7 +235,9 @@ func (leaf *DagLeaf) GetBranch(key string) (*ClassicTreeBranch, error) {
}

func (leaf *DagLeaf) VerifyBranch(branch *ClassicTreeBranch) (bool, error) {
result, err := merkletree.Verify(*branch.Leaf, branch.Proof, leaf.MerkleRoot, nil)
block := tree.CreateLeaf(branch.Leaf)

result, err := merkletree.Verify(block, branch.Proof, leaf.MerkleRoot, nil)
if err != nil {
return false, err
}
Expand Down
2 changes: 1 addition & 1 deletion dag/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type DagLeafBuilder struct {
}

type ClassicTreeBranch struct {
Leaf *merkletree.DataBlock
Leaf string
Proof *merkletree.Proof
}

Expand Down

0 comments on commit d07536c

Please sign in to comment.