Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Commit

Permalink
use bytes.Compare instead of reimplementing it
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Nov 26, 2019
1 parent fbb6727 commit 2b58ab5
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions crypto.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package libp2ptls

import (
"bytes"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
Expand Down Expand Up @@ -227,13 +228,5 @@ func preferServerCipherSuites() bool {
func comparePeerIDs(p1, p2 peer.ID) int {
p1Hash := sha256.Sum256([]byte(p1))
p2Hash := sha256.Sum256([]byte(p2))
for i := 0; i < sha256.Size; i++ {
if p1Hash[i] < p2Hash[i] {
return -1
}
if p1Hash[i] > p2Hash[i] {
return 1
}
}
return 0
return bytes.Compare(p1Hash[:], p2Hash[:])
}

0 comments on commit 2b58ab5

Please sign in to comment.