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

refactor: use len check instead of nil check in multisignature #14648

Merged
merged 3 commits into from
Jan 17, 2023
Merged
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
11 changes: 9 additions & 2 deletions crypto/types/multisig/multisignature.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package multisig

import (
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -63,13 +64,19 @@ func AddSignatureFromPubKey(mSig *signing.MultiSignatureData, sig signing.Signat
if mSig == nil {
return fmt.Errorf("value of mSig is nil %v", mSig)
}

if sig == nil {
return fmt.Errorf("value of sig is nil %v", sig)
}

if pubkey == nil || keys == nil {
return fmt.Errorf("pubkey or keys can't be nil %v %v", pubkey, keys)
if pubkey == nil {
return fmt.Errorf("pubkey can't be nil %v", pubkey)
}

if len(keys) == 0 {
return errors.New("keys can't be empty")
}

index := getIndex(pubkey, keys)
if index == -1 {
keysStr := make([]string, len(keys))
Expand Down