Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused returned error #82

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions bump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions merkleroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions merkleroot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
Loading