Skip to content

Commit

Permalink
Linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsporn committed Oct 10, 2023
1 parent 613cec7 commit dbd1781
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions commitment_roots.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func (r *Roots) MutationProof() *merklehasher.Proof[Identifier] {

func VerifyProof(proof *merklehasher.Proof[Identifier], proofedRoot Identifier, treeRoot Identifier) bool {
// We can ignore the error because Identifier.Bytes() will never return an error
//nolint:nosnakecase // false positive
if !lo.PanicOnErr(proof.ContainsValue(proofedRoot, merklehasher.NewHasher[Identifier](crypto.BLAKE2b_256))) {
return false
}
Expand Down
1 change: 1 addition & 0 deletions merklehasher/merkle_hasher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func TestMerkleHasher(t *testing.T) {
includedBlocks = append(includedBlocks, iotago.MustBlockIDFromHexString("0x0bf5059875921e668a5bdf2c7fc4844592d2572bcd0668d2d6c52f5054e2d08300000000"))
includedBlocks = append(includedBlocks, iotago.MustBlockIDFromHexString("0x6bf84c7174cb7476364cc3dbd968b0f7172ed85794bb358b0c3b525da1786f9f00000000"))

//nolint:nosnakecase // false positive
hasher := merklehasher.NewHasher[iotago.BlockID](crypto.BLAKE2b_256)
hash, err := hasher.HashValues(includedBlocks)
require.NoError(t, err)
Expand Down
3 changes: 3 additions & 0 deletions merklehasher/merkle_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,17 @@ func (t *Hasher[V]) computeProof(data [][]byte, index int) (MerkleHashable[V], e
}, nil
}

//nolint:unused // False positive
func (l *ValueHash[V]) hash(_ *Hasher[V]) []byte {
return l.Hash
}

//nolint:unused // False positive
func (h *LeafHash[V]) hash(_ *Hasher[V]) []byte {
return h.Hash
}

//nolint:unused // False positive
func (p *Node[V]) hash(hasher *Hasher[V]) []byte {
return hasher.hashNode(p.Left.hash(hasher), p.Right.hash(hasher))
}
Expand Down
2 changes: 2 additions & 0 deletions output_id_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func NewOutputIDProof(api API, txCommitment Identifier, txCreationSlot SlotIndex
return nil, ierrors.Errorf("index %d out of bounds len=%d", outputIndex, len(outputs))
}

//nolint:nosnakecase // false positive
outputHasher := merklehasher.NewHasher[*APIByter[TxEssenceOutput]](crypto.BLAKE2b_256)
wrappedOutputs := lo.Map(outputs, APIByterFactory[TxEssenceOutput](api))

Expand Down Expand Up @@ -74,6 +75,7 @@ func (p *OutputIDProof) OutputID(output Output) (OutputID, error) {
return EmptyOutputID, ierrors.New("API not set")
}

//nolint:nosnakecase // false positive
outputHasher := merklehasher.NewHasher[*APIByter[TxEssenceOutput]](crypto.BLAKE2b_256)

contains, err := p.OutputCommitmentProof.ContainsValue(APIByterFactory[TxEssenceOutput](p.API)(output), outputHasher)
Expand Down
1 change: 1 addition & 0 deletions transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (t *Transaction) TransactionCommitment() (Identifier, error) {

// OutputCommitment returns the output commitment which is the root of the merkle tree of the outputs.
func (t *Transaction) OutputCommitment() (Identifier, error) {
//nolint:nosnakecase // false positive
outputHasher := merklehasher.NewHasher[*APIByter[TxEssenceOutput]](crypto.BLAKE2b_256)
wrappedOutputs := lo.Map(t.Outputs, APIByterFactory[TxEssenceOutput](t.API))

Expand Down

0 comments on commit dbd1781

Please sign in to comment.