diff --git a/bump_test.go b/bump_test.go index 4cdc46a..61308e5 100644 --- a/bump_test.go +++ b/bump_test.go @@ -50,8 +50,7 @@ func TestNewBUMPFromMerkleTreeWithOnlyOneTxid(t *testing.T) { hash, err := chainhash.NewHashFromStr(txidSmallBlock) require.NoError(t, err) chainHashBlock = append(chainHashBlock, hash) - merkles, err := BuildMerkleTreeStoreChainHash(chainHashBlock) - require.NoError(t, err) + merkles := BuildMerkleTreeStoreChainHash(chainHashBlock) bump, err := NewBUMPFromMerkleTreeAndIndex(fakeMadeUpNum, merkles, uint64(0)) require.NoError(t, err) root, err := bump.CalculateRootGivenTxid(txidSmallBlock) @@ -66,8 +65,7 @@ func TestNewBUMPFromMerkleTree(t *testing.T) { require.NoError(t, err) chainHashBlock = append(chainHashBlock, hash) } - merkles, err := BuildMerkleTreeStoreChainHash(chainHashBlock) - require.NoError(t, err) + merkles := BuildMerkleTreeStoreChainHash(chainHashBlock) for txIndex, txid := range blockTxExample { bump, err := NewBUMPFromMerkleTreeAndIndex(fakeMadeUpNum, merkles, uint64(txIndex)) require.NoError(t, err) @@ -108,8 +106,7 @@ func TestTestnetCalculateRootGivenTxid(t *testing.T) { require.NoError(t, err) chainHashBlock = append(chainHashBlock, hash) } - merkles, err := BuildMerkleTreeStoreChainHash(chainHashBlock) - require.NoError(t, err) + merkles := BuildMerkleTreeStoreChainHash(chainHashBlock) for txIndex, txid := range testnetBlockExample { bump, err := NewBUMPFromMerkleTreeAndIndex(1575794, merkles, uint64(txIndex)) require.NoError(t, err) @@ -161,8 +158,7 @@ func TestTxids(t *testing.T) { require.NoError(t, err) chainHashBlock = append(chainHashBlock, hash) } - merkles, err := BuildMerkleTreeStoreChainHash(chainHashBlock) - require.NoError(t, err) + merkles := BuildMerkleTreeStoreChainHash(chainHashBlock) bump, err := NewBUMPFromMerkleTreeAndIndex(1575794, merkles, uint64(0)) require.NoError(t, err) @@ -177,8 +173,7 @@ func TestOnlySpecifiedPathsStored(t *testing.T) { require.NoError(t, err) chainHashBlock = append(chainHashBlock, hash) } - merkles, err := BuildMerkleTreeStoreChainHash(chainHashBlock) - require.NoError(t, err) + merkles := BuildMerkleTreeStoreChainHash(chainHashBlock) for idx := range blockTxExample { bump, err := NewBUMPFromMerkleTreeAndIndex(1575794, merkles, uint64(idx)) diff --git a/merkleroot.go b/merkleroot.go index 68be47f..8404256 100644 --- a/merkleroot.go +++ b/merkleroot.go @@ -130,7 +130,7 @@ func BuildMerkleTreeStore(txids []string) ([]string, error) { } // BuildMerkleTreeStoreChainHash has the same functionality as BuildMerkleTreeStore but uses chainhash as a type to avoid string conversions. -func BuildMerkleTreeStoreChainHash(txids []*chainhash.Hash) ([]*chainhash.Hash, error) { +func BuildMerkleTreeStoreChainHash(txids []*chainhash.Hash) []*chainhash.Hash { // // Calculate how many entries are re?n array of that size. nextPoT := nextPowerOfTwo(len(txids)) arraySize := nextPoT*2 - 1 @@ -161,7 +161,7 @@ func BuildMerkleTreeStoreChainHash(txids []*chainhash.Hash) ([]*chainhash.Hash, offset++ } - return merkles, nil + return merkles } // nextPowerOfTwo returns the next highest power of two from a given number if diff --git a/merkleroot_test.go b/merkleroot_test.go index f1e6bf5..0606c2c 100644 --- a/merkleroot_test.go +++ b/merkleroot_test.go @@ -75,8 +75,7 @@ func TestBuildMerkleTreeStoreChainHash(t *testing.T) { transactionHashes[i], _ = chainhash.NewHashFromStr(txid) } - merkleTreeChainStore, err := bc.BuildMerkleTreeStoreChainHash(transactionHashes) - require.NoError(t, err) + merkleTreeChainStore := bc.BuildMerkleTreeStoreChainHash(transactionHashes) actual := merkleTreeChainStore[len(merkleTreeChainStore)-1].String() @@ -114,8 +113,7 @@ func TestBuildMerkleTreeStoreChainHashDifferentSizes(t *testing.T) { transactionHashes[idx] = h } - merkleTreeChainStore, err := bc.BuildMerkleTreeStoreChainHash(transactionHashes) - require.NoError(t, err) + merkleTreeChainStore := bc.BuildMerkleTreeStoreChainHash(transactionHashes) actual := merkleTreeChainStore[len(merkleTreeChainStore)-1].String()