Skip to content

Commit

Permalink
swap names of MerkleTreeParent and MerkleTreeParentBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
shruggr committed Oct 18, 2024
1 parent ce13b00 commit 8d865f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions transaction/merkletreeparent.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ func MerkleTreeParentStr(leftNode, rightNode string) (string, error) {
return "", err
}

return hex.EncodeToString(MerkleTreeParent(l, r)), nil
return hex.EncodeToString(MerkleTreeParentBytes(l, r)), nil
}

// MerkleTreeParent returns the Merkle Tree parent of two MerkleTree children.
func MerkleTreeParent(leftNode, rightNode []byte) []byte {
// MerkleTreeParentBytes returns the Merkle Tree parent of two MerkleTree children.
func MerkleTreeParentBytes(leftNode, rightNode []byte) []byte {
concatenated := flipTwoArrays(leftNode, rightNode)

hash := crypto.Sha256d(concatenated)
Expand All @@ -47,9 +47,9 @@ func flipTwoArrays(a, b []byte) []byte {
return result
}

// MerkleTreeParentBytes returns the Merkle Tree parent of two Merkle Tree children.
// MerkleTreeParent returns the Merkle Tree parent of two Merkle Tree children.
// The expectation is that the bytes are not reversed.
func MerkleTreeParentBytes(l *chainhash.Hash, r *chainhash.Hash) *chainhash.Hash {
func MerkleTreeParents(l *chainhash.Hash, r *chainhash.Hash) *chainhash.Hash {
concatenated := make([]byte, len(l)+len(r))
copy(concatenated, l[:])
copy(concatenated[len(l):], r[:])
Expand Down
2 changes: 1 addition & 1 deletion transaction/merkletreeparent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestGetMerkleTreeParent(t *testing.T) {

expected, _ := hex.DecodeString("b0d537b3ee52e472507f453df3d69561720346118a5a8c4d85ca0de73bc792be")

parent := transaction.MerkleTreeParent(leftNode, rightNode)
parent := transaction.MerkleTreeParentBytes(leftNode, rightNode)

require.Equal(t, expected, parent)
}

0 comments on commit 8d865f1

Please sign in to comment.