diff --git a/pkg/crypto/hash/merkle_tree.go b/pkg/crypto/hash/merkle_tree.go index 6e980d0b1..9d6642efa 100644 --- a/pkg/crypto/hash/merkle_tree.go +++ b/pkg/crypto/hash/merkle_tree.go @@ -25,13 +25,8 @@ func NewMerkleTree(hashes []util.Uint256) (*MerkleTree, error) { } } - root, err := buildMerkleTree(nodes) - if err != nil { - return nil, err - } - return &MerkleTree{ - root: root, + root: buildMerkleTree(nodes), depth: 1, }, nil } @@ -41,12 +36,12 @@ func (t *MerkleTree) Root() util.Uint256 { return t.root.hash } -func buildMerkleTree(leaves []*MerkleTreeNode) (*MerkleTreeNode, error) { +func buildMerkleTree(leaves []*MerkleTreeNode) *MerkleTreeNode { if len(leaves) == 0 { - return nil, errors.New("length of the leaves cannot be zero") + panic("length of leaves cannot be zero") } if len(leaves) == 1 { - return leaves[0], nil + return leaves[0] } parents := make([]*MerkleTreeNode, (len(leaves)+1)/2)