From 8d865f17fcccdc4ac812c260681f0add2b822cd2 Mon Sep 17 00:00:00 2001 From: David Case Date: Fri, 18 Oct 2024 10:16:26 -0400 Subject: [PATCH] swap names of MerkleTreeParent and MerkleTreeParentBytes --- transaction/merkletreeparent.go | 10 +++++----- transaction/merkletreeparent_test.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/transaction/merkletreeparent.go b/transaction/merkletreeparent.go index 38ef4d2..88e24f7 100644 --- a/transaction/merkletreeparent.go +++ b/transaction/merkletreeparent.go @@ -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) @@ -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[:]) diff --git a/transaction/merkletreeparent_test.go b/transaction/merkletreeparent_test.go index d2857de..4ca1715 100644 --- a/transaction/merkletreeparent_test.go +++ b/transaction/merkletreeparent_test.go @@ -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) }