Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Handle error when calculating SHA peer id
Browse files Browse the repository at this point in the history
  • Loading branch information
placer14 committed Jul 10, 2019
1 parent 29bbd0f commit 586cd26
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ func IDFromPublicKey(pk ic.PubKey) (ID, error) {
if AdvancedEnableInlining && len(b) <= maxInlineKeyLength {
alg = mh.ID
}
hash, _ := mh.Sum(b, alg, -1)
// OpenBazaar: handle the Sum error
hash, err := mh.Sum(b, alg, -1)
if err != nil {
return "", err
}
return ID(hash), nil
}

Expand All @@ -177,7 +181,10 @@ func HashedIDFromPublicKey(pk ic.PubKey) (ID, error) {
if err != nil {
return "", err
}
hash, _ := mh.Sum(b, mh.SHA2_256, -1)
hash, err := mh.Sum(b, mh.SHA2_256, -1)
if err != nil {
return "", err
}
return ID(hash), nil
}

Expand All @@ -189,7 +196,10 @@ func InlineIDFromPublicKey(pk ic.PubKey) (ID, error) {
if err != nil {
return "", err
}
hash, _ := mh.Sum(b, mh.ID, -1)
hash, err := mh.Sum(b, mh.SHA2_256, -1)
if err != nil {
return "", err
}
return ID(hash), nil
}

Expand Down

0 comments on commit 586cd26

Please sign in to comment.